简体   繁体   中英

ASP.NET Identity Role management through LDAP Authentication

I am using Visual Studio 2013 and have developed an MVC5 application. I had implemented the application to use LocalDB with ASP.NET Identity for authentication and authorization. I have now changed it to authenticate against LDAP which I have successfully implemented. Now I need to manage user roles still with identity but I cant seem to find any relevant code in the IdentityModel.cs nor the AccountController that can point me in the right direction on how to tweak my application to authenticate through LDAP and authorize through Identity.

...authenticate through LDAP and authorize through Identity.

I'm assuming this means storing roles somewhere else (in your localdb) while using LDAP for authorization. Without seeing your code to be sure, it sounds like the job is to add claims to filter after logging in from another provider.

Here's an approach for adding that to your LDAP login:

http://brockallen.com/2013/01/17/adding-custom-roles-to-windows-roles-in-asp-net-using-claims/

After that, you can use typical MVC [Authorize(Roles="Administrator")] filters on your controllers/actions to implement roles.

Store the roles in LDAP as well - it's not rocket surgery and roles -> getmembers and user -> memberof... it'll work both ways. Just create a Container called "Roles". Then create "Groups" for each role in your app.. Add users as members of the group.. ---

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM