Ejemplo n.º 1
0
        public static LsaAuthHandle Connect(string name)
        {
            NtStatus status;
            AnsiString nameStr;
            IntPtr handle;
            LsaOperationalMode mode;

            nameStr = new AnsiString(name);

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

            return new LsaAuthHandle(handle, true);
        }
Ejemplo n.º 2
0
        public static LsaAuthHandle Connect(string name)
        {
            NtStatus           status;
            AnsiString         nameStr;
            IntPtr             handle;
            LsaOperationalMode mode;

            nameStr = new AnsiString(name);

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

            return(new LsaAuthHandle(handle, true));
        }
Ejemplo n.º 3
0
        public int LookupAuthenticationPackage(string packageName)
        {
            NtStatus   status;
            AnsiString packageNameStr;
            int        authenticationPackage;

            packageNameStr = new AnsiString(packageName);

            try
            {
                if ((status = Win32.LsaLookupAuthenticationPackage(
                         this,
                         ref packageNameStr,
                         out authenticationPackage
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }
            }
            finally
            {
                packageNameStr.Dispose();
            }

            return(authenticationPackage);
        }
Ejemplo n.º 4
0
        public TokenHandle LogonUser(
            string originName,
            SecurityLogonType logonType,
            IAuthenticationPackage package,
            TokenSource source,
            out object profileData,
            out Luid logonId,
            out NtStatus subStatus
            )
        {
            NtStatus    status;
            AnsiString  originNameStr;
            IntPtr      profileBuffer;
            int         profileBufferLength;
            IntPtr      token;
            QuotaLimits quotas;

            originNameStr = new AnsiString(originName);

            try
            {
                using (var logonData = package.GetAuthData())
                {
                    if ((status = Win32.LsaLogonUser(
                             this,
                             ref originNameStr,
                             logonType,
                             this.LookupAuthenticationPackage(package.PackageName),
                             logonData,
                             logonData.Size,
                             IntPtr.Zero,
                             ref source,
                             out profileBuffer,
                             out profileBufferLength,
                             out logonId,
                             out token,
                             out quotas,
                             out subStatus
                             )) >= NtStatus.Error)
                    {
                        Win32.Throw(status);
                    }

                    using (var profileBufferAlloc = new LsaMemoryAlloc(profileBuffer, true))
                        profileData = package.GetProfileData(new MemoryRegion(profileBuffer, 0, profileBufferLength));

                    return(new TokenHandle(token, true));
                }
            }
            finally
            {
                originNameStr.Dispose();
            }
        }
Ejemplo n.º 5
0
        public int LookupAuthenticationPackage(string packageName)
        {
            int authenticationPackage;

            AnsiString packageNameStr = new AnsiString(packageName);

            try
            {
                Win32.LsaLookupAuthenticationPackage(
                    this,
                    ref packageNameStr,
                    out authenticationPackage
                    ).ThrowIf();
            }
            finally
            {
                packageNameStr.Dispose();
            }

            return(authenticationPackage);
        }
Ejemplo n.º 6
0
        public static LsaAuthHandle Connect(string name)
        {
            IntPtr handle;
            LsaOperationalMode mode;

            AnsiString nameStr = new AnsiString(name);

            try
            {
                Win32.LsaRegisterLogonProcess(
                    ref nameStr,
                    out handle,
                    out mode
                    ).ThrowIf();
            }
            finally
            {
                nameStr.Dispose();
            }

            return new LsaAuthHandle(handle, true);
        }
Ejemplo n.º 7
0
        public static LsaAuthHandle Connect(string name)
        {
            IntPtr             handle;
            LsaOperationalMode mode;

            AnsiString nameStr = new AnsiString(name);

            try
            {
                Win32.LsaRegisterLogonProcess(
                    ref nameStr,
                    out handle,
                    out mode
                    ).ThrowIf();
            }
            finally
            {
                nameStr.Dispose();
            }

            return(new LsaAuthHandle(handle, true));
        }
Ejemplo n.º 8
0
        public TokenHandle LogonUser(
            string originName,
            SecurityLogonType logonType,
            IAuthenticationPackage package,
            TokenSource source,
            out object profileData,
            out Luid logonId,
            out NtStatus subStatus
            )
        {
            IntPtr profileBuffer;
            int profileBufferLength;
            IntPtr token;
            QuotaLimits quotas;

            AnsiString originNameStr = new AnsiString(originName);

            try
            {
                using (MemoryRegion logonData = package.GetAuthData())
                {
                    Win32.LsaLogonUser(
                        this,
                        ref originNameStr,
                        logonType,
                        this.LookupAuthenticationPackage(package.PackageName),
                        logonData,
                        logonData.Size,
                        IntPtr.Zero,
                        ref source,
                        out profileBuffer,
                        out profileBufferLength,
                        out logonId,
                        out token,
                        out quotas,
                        out subStatus
                        ).ThrowIf();

                    using (new LsaMemoryAlloc(profileBuffer, true))
                    {
                        profileData = package.GetProfileData(new MemoryRegion(profileBuffer, 0, profileBufferLength));
                    }

                    return new TokenHandle(token, true);
                }
            }
            finally
            {
                originNameStr.Dispose();
            }
        }
Ejemplo n.º 9
0
        public int LookupAuthenticationPackage(string packageName)
        {
            int authenticationPackage;

            AnsiString packageNameStr = new AnsiString(packageName);

            try
            {
                Win32.LsaLookupAuthenticationPackage(
                    this,
                    ref packageNameStr,
                    out authenticationPackage
                    ).ThrowIf();
            }
            finally
            {
                packageNameStr.Dispose();
            }

            return authenticationPackage;
        }
Ejemplo n.º 10
0
        public int LookupAuthenticationPackage(string packageName)
        {
            NtStatus status;
            AnsiString packageNameStr;
            int authenticationPackage;

            packageNameStr = new AnsiString(packageName);

            try
            {
                if ((status = Win32.LsaLookupAuthenticationPackage(
                    this,
                    ref packageNameStr,
                    out authenticationPackage
                    )) >= NtStatus.Error)
                    Win32.Throw(status);
            }
            finally
            {
                packageNameStr.Dispose();
            }

            return authenticationPackage;
        }