Пример #1
0
        public LsaSecretHandle(LsaPolicyHandle policyHandle, string name, LsaSecretAccess access)
        {
            NtStatus      status;
            UnicodeString nameStr;
            IntPtr        handle;

            nameStr = new UnicodeString(name);

            try
            {
                if ((status = Win32.LsaOpenSecret(
                         policyHandle,
                         ref nameStr,
                         access,
                         out handle
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }
            }
            finally
            {
                nameStr.Dispose();
            }

            this.Handle = handle;
        }
Пример #2
0
        public static LsaSecretHandle Create(LsaSecretAccess access, LsaPolicyHandle policyHandle, string name)
        {
            NtStatus      status;
            UnicodeString nameStr;
            IntPtr        handle;

            nameStr = new UnicodeString(name);

            try
            {
                if ((status = Win32.LsaCreateSecret(
                         policyHandle,
                         ref nameStr,
                         access,
                         out handle
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }
            }
            finally
            {
                nameStr.Dispose();
            }

            return(new LsaSecretHandle(handle, true));
        }
Пример #3
0
        /// <summary>
        /// Opens a LSA account.
        /// </summary>
        /// <param name="policyHandle">A handle to a LSA policy.</param>
        /// <param name="sid">The SID of the account to open.</param>
        /// <param name="access">The desired access to the account.</param>
        public LsaAccountHandle(LsaPolicyHandle policyHandle, Sid sid, LsaAccountAccess access)
        {
            IntPtr handle;

            Win32.LsaOpenAccount(
                policyHandle,
                sid,
                access,
                out handle
                ).ThrowIf();

            this.Handle = handle;
        }
Пример #4
0
        public static LsaAccountHandle Create(LsaAccountAccess access, LsaPolicyHandle policyHandle, Sid sid)
        {
            IntPtr handle;

            Win32.LsaCreateAccount(
                policyHandle,
                sid,
                access,
                out handle
                ).ThrowIf();

            return(new LsaAccountHandle(handle, true));
        }
Пример #5
0
        /// <summary>
        /// Opens a LSA account.
        /// </summary>
        /// <param name="policyHandle">A handle to a LSA policy.</param>
        /// <param name="sid">The SID of the account to open.</param>
        /// <param name="access">The desired access to the account.</param>
        public LsaAccountHandle(LsaPolicyHandle policyHandle, Sid sid, LsaAccountAccess access)
        {
            NtStatus status;
            IntPtr   handle;

            if ((status = Win32.LsaOpenAccount(
                     policyHandle,
                     sid,
                     access,
                     out handle
                     )) >= NtStatus.Error)
            {
                Win32.Throw(status);
            }

            this.Handle = handle;
        }
Пример #6
0
        public static LsaAccountHandle Create(LsaAccountAccess access, LsaPolicyHandle policyHandle, Sid sid)
        {
            NtStatus status;
            IntPtr   handle;

            if ((status = Win32.LsaCreateAccount(
                     policyHandle,
                     sid,
                     access,
                     out handle
                     )) >= NtStatus.Error)
            {
                Win32.Throw(status);
            }

            return(new LsaAccountHandle(handle, true));
        }
Пример #7
0
        public LsaSecretHandle(LsaPolicyHandle policyHandle, string name, LsaSecretAccess access)
        {
            IntPtr handle;

            UnicodeString nameStr = new UnicodeString(name);

            try
            {
                Win32.LsaOpenSecret(
                    policyHandle,
                    ref nameStr,
                    access,
                    out handle
                    ).ThrowIf();
            }
            finally
            {
                nameStr.Dispose();
            }

            this.Handle = handle;
        }
Пример #8
0
        public static LsaSecretHandle Create(LsaSecretAccess access, LsaPolicyHandle policyHandle, string name)
        {
            IntPtr handle;

            UnicodeString nameStr = new UnicodeString(name);

            try
            {
                Win32.LsaCreateSecret(
                    policyHandle,
                    ref nameStr,
                    access,
                    out handle
                    ).ThrowIf();
            }
            finally
            {
                nameStr.Dispose();
            }

            return(new LsaSecretHandle(handle, true));
        }