我想使用 AccountManagement 列出组织单位中的所有组。
以下代码段适用于 DirectoryServices,但我必须在结果中使用 DirectoryEntry 路径实例化 GroupPrincipal(这感觉像是一个肮脏的修复)。
DirectoryEntry root = new DirectoryEntry("LDAP://OU=Marketing,OU=Operations,OU=Applications,DC=mycompany,DC=local")
DirectorySearcher ds = new DirectorySearcher(root);
ds.Filter = "(objectCategory=group)";
SearchResultCollection results = ds.FindAll();
有人有想法吗?
谢谢!