简体   繁体   English

在活动目录c#ldap中搜索用户

[英]searching users in active directory c# ldap

I am trying to get users who are members of a particular group in AD. 我正在尝试获取属于AD中特定组成员的用户。

I am trying with the following filters but i am unsuccessful. 我正在尝试使用以下过滤器,但未成功。

1) 1)

DirectoryEntry entry1 = new DirectoryEntry("LDAP://DC=xxinfo,DC=com");
string query = "(&(objectCategory=person)(objectClass=user)(memberOf=CN=Guests))";

2) 2)

objSearchADAM.Filter = "(&(ObjectClass=user)(memberOf=CN=Network Configuration perators,CN=Builtin,DC=xxxx,DC=xxinfo,DC=com))";

also, is there any way to get users using this approach? 还有,有什么方法可以让用户使用这种方法?

PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "group_name");

this searches the current domain, i want to search the whole forest.is there any way to initialize ctx for whole forest? 这搜索当前域,我想搜索整个森林。是否有任何方法可以初始化整个森林的ctx?

any help would be appreciated. 任何帮助,将不胜感激。 thank you. 谢谢。

Got the answer!! 得到了答案!! used below code using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "subdomain.domain.comany.com:3268", "DC=comapny,DC=com")) { GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx, "Group_Name"); 在下面的代码中使用(PrincipalPrincipal ctx = new PrincipalContext(ContextType.Domain,“ subdomain.domain.comany.com:3268”,“ DC = comapny,DC = com”)){GroupPrincipal group = GroupPrincipal.FindByIdentity(ctx,“ Group_Name “);

port 3268 is used to search in global catalog. 端口3268用于在全局目录中搜索。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM