Example #1
0
        private bool TryNtlmAuthenticate()
        {
            try
            {
                using (var auth = new NtlmAuth())
                {
                    do
                    {
                        string blobString   = null;
                        string extraHeaders = _knownRequestHeaders[0x18];
                        if ((extraHeaders != null) && extraHeaders.StartsWith("NTLM ", StringComparison.Ordinal))
                        {
                            blobString = extraHeaders.Substring(5);
                        }
                        if (blobString != null)
                        {
                            if (!auth.Authenticate(blobString))
                            {
                                _connection.WriteErrorAndClose(0x193);
                                return(false);
                            }
                            if (auth.Completed)
                            {
                                goto Label_009A;
                            }
                            extraHeaders = "WWW-Authenticate: NTLM " + auth.Blob + "\r\n";
                        }
                        else
                        {
                            extraHeaders = "WWW-Authenticate: NTLM\r\n";
                        }
                        SkipAllPostedContent();
                        _connection.WriteErrorWithExtraHeadersAndKeepAlive(0x191, extraHeaders);
                    } while (TryParseRequest());
                    return(false);

Label_009A:
                    if (_host.GetProcessSid() != auth.SID)
                    {
                        _connection.WriteErrorAndClose(0x193);
                        return(false);
                    }
                }
            }
            catch
            {
                try
                {
                    _connection.WriteErrorAndClose(500);
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch
                // ReSharper restore EmptyGeneralCatchClause
                {
                }
                return(false);
            }
            return(true);
        }
Example #2
0
        public override void EndOfRequest()
        {
            Connection conn = _connection;

            if (conn != null)
            {
                _connection = null;
                _server.OnRequestEnd(conn, GetProcessUser());
            }

            if (_auth != null)
            {
                _auth.Dispose(); //
                _auth = null;
            }
        }
Example #3
0
 private bool TryNtlmAuthenticate()
 {
     try
     {
         using (var auth = new NtlmAuth())
         {
             do
             {
                 string blobString = null;
                 string extraHeaders = _knownRequestHeaders[0x18];
                 if ((extraHeaders != null) && extraHeaders.StartsWith("NTLM ", StringComparison.Ordinal))
                 {
                     blobString = extraHeaders.Substring(5);
                 }
                 if (blobString != null)
                 {
                     if (!auth.Authenticate(blobString))
                     {
                         _connection.WriteErrorAndClose(0x193);
                         return false;
                     }
                     if (auth.Completed)
                     {
                         goto Label_009A;
                     }
                     extraHeaders = "WWW-Authenticate: NTLM " + auth.Blob + "\r\n";
                 }
                 else
                 {
                     extraHeaders = "WWW-Authenticate: NTLM\r\n";
                 }
                 SkipAllPostedContent();
                 _connection.WriteErrorWithExtraHeadersAndKeepAlive(0x191, extraHeaders);
             } while (TryParseRequest());
             return false;
         Label_009A:
             if (_host.GetProcessSid() != auth.SID)
             {
                 _connection.WriteErrorAndClose(0x193);
                 return false;
             }
         }
     }
     catch
     {
         try
         {
             _connection.WriteErrorAndClose(500);
         }
         // ReSharper disable EmptyGeneralCatchClause
         catch
         // ReSharper restore EmptyGeneralCatchClause
         {
         }
         return false;
     }
     return true;
 }
Example #4
0
        public override void EndOfRequest()
        {
            Connection conn = _connection;
            if (conn != null)
            {
                _connection = null;
                _server.OnRequestEnd(conn, GetProcessUser());
            }

            if (_auth != null)
            {
                _auth.Dispose(); //
                _auth = null;
            }
        }