Ejemplo n.º 1
0
        private SafeLSA_HANDLE GetAccount(string accountName, LsaAccountAccessMask mask = LsaAccountAccessMask.ACCOUNT_VIEW)
        {
            var sid = GetSid(accountName);
            var res = LsaNtStatusToWinError(LsaOpenAccount(Handle, sid, mask, out var hAcct));

            if (res == Win32Error.ERROR_FILE_NOT_FOUND)
            {
                ThrowIfLsaError(LsaCreateAccount(Handle, sid, mask, out hAcct));
            }
            else
            {
                res.ThrowIfFailed();
            }
            return(hAcct);
        }
Ejemplo n.º 2
0
        private SafeLsaHandle GetAccount(string accountName, LsaAccountAccessMask mask = LsaAccountAccessMask.View)
        {
            var           sid = GetSid(accountName);
            SafeLsaHandle hAcct;
            int           res = LsaNtStatusToWinError(LsaOpenAccount(handle, sid, mask, out hAcct));

            if (res == 2)
            {
                ThrowIfLsaError(LsaCreateAccount(handle, sid, mask, out hAcct));
            }
            else if (res != 0)
            {
                throw new ComponentModel.Win32Exception(res);
            }
            return(hAcct);
        }
Ejemplo n.º 3
0
        private SafeLsaPolicyHandle GetAccount(string accountName, LsaAccountAccessMask mask = LsaAccountAccessMask.ACCOUNT_VIEW)
        {
            var sid = GetSid(accountName);
            SafeLsaPolicyHandle hAcct;
            var res = LsaNtStatusToWinError(LsaOpenAccount(handle, sid, mask, out hAcct));

            if (res == Win32Error.ERROR_FILE_NOT_FOUND)
            {
                ThrowIfLsaError(LsaCreateAccount(handle, sid, mask, out hAcct));
            }
            else if (res != 0)
            {
                Marshal.ThrowExceptionForHR(res);
            }
            return(hAcct);
        }
Ejemplo n.º 4
0
 private static extern int LsaOpenAccount(SafeLsaHandle PolicyHandle, SafeMemoryHandle AccountSid, LsaAccountAccessMask DesiredAccess, out SafeLsaHandle AccountHandle);
Ejemplo n.º 5
0
 public static extern uint LsaOpenAccount(SafeLsaPolicyHandle PolicyHandle, PSID AccountSid, LsaAccountAccessMask DesiredAccess, out SafeLsaPolicyHandle AccountHandle);