开发者

Retrieve the Active Directory groups of the current user

开发者 https://www.devze.com 2023-03-29 15:13 出处:网络
How can I get the Ac开发者_运维百科tive Directory groups the current user belongs to? Is there a way to do this using the DirectoryServices.AccountManagement library?I found how. It turned out to be

How can I get the Ac开发者_运维百科tive Directory groups the current user belongs to?

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


I found how. It 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);
0

精彩评论

暂无评论...
验证码 换一张
取 消