I am looking for a simple way to get all Active Directory Groups a given User is member in. There are two methods in UserPrincipal
, but both don't match this requirement:
- GetGroups(): returns all groups, but not recursive:
This method returns only the groups of which the principal is directly a member; no recursive searches are performed.
- GetAuthorizationGroups(): works recursive, but returns only security groups (no distribution groups)
This function only returns groups that are security groups; distribution groups are not returned.
Unfortunately, I am not able to find something like GetAllGroups()
or GetDistributionGroups()
. Is there a short solution to get security and distribution groups recursively?