Active Directory:获取所有“安全组”
我希望在 Active Diectory 中获得所有可用的“安全组”组。
有什么想法吗?
谢谢,
I'd like to get all groups "Security Groups" available in the Active Diectory.
Any idea ?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
萌逼全场2024-12-10 06:36:15
试试这个方法,
DirectoryEntry ent1 = new DirectoryEntry("LDAP://" + _path,
"adminUser", "***********");
DirectorySearcher dSearch = new DirectorySearcher(ent1);
dSearch.Filter = "(&(objectClass=group))";
dSearch.SearchScope = SearchScope.Subtree;
SearchResultCollection results = dSearch.FindAll();
List<string> groupNames = new List<string>();
for (int i = 0; i < results.Count; i++)
{
DirectoryEntry de = results[i].GetDirectoryEntry();
groupNames.Add(de.Name.Replace("CN=", ""));
}
它对我有用:)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
由于您使用的是 .NET 3.5 或更高版本,因此您可以使用
PrincipalSearcher
和“按示例查询”主体进行搜索:如果您还没有 - 请务必阅读 MSDN 文章管理 .NET Framework 中的目录安全主体3.5 很好地展示了如何充分利用
System.DirectoryServices.AccountManagement
中的新功能Since you're on .NET 3.5 or higher, you can use a
PrincipalSearcher
and a "query-by-example" principal to do your searching:If you haven't already - absolutely read the MSDN article Managing Directory Security Principals in the .NET Framework 3.5 which shows nicely how to make the best use of the new features in
System.DirectoryServices.AccountManagement