I am attempting to do something simple (I thought) - securing my application using roles-based security using Active Directory groups in our Domain.
Specifically, I need to show/hide items on a page depending upon whether the currently logged in user is part of domain\groupA
in Active Directory. For some reason, it is difficult finding information on using Active Directory for this. Everything I seem to find goes into details of using forms-based authentication using roles, or it uses a DB to store the information.
All I want to do is use our already outlined security structure in our Active Directory. Can someone please explain what I need?
Do I need:
<roleManager enabled="true"/>
in web.config
<allow roles ="domain\groupA"/>
in web.config
if (User.IsInRole(@"domain\groupA")){ //do stuff }
in my page?What else am I missing? Anything? 'cause its not working. heh.
Thanks all for your help.
To accomplish this, start by adding a Web. config file to the Roles folder. The <authorization> element in the <system. web> section indicates that only users in the Administrators role may access the ASP.NET resources in the Roles directory.
Role-based authorization checks specify which roles which the current user must be a member of to access the requested resource. The controller SalaryController is only accessible by users who are members of the HRManager role or the Finance role.
They are - Windows Authentication, Forms Based Authentication and Passport Authentication.
For role-based authorization, the customer is responsible for providing the user ID, any optional attributes, and all mandatory user attributes necessary to define the user to Payment Feature Services. The customer must also define the roles that are assigned to the user.
You probably just need to add a RoleProvider to your web.config to tell the app how to do searches against AD.
Sample code from here.
<roleManager defaultProvider="WindowsProvider"
enabled="true"
cacheRolesInCookie="false">
<providers>
<add
name="WindowsProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With