Get Active Directory groups for current user

How to get the Active Directory groups to which the current user belongs?

Is there a way to do this using the DirectoryServices.AccountManagement library?

+6
source share
1 answer

I found how. This turned out to be very simple with DirectoryServices.AccountManagement :

 using System.DirectoryServices.AccountManagement; PrincipalSearchResult<Principal> groups = UserPrincipal.Current.GetGroups(); IEnumerable<string> groupNames = groups.Select(x => x.SamAccountName); 
+14
source

Source: https://habr.com/ru/post/895447/


All Articles