NTLM Authentication

Many Web resources are protected by some sort of authentication scheme. This section examines retrieving data from Web resources that require NTIM authentication. Essentially, a NetworkCredential class needs to be created. The NetworkCredential class constructor requires a username and password in the domain. The NetworkCredential class can then be assigned to the WebRequest object that is used to perform any kind of Web request. This then satisfies the authentication requirements of the remote server. The code in Listing 26.5 shows how to use authentication when requesting data from a remote server.

Listing 26.5. Authenticating a User Before the Data Is Retrieved
 try { WebRequest req = WebRequest.Create( strURL ); NetworkCredential ...

Get Special Edition Using® Microsoft® ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.