Return to HomePage, ASPNET2SecurityFAQs


Question: How do I use Windows Groups for role authorization in ASP.NET 2.0?

Answer:

If you use Windows authentication, you can use ASP.NET 2.0 role manager with the WindowsTokenRoleProvider for role-based authorization using Windows groups.
Enable role manager by setting the enabled attribute on the <roleManager> element to true. Note that the machine level Web.config file contains a default configuration for a WindowsTokenRoleProvider instance named AspNetWindowsTokenRoleProvider. You can use this provider instance and set it as the default provider by modifying your Web.config file as follows.

		 <system.web>
		    <roleManager enabled="true" 
		        defaultProvider="AspNetWindowsTokenRoleProvider" />
		 </system.web>
	

To check role membership to authorize callers, use the role manager APIs such as IsUserInRole.
		 if(Roles.IsUserInRole("Readers")){};  
	

More Information

For information on using WindowsTokenRoleProvider, see “How To: Use Role Manager in ASP.NET 2.0” at http://msdn.microsoft.com/library/en-us/dnpag2/html/PAGHT000013.asp


Return to HomePage, ASPNET2SecurityFAQs
Microsoft Communities