Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net Role-based authentication using Security groups in Active Directory

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:

  1. <roleManager enabled="true"/> in web.config
  2. <allow roles ="domain\groupA"/> in web.config
  3. IIS set to windows authentication
  4. 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.

like image 655
Kolten Avatar asked Oct 16 '08 16:10

Kolten


People also ask

How is role-based authorization implemented in ASP NET?

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.

Which of the following is role-based authorization in asp net?

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.

Which of the following are the right authentication modes for implementing role-based security?

They are - Windows Authentication, Forms Based Authentication and Passport Authentication.

How do you do role-based authorization?

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.


1 Answers

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>
like image 152
tvanfosson Avatar answered Oct 07 '22 16:10

tvanfosson