开发者

Retrieve the Active Directory groups of the current user

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜