如何获取当前用户所属的Active Directory组?
有没有办法使用DirectoryServices.AccountManagement
库?
答案 0 :(得分:18)
我找到了。事实证明DirectoryServices.AccountManagement
:
using System.DirectoryServices.AccountManagement;
PrincipalSearchResult<Principal> groups = UserPrincipal.Current.GetGroups();
IEnumerable<string> groupNames = groups.Select(x => x.SamAccountName);