【发布时间】:2013-11-06 19:19:00
【问题描述】:
我想问你是否有从 LDAP 中的子组获取父组的解决方案?我做了一些搜索,我们可以使用像 &(objectClass=group)(memberof:1.2.840.113556.1.4.1941:=PATH_TO_GROUP1) 这样的过滤器来获取组的子组,但我想知道是否有办法从子组中获取父组。
提前谢谢你。
【问题讨论】:
标签: c# active-directory
我想问你是否有从 LDAP 中的子组获取父组的解决方案?我做了一些搜索,我们可以使用像 &(objectClass=group)(memberof:1.2.840.113556.1.4.1941:=PATH_TO_GROUP1) 这样的过滤器来获取组的子组,但我想知道是否有办法从子组中获取父组。
提前谢谢你。
【问题讨论】:
标签: c# active-directory
您只需要查询组的 AD,并获取 memberof 属性,即可获取 subgroup 所属的所有组。以下应该是您需要的。
// assuming your domain is "my.ad.domain.com"
DirectoryEntry entry = new DirectoryEntry("LDAP://DC=my,DC=ad,DC=domain,DC=com");
// the subgroup you want to find the parents for is "ChildGroup"
DirectorySearcher searcher = new DirectorySearcher(entry, "(&(objectcategory=group)(cn=ChildGroup))", new string[] { "memberof" });
SearchResult result = searcher.FindOne();
// then you can access its groups the usual way
foreach (var group in result.Properties["memberof"])
{
...
}
【讨论】: