Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I query an organizational unit for its groups with LDAP?

I have tried many queries, but this gets me my OU:

(&(objectCategory=organizationalUnit)(Name=MyOU)) (I just get the ou here)

I tried to use (&(objectCategory=organizationalUnit)(objectClass=group)(Name=MyOU)) but failed.

Also, (&(objectCategory=Group)(cn=MyOU,dc=mytop,dc=mysuffix)) and failed.

I am trying to get the groups within the OU. I have searched a lot but cannot come up with it. How do I find the groups within the OU? I have a routine that will print out the groups. I just can't get the query right.

Thank you for any help.

like image 469
johnny Avatar asked Aug 03 '09 21:08

johnny


People also ask

How do I query a LDAP database?

To search for the LDAP configuration, use the “ldapsearch” command and specify “cn=config” as the search base for your LDAP tree. To run this search, you have to use the “-Y” option and specify “EXTERNAL” as the authentication mechanism.

What is the difference between organizational units and Active Directory groups?

Groups are for granting access to data and organizational units (OUs for short) are for organizing and controling objects (users and computers) via delegation and group policy settings.


1 Answers

cn=MyOU,dc=mytop,dc=mysuffix does not go in the filter - this is the Base DN of your search.

The filter you need is just (objectClass=group).

like image 144
Andrew Strong Avatar answered Oct 10 '22 10:10

Andrew Strong