Hi,
This blog post summarizes - Enabling Windows Authentication within an Intranet ASP.NET Web application.
Steps:
Though it is simple, best to document it here.
· “Integrated Windows Authentication” (formerly called NTLM authentication) enabled within IIS.
· In Web.config - <authentication> section which sets the mode to “Windows”.
· In Web.config - <authorization> section that denies access to “anonymous” users visiting the site.
<configuration>
<system.web>
<authentication mode="Windows" />
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</configuration>
Obtaining the Logged-in Username:
In Asp.net Page:
Dim username As String
username = User.Identity.Name
In C# class:
Dim User As System.Security.Principal.IPrincipal
User = System.Web.HttpContext.Current.User
Dim username As String
username = User.Identity.Name
Looking up Role/Group information for a User
If User.IsInRole("DOMAIN\managers") Then
Label1.Text = User.Identity.Name & " is a manager"
Else
Label1.Text = User.Identity.Name & " is not a manager"
End If
Hope this helps.
Arun Manglick
No comments:
Post a Comment