Exemplo n.º 1
0
        public NtlmAuth()
        {
            int num = NtlmAuth.AcquireCredentialsHandle(null, "NTLM", 1u, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, ref this._credentialsHandle, ref this._timestamp);

            if (num != 0)
            {
                throw new InvalidOperationException();
            }
            this._credentialsHandleAcquired = true;
        }
Exemplo n.º 2
0
 private void FreeUnmanagedResources()
 {
     if (this._securityContextAcquired)
     {
         NtlmAuth.DeleteSecurityContext(ref this._securityContext);
     }
     if (this._credentialsHandleAcquired)
     {
         NtlmAuth.FreeCredentialsHandle(ref this._credentialsHandle);
     }
 }
Exemplo n.º 3
0
        private bool TryNtlmAuthenticate()
        {
            try
            {
                using (NtlmAuth ntlmAuth = new NtlmAuth())
                {
                    while (true)
                    {
                        string text  = null;
                        string text2 = this._knownRequestHeaders[24];
                        if (text2 != null && text2.StartsWith("NTLM ", StringComparison.Ordinal))
                        {
                            text = text2.Substring(5);
                        }
                        if (text != null)
                        {
                            if (!ntlmAuth.Authenticate(text))
                            {
                                break;
                            }
                            if (ntlmAuth.Completed)
                            {
                                goto IL_9A;
                            }
                            text2 = "WWW-Authenticate: NTLM " + ntlmAuth.Blob + "\r\n";
                        }
                        else
                        {
                            text2 = "WWW-Authenticate: NTLM\r\n";
                        }
                        this.SkipAllPostedContent();
                        this._connection.WriteErrorWithExtraHeadersAndKeepAlive(401, text2);
                        if (!this.TryParseRequest())
                        {
                            goto Block_8;
                        }
                    }
                    this._connection.WriteErrorAndClose(403);
                    bool result = false;
                    return(result);

Block_8:
                    result = false;
                    return(result);

IL_9A:
                    if (this._host.GetProcessSID() != ntlmAuth.SID)
                    {
                        this._connection.WriteErrorAndClose(403);
                        result = false;
                        return(result);
                    }
                }
            }
            catch
            {
                try
                {
                    this._connection.WriteErrorAndClose(500);
                }
                catch
                {
                }
                bool result = false;
                return(result);
            }
            return(true);
        }