LDAP:从亚组检索父组 [英] Ldap: retrieve parent group from subgroup

查看:127
本文介绍了LDAP:从亚组检索父组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问问你,如果有一个解决方案,以从​​LDAP亚组得到父组?我做了一些搜索,我们可以使用类似过滤器的及(对象类=组)(的memberOf:1.2.840.113556.1.4.1941:= PATH_TO_GROUP1),以获得该组的子组,但我想知道是否有一种方法可以从子组得到父组。

I want to ask you if there is a solution to get parent group from subgroups in LDAP? I did a little search and we can use the filter like &(objectClass=group)(memberof:1.2.840.113556.1.4.1941:=PATH_TO_GROUP1) to get the child groups of the group, but I want to know if there is a way to get parent group from child group.

感谢你在前进。

推荐答案

所有你应该需要的是查询AD的群组,并获得的memberOf 属性,让所有该分组组是的组成部分。下面应该是你所需要的。

All you should need is query AD for the group, and get the memberof property, to get all groups that subgroup is part of. The below should be what you need.

// 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"])
{
    ...
}

这篇关于LDAP:从亚组检索父组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆