NTLM Authentication

  • Thread starter Thread starter r0main
  • Start date Start date
R

r0main

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'
How can my application pass through ntlm without login/password ? Do I
have to implement my own ntlm authentication procedure ?

I'm lost :(
If anyone can help,

Thanks a lot !
 
Both the WebClient and HttpWebRequest classes have the Credentials property.
The Credentials property accepts an object that implements ICredentials. The
CredentialCache class provides a store for credentials.
You can add new NetworkCredential instances to this store, or use the
CredentialCache.DefaultCredentials property to use the credentials of the
currently logged on user. The DefaultCredentials property can only be used
when authenticating against NTLM or Keberos-based authentication schemes.

Using the current logged on user's credentials:

WebClient req =new WebClient();
req.Credentials = CredentialCache.DefaultCredentials;
string results = System.Encoding.UTF8.GetString(req.DownloadData(URL))

Code like the above should work from a windows form app, provided the logged
in user on the originating machine has permissions.


Peter
 
Back
Top