c# - 检索当前用户的 Active Directory 组

标签 c# .net security active-directory

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

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

最佳答案

我找到了方法。结果证明,使用 DirectoryServices.AccountManagement 非常简单:

using System.DirectoryServices.AccountManagement;

PrincipalSearchResult<Principal> groups = UserPrincipal.Current.GetGroups();

IEnumerable<string> groupNames = groups.Select(x => x.SamAccountName);

关于c# - 检索当前用户的 Active Directory 组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7126746/

相关文章:

c# - Culture 是否自动应用于 ASP.Net Webforms? (不是 UICulture)

c# - 无法加载文件或程序集 'Microsoft.Data.Edm'

security - 反向代理服务器如何提高您的安全性?

apache - 当url包含特殊字符时如何重定向错误页面?

c# - 获取当前位置 Pin 以显示在 map 上

c# - Linq to SQL 连接和位置

.net - 如何*正确*使用 WCF 的接口(interface)类型?

javascript - "window.location.history.go(-2)"在主要浏览器中可能吗?

c# - Entity Framework 死锁

.net - Wix 安装程序将 DLL 放入 GAC 和程序文件夹中