WebProxy support NTLM?

  • Thread starter Thread starter vooose
  • Start date Start date
V

vooose

Consider accessing a webpage through a proxy server:

WebRequest request = WebRequest.Create("http://somepage.com");
WebProxy proxy = new WebProxy(proxyHost, proxyPort);
proxy.Credentials = new NetworkCredential(proxyUsername,
proxyPassword);
request.Proxy = proxy;

Now suppose the *proxy server* authenticates using NTLM (somepage.com
does NOT require any authentication its just a webpage). How does one
tell the WebProxy object to use NTLM?

I have tried the following not expecting much and it didnt do much:

proxy.Credentials = new
NetworkCredential(proxyUsername,proxyPassword).GetCredential(proxyURI,
"NTLM");

Regards,
 
vooose said:
Consider accessing a webpage through a proxy server:

WebRequest request = WebRequest.Create("http://somepage.com");
WebProxy proxy = new WebProxy(proxyHost, proxyPort);
proxy.Credentials = new NetworkCredential(proxyUsername,
proxyPassword);
request.Proxy = proxy;

Now suppose the *proxy server* authenticates using NTLM (somepage.com
does NOT require any authentication its just a webpage). How does one
tell the WebProxy object to use NTLM?

I have tried the following not expecting much and it didnt do much:

proxy.Credentials = new
NetworkCredential(proxyUsername,proxyPassword).GetCredential(proxyURI,
"NTLM");

The NetworkCredential covers all challenge/response schemes registered
with the AuthenticationManager class, including NTLM. Your first code
snippet should work fine.

Cheers,
 
Thanks for your reply.

Now I have a slightly different question. Suppose you were using a
non-HTTP protocol but were still required to authenticate with the NTLM
proxy - something like the following would be good:

TCPClient client = new TCPClient(..);
client .Credentials = new
NetworkCredential(proxyUsername,proxyPassword).GetCredential(proxyURI,"N
TLM");

Doing this for "Basic" authentication is easy, because you just
construct a simple statement to write to the network stream (for the
proxy). However with NTLM its more involved and besides its already
been done! (for HTTP)

I would have thought there were a million and one applications that
require authentication via NTLM that *DON'T* user HTTP-style protocols
on top of TCP. I can't find much!

Regards
 
vooose said:
Thanks for your reply.

Now I have a slightly different question. Suppose you were using a
non-HTTP protocol but were still required to authenticate with the
NTLM proxy - something like the following would be good:

TCPClient client = new TCPClient(..);
client .Credentials = new
NetworkCredential(proxyUsername,proxyPassword).GetCredential(proxyURI,
"N TLM");

Doing this for "Basic" authentication is easy, because you just
construct a simple statement to write to the network stream (for the
proxy). However with NTLM its more involved and besides its already
been done! (for HTTP)

You might want to check out Keith Brown's .NET Developer's Guide to
Windows Security. I'm afraid I'm not a great help here.
I would have thought there were a million and one applications that
require authentication via NTLM that DON'T user HTTP-style protocols
on top of TCP. I can't find much!

Don't forget that HTTP is ubiquitous, whereas a million and one
applications implementing their own application protocol are all
oddities ;-)

Cheers,
 
Back
Top