Recipe: Enabling Windows Authentication within an Intranet ASP.NET Web application
page 4 of 10
by Scott Guthrie
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 36561/ 63

Solution

To enable Windows Authentication within an ASP.NET Application, you should make sure that you have “Integrated Windows Authentication” (formerly called NTLM authentication) enabled within IIS for the application you are building. 
 
You should then add a web.config file to the root directory of your ASP.NET application that contains an <authentication> section which sets the mode to “Windows”. 

You should also then add an <authorization> section to the same web.config file that denies access to “anonymous” users visiting the site.  This will force ASP.NET to always authenticate the incoming browser user using Windows Authentication – and ensure that from within code on the server you can always access the username and Windows group membership of the incoming user.

The below web.config file demonstrates how to configure both steps described above:

<configuration>
  <system.web>
   <authentication mode="Windows" />
     <authorization>
        <deny users="?"/>
      </authorization>
   </system.web>
 </configuration>

Note that the <deny users=”?”/> directive within the <authorization> section above is what tells ASP.NET to deny access to the application to all “anonymous” users to the site (the “?” character means anonymous user).  This forces Windows to authenticate the user, and ensures that the username is always available from code on the server.


View Entire Article

User Comments

Title: Help please   
Name: Kaustubh
Date: 2008-09-02 3:05:57 AM
Comment:
Hello,

I did same thing as u mentioned. But when I tried to open it through browser. it asks for windows user and password.

What could be reason ?
Title: HELP !   
Name: Bruce
Date: 2007-12-03 4:56:27 PM
Comment:
I've done this. When the browser is run from a W2K machine, I get "Cannot find server or DNS Error". When run from an XP machine, it appears to work just fine. Any ideas? Thanks.
Title: how to implement windows integrated authentication in java step by step   
Name: Shilpa
Date: 2007-08-16 3:12:57 AM
Comment:
Can I retrieve windows authentication in java
Title: Hi   
Name: Hello
Date: 2007-05-17 4:20:29 PM
Comment:
Super

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 1:16:54 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search