Example #1
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();
            }
        }
        public TokenHandle LogonUser(string originName, SecurityLogonType logonType, IAuthenticationPackage package)
        {
            object profileData;
            Luid logonId;
            NtStatus subStatus;

            return this.LogonUser(
                originName,
                logonType,
                package,
                TokenHandle.PhTokenSource,
                out profileData,
                out logonId,
                out subStatus
                );
        }
        public TokenHandle LogonUser(string originName, SecurityLogonType logonType, IAuthenticationPackage package)
        {
            object   profileData;
            Luid     logonId;
            NtStatus subStatus;

            return(this.LogonUser(
                       originName,
                       logonType,
                       package,
                       TokenHandle.PhTokenSource,
                       out profileData,
                       out logonId,
                       out subStatus
                       ));
        }
        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();
            }
        }
 public TokenHandle LogonUser(SecurityLogonType logonType, IAuthenticationPackage package)
 {
     return this.LogonUser("PH.N", logonType, package);
 }
 public TokenHandle LogonUser(SecurityLogonType logonType, IAuthenticationPackage package)
 {
     return(this.LogonUser("PH.N", logonType, package));
 }