Beispiel #1
0
        public static bool GetLuidInfo(SE_PRIVILEGE _requestedPrivilege, out SYSTEM_LUID _luid)
        {
            SYSTEM_LUID _luidInternal = new SYSTEM_LUID();
            string      _sePrivilege  = SE_PRIVILEGE_STR(_requestedPrivilege);

            try
            {
                if (_sePrivilege.Length == 0)
                {
                    throw new InvalidEnumArgumentException("SE_PRIVILEGE INVALID");
                }

                if (_LookupPrivilegeValue(null, _sePrivilege, ref _luidInternal))
                {
                    _luid = _luidInternal;
                    return(true);
                }

                else
                {
                    var win32Exception   = new Win32Exception();
                    var exceptionMessage = string.Format("GetLuidInfo failed. REQUESTED: {0}", _sePrivilege);
                    throw new InvalidOperationException(exceptionMessage, win32Exception);
                }
            }
            catch (Exception e)
            {
                var exceptionMessage = string.Format("Internal Exception: ERROR REQUESTING: {0}", _sePrivilege);
                throw new InvalidOperationException(exceptionMessage, e);
            }
        }
Beispiel #2
0
 private static extern bool _LookupPrivilegeValue(string lpSystemName, string lpName, ref SYSTEM_LUID lpLuid);