Handling Nested Group Permisions (ASP.NET Role Provider)

自作多情 提交于 2019-12-10 12:19:43

问题


We have a security module which, based on group/role membership, controls permissions to resources in ASP.Net. I've built a custom ASP.Net Role Provider that queries Active Directory for group membership and which is used by this module.

Security checking works as follows for each request (caching used in places for performance reasons but excluded from this list):

  1. Query AD for list of users group memberships
  2. Query database for a list of users and groups with access to the requested resource
  3. Compare results from AD with results from the database. If the user explicitly has rights or if a group that the user is in has rights then allow access, else don't.

The problem arises when we have nested groups. Lets say we have two groups: ParentGroup and ChildGroup, where ChildGroup is a member of ParentGroup in Active Directory and where our user is a member of ChildGroup. According to the logic above if we give ChildGroup access to a resource then then the user can access the resource too.

Now logically (to me anyways) if we give ParentGroup access to a resource then all members of it, and any sub groups and their members acquired recursively, should also be able to access said resource. But instead, because of the way my logic works they can't access the resource. Step 1 from the above list does not see ParentGroup it only see's ChildGroup, and Step 2 only see's ParentGroup and does not see ChildGroup.

So the question is, to make it work how I described it "Logically" should, where should I fix the problem, and is there some method that would work better then another?


回答1:


Try using the WindowsPrincipal.IsInRole() method instead of querying AD directly. I posted some sample code over here which might help.



来源:https://stackoverflow.com/questions/4430567/handling-nested-group-permisions-asp-net-role-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!