473,530 Members | 2,902 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NTLM authentication - How to ?

1 New Member
I am develping a C# app that has to pull over some XML from an https site.
My code seems to work fine with standard html (at least getting it) from http sites
(like google.com). But when I change the site to an https site our local proxy server emits 407 errors (indicating that it cannot authenticate the connection). I am using and HttpWebRequest object to perform all the steps.
I have tried Basic, NTLM and Negotiate in the CredentialCache Add method, they all fall over on the https connection.

At this point I am wondering several things:

1) Does the HttpWebRequest.proxy really perform the needed NTLM negotiation?
2) If so, why is it picky about https vs http?
3) Do I need to write my own code to perform the negotiation with the proxy?
4) If so, do I do it in response to the exceptions I am getting at this point, or is there a way to circumvent the exceptions?

Here is a code snippet:
all the required params are passed into the constructor of this object method.

Expand|Select|Wrap|Line Numbers
  1.         public string SendRequest()
  2.         // run the request and return a string response
  3.         {
  4.             string FinalResponse = "";
  5.             string Cookie = "";
  6.  
  7.             NameValueCollection collHeader = new NameValueCollection();
  8.  
  9.             HttpWebResponse webresponse;
  10.  
  11.              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
  12.  
  13.              request.KeepAlive = true;
  14.             request.Timeout = 10000;
  15.             request.Method = "POST";
  16.             request.AllowAutoRedirect = false;
  17.             request.Proxy = WebProxy.GetDefaultProxy();
  18.  
  19.             string addr = "http://" + ProxyServer + ":" + String.Format("{0:D}", ProxyPort);
  20.             Uri u = new Uri(addr);
  21.  
  22.             CredentialCache wrCache = new CredentialCache();
  23.             wrCache.Add(u, "Negotiate", System.Net.CredentialCache.DefaultNetworkCredentials);
  24.  
  25.             request.Proxy.Credentials = wrCache;
  26.  
  27.             try
  28.             {
  29.                 byte[] bytes = Encoding.ASCII.GetBytes(Request);
  30.                 request.ContentLength = bytes.Length;
  31.  
  32.                 Stream oStreamOut = request.GetRequestStream();
  33.                 oStreamOut.Write(bytes, 0, bytes.Length);
  34.                 oStreamOut.Close();
  35.  
  36.                 webresponse = (HttpWebResponse)request.GetResponse();
  37.                 if (null == webresponse)
  38.                 {
  39.                     FinalResponse = "No Response from " + URI;
  40.                 }
  41.                 else
  42.                 {
  43.                     Encoding enc = System.Text.Encoding.GetEncoding(1252);
  44.                     StreamReader rdr = new StreamReader(webresponse.GetResponseStream(),enc);
  45.                     FinalResponse = rdr.ReadToEnd();
  46.                 }
  47.  
  48.             }//End of Try Block
  49.  
  50.             catch (WebException e)
  51.             {
  52.                 // some kind of error..
  53.                 if (407 == (int)e.Status)
  54.                 {
  55.                 }
  56.  
  57.                 throw CatchHttpExceptions(FinalResponse = e.Message);
  58.             }
  59.             catch (System.Exception e)
  60.             {
  61.                 throw new Exception(FinalResponse = e.Message);
  62.             }
  63.             finally
  64.             {
  65.                 // BaseHttp = null;
  66.             }
  67.             return FinalResponse;
  68.         } //End of SendRequestTo method
  69.  
Oct 4 '06 #1
2 8926
iripka
2 New Member
Hi,

I have completely the same issue.
Additonally I tried to test this scenario using the demonstration tool from Microsoft (http://support.microsoft.com/kb/303436) . The result is the same - success in case of HTTP and 407 error in case of HTTPS.

Thanks,
Sep 18 '07 #2
iripka
2 New Member
One update.

I have found this http://support.microsoft.com/kb/928563.

The files on my machine are of version *832. As I understand they are newer than version *428 mentioned in the hotfix.

Nevertheless the issue appears.
Sep 18 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4523
by: Bruce Lewis | last post by:
I've gotten NTLM authentication working with PHP 5.0.2 and IIS 5.0, so long as I use Internet Explorer 6.0.2800. Using IE 6.0.2900 authentication doesn't happen. IE displays a "Cannot find Server or DNS Error" page ("friendly HTTP message") or just hangs. Anybody know a workaround? Here's the current incarnation of my code: if...
6
1570
by: Tom | last post by:
Hi, I have activated NTLM authentication on IIS on Windows 2003, and the log files show that for each request, three or four hits are generated. Typically, the first and second hit get a 401 (authentication required) and the third hit is successful (200). While I understand this is normal behaviour with NTLM (the browser attemps an...
0
1404
by: Steve Podradchik | last post by:
Hi, In reading the docs for how to do NTLM authentication w/ .Net, an interesting problem seems to appear. Specifically, how do you set the username/password info for a 3rd party Web server that uses Basic authenticaiton AND, at the same time, go thru NT authentication. The pseudo-code is below: 'Does a basic Get request via NTLM
1
2387
by: Andy Fish | last post by:
Hi, I have an asp.net application in several tiers and I would like to enable it for NTLM. Say the web front end is running on server X and the business logic is running on server Y. In the non-NTLM case, the user types his password into the web front end and server X passes it to Y in order to authenticate him. In the NTLM case, the...
2
10748
by: samir.kuthiala | last post by:
I do some requests in the background on a page using the XMLHttpRequest object. My site uses NTLM Authentication. However if the user is not logged in, it throws up an ugly dialog box. Is there any way to suppress this? I am ok with the object throwing an error which I can catch. What I want to do is to make a request. Instead of it...
1
875
by: r0main | last post by:
Hi, I'm building a .NET C# Windows Forms Application, and I am facing authentication issues. The application makes requests to an http web server using the HttpWebRequest class. But it doesn't pass through NTLM authentication without login and password. Internet explorer and Firefox do ! UseDefaultCredentials has been set to 'true'
4
8486
by: looping | last post by:
Hi, I have to make internet connections through an ISA proxy server that use NTLM or Kerberos authorization method. I've found a program in python called ntlmaps that act like a proxy and could make the NTLM authentication, but you have to run it and make all your connection through it, not an optimal solution. So what I really need is an...
40
7528
by: webrod | last post by:
Dear All, let's say I have a web service. I would like to authenticate users who try to access it. I am on a winnt server so I will have to use NTLM but I don't want to use IIS settings. Is there a way to authenticate a user using WSE 3.0 against NTLM?? All the samples I have found on the web provide a solution based on
1
2708
by: pycraze | last post by:
Hi , I am working on NTLM (Windows NT Lan Manager )APS (Authentication Proxy Server ) , to port to C language . I am using ethereal to monitor the packets sent between client and server . NTLM is a MS proprietary protocol designed so that will allow authentication only from MS browsers . This proprietary was cracked and code was...
2
8144
by: =?Utf-8?B?TGVuc3Rlcg==?= | last post by:
A C# (.NET 2) application which uses the System.Net.HttpWebRequest object to request a resource over HTTPS is failing following the installation of a new proxy server on our internal network with 407 Proxy Authentication Required. The same request through the old proxy succeeds. The same request to an HTTP address through the new proxy...
1
7267
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7632
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5208
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3341
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1746
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
906
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.