Reputation: 12720
This LDAP query successfully enumerates all users within a group:
memberOf=CN=MySubGroup1,OU=MyGroup1,OU=Global Groups,DC=mycompany,DC=com
The group MyGroup1 has two subgroups: MySubGroup1, MySubGroup2. In order to get all the users of MyGroup1, I could make a query to get the users of MySubGroup1, another query to get the users of MySubGroup1, and then make the union.
However, I am asking how I can achieve the same results with only one LDAP query, asking for all the users within MyGroup1 and sub-groups.
Any idea?
Upvotes: 2
Views: 15273
Reputation: 5885
If your server is Microsoft Active Directory then you can use some extended rules. One of those rules does basically what you are looking for. Look at this answer.
Try this:
memberof:1.2.840.113556.1.4.1941:=CN=Some Group,OU=My Organization Unit,DC=company,DC=com
Quoting from that answer:
[...] it is possible, when using Microsoft AD LDAP, to do authorization using nested groups by using LDAP_MATCHING_RULE_IN_CHAIN matching rule. This is much faster than searching subgroups on the client, because it is done on the DC server with less queries over network.
1.2.840.113556.1.4.1941 LDAP_MATCHING_RULE_IN_CHAIN This rule is limited to filters that apply to the DN. This is a special "extended match operator that walks the chain of ancestry in objects all the way to the root until it finds a match.
Upvotes: 3
Reputation: 11132
There is no such thing as a subgroup
, just groups. The correct term is subordinate
,
i.e., cn=mysubgroup1
is subordinate to ou=mygroup1
, and so forth.
Use the following parameters in an LDAP search request:
OU=MyGroup1,OU=Global Groups,DC=mycompany,DC=com
sub
if there is more than one 'level' beneath ou=mygroup1
, one
otherwise(|(cn=mysubgroup1)(cn=mysubgroup2))
These search request parameters should result in a search result with two entries, the distinguished of each entry, and the attributes whose values are the distinguished names of the members of each group.
Upvotes: 3