简体   繁体   English

LDAP:获取特定组中的用户列表

[英]LDAP: Get list of users in a specific group

I'm trying to get all users of a specific user group.我正在尝试获取特定用户组的所有用户。 I'm doing this in java, I can connect to ldap and get results from different queries.我在 java 中这样做,我可以连接到 ldap 并从不同的查询中获取结果。 However I've searched to find solution but as far as I can tell the LDAP of my workplace is structured differently than what seems normal.但是,我已经寻找解决方案,但据我所知,我工作场所的 LDAP 结构与正常情况不同。

dn of users:用户 dn:

ou=Users,O=MYCOMPANY.COM

dn of the user group:用户组的dn:

cn=Admin,ou=Profiles,ou=MYAPP,ou=Applirights,O=MYCOMPANY.COM

For the user group, cn is the privilege level / group name (Admin) and the name of the application is in an organisational unit.对于用户组,cn 是权限级别/组名(Admin),应用程序的名称在一个组织单元中。 With this structure, how would I query for all users in this specific group?使用这种结构,我将如何查询该特定组中的所有用户?

I tried:我试过:

NamingEnumeration<?> namingEnum = ctx.search("ou=Users,O=MYCOMPANY.COM", "(cn=Admin,ou=Profiles,ou=MYAPP,ou=Applirights,O=MYCOMPANY.COM)", searchControls);

However what attributes would need to be in search controls?但是,搜索控件中需要哪些属性? I use uid which is the users login name.我使用uid这是用户登录名。

I also tried whats outlined here :我也试过这里概述的内容:

(&(objectCategory=user)(memberOf=cn=Admin,ou=MYAPP,ou=Applirights,O=MYCOMPANY.COM))

Nothing works and with that, I mean I get 0 results but no error.没有任何效果,我的意思是我得到 0 结果但没有错误。 How can I achieve this with the given organisation of ldap?如何使用给定的 ldap 组织实现这一目标?

Groups have something called memberOf : So try this:组有一个叫做memberOf东西:所以试试这个:

search -s sub -b "DC=whatever,DC=mydomain,DC=com" "(&(objectCategory=user)(memberOf=CN=GROUP,DC=whatever,DC=mydomain,DC=com))"

you fill in whatever mydomain and GROUP above ^你填写上面的whatever mydomainGROUP ^

What attributes would need to be in search controls?搜索控件中需要哪些属性?

The attributes listed in searchControls are the ones you want returned . searchControls中列出的属性是您想要返回的属性。 The one containing the group members.包含组成员的那个。 Depending on what objectClass the group object is, it might be:根据组对象是什么objectClass ,它可能是:

  • uniqueMember for groupOfUniqueNames groupOfUniqueNames uniqueMember
  • roleOccupant for organizationalRole roleOccupant用于organizationalRole roleOccupant

and so forth.等等。

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

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