[Mono-bugs] [Bug 80687][Nor] New - HttpWebRequest does not authenticate via NTLM

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Jan 31 08:44:06 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by dave at digi-link.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80687

--- shadow/80687	2007-01-31 08:44:06.000000000 -0500
+++ shadow/80687.tmp.11716	2007-01-31 08:44:06.000000000 -0500
@@ -0,0 +1,102 @@
+Bug#: 80687
+Product: Mono: Class Libraries
+Version: 1.2
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: dave at digi-link.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: HttpWebRequest does not authenticate via NTLM
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing.
+Description of Problem:
+When a server requires NTLM authentication, HttpWebRequest immediately 
+throws an WebException saying the client is Unauthorized.
+If the server requires Basic authentication, HttpWebRequest successfully 
+retreives the resource
+
+Steps to reproduce the problem:
+1. Find two servers, one using Basic authentication, one using NTLM 
+authentication
+2. Use code below on each
+
+static void ReadFromServer (string url, string username, string password)
+{
+   try
+   {
+      Console.WriteLine (url);
+      HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create 
+(url);
+      request.Credentials = new NetworkCredential (username, password);
+      WebResponse response = request.GetResponse ();
+      StreamReader reader = new StreamReader (response.GetResponseStream 
+(), System.Text.Encoding.ASCII);
+      for (int i = 0; i < 5; i++)
+      {
+         Console.WriteLine (reader.ReadLine ());
+      }
+      response.Close ();
+      Console.WriteLine ();
+   }
+   catch (WebException err)
+   {
+      Console.WriteLine (err.Message);
+   }
+}
+
+Actual Results:
+http://basic-auth-server
+first
+few
+lines
+of
+file
+
+http://ntlm-auth-server
+The remote server returned an error: (401) Unauthorized.
+
+Expected Results:
+http://basic-auth-server
+first
+few
+lines
+of
+file
+
+http://ntlm-auth-server
+first
+few
+lines
+of
+file
+
+How often does this happen? 
+Every time
+
+Additional Information:
+The code snippet works fine in .Net but when run via Mono the result is 
+consistently Unauthorized.
+Observing the requests between client and server, the exchanges seem to 
+be as follows
+
+.Net
+Client -> Server GET
+Client <- Server 401, WWW-Authenticate: NTLM
+Client -> Server Get, NTLM Data p1
+Client <- Server 401, NTLM Data p2
+Client -> Server Get, NTLM Data p3
+Client <- Server 200
+
+Mono
+Client -> Server GET
+Client <- Server 401, WWW-Authenticate: NTLM
+*Exception thrown*


More information about the mono-bugs mailing list