【问题标题】:Retrieve the Active Directory groups of the current user检索当前用户的 Active Directory 组
【发布时间】:2011-08-19 19:59:38
【问题描述】:

如何获取当前用户所属的 Active Directory 组?

有没有办法使用DirectoryServices.AccountManagement 库来做到这一点?

【问题讨论】:

    标签: c# .net security active-directory


    【解决方案1】:

    我找到了方法。事实证明,DirectoryServices.AccountManagement 非常简单:

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

    【讨论】:

    • 只返回安全组?
    • GetGroups 方法返回 Active Directory 组对象。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多