If I am looking for all Groups
, I get too much garbage.
If I try to narrow down the base, I get too few.
Here is an example:
CN=A Team,OU=Groups,OU=Americas,DC=example,DC=com
CN=B TEAM,OU=Groups,OU=EMEA,DC=example,DC=com
CN=C Team,OU=Legacy Groups,DC=example,DC=com
CN=D Team,OU=Groups,OU=Bangalore,OU=APAC,DC=example,DC=com
CN=E Team,OU=Common Groups,DC=example,DC=com
I am looking for a LDAP filter
that returns A B D E (without C) - mainly the logic would be get me all groups that do have last OU=Groups
or OU=Common Groups
My current search is using:
Search base: CN=Users,DC=citrite,DC=net
Filter: (objectCategory=Group)
First, on Microsoft Active Directory is impossible to do this in a single search, that's because AD is not fully LDAP compatible.
LDAP-compliant servers support an
extensible-match
filter which provides the necessary filtering. From RFC4511:Note that the extensible-match filter technique only works with LDAP-compliant servers, of which AD is not one.
For example, I added the following entries to a server:
Examine the filter in the following search after the above entries were added:
Note that
ou=common groups
,ou=groups
, and their subordinates are returned, but notou=legacy groups
and subordinates.This example uses the modern syntax of the ldapsearch command line tool. If the user is utilizing the legacy OpenLDAP version of ldapsearch, the parameters to the command line tool are somewhat different, but that does not matter. What matters is the filter.