I am using AD groups for my intranet application.
<authentication mode="Windows" /> <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider"> <providers> <clear /> <add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </roleManager>
and then added authorization attributes to my controller actions that I needed to protect:
[Authorize(Roles = MyNamesspace.Constants.MANAGER_GROUP)] public ActionResult Blah() {...
And in the view, you can use User.IsInRole and the name of your AD / Windows group.
Or get a list of the roles that the web server sees with this user: System.Web.Security.Roles.GetRolesForUser();
Caution: my server and my clients are in the same domain. this will not work if you need to do the same for off-site web clients against your ActiveDirectory.
source share