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;
        }
        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));
        }
Example #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;
        }
Example #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));
        }
        /// <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;
        }
        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));
        }
Example #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;
        }
Example #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));
        }