How to determine all the groups a user belongs to (including nested groups) in ActiveDirectory and .NET 3.5

后端 未结 4 1128
情歌与酒
情歌与酒 2020-12-25 13:16

I have an application that uses ActiveDirecotry authorisation and it has been decided that it needs to support nested AD groups, e.g.:

MAIN_AD_GROUP
     |
          


        
4条回答
  •  有刺的猬
    2020-12-25 14:06

    Use UserPrincipal.GetAuthorizationGroups() instead - from its MSDN docs:

    This method searches all groups recursively and returns the groups in which the user is a member. The returned set may also include additional groups that system would consider the user a member of for authorization purposes.

    The groups that are returned by this method may include groups from a different scope and store than the principal. For example, if the principal is an AD DS object that has a DN of "CN=SpecialGroups,DC=Fabrikam,DC=com, the returned set can contain groups that belong to the "CN=NormalGroups,DC=Fabrikam,DC=com.

提交回复
热议问题