How can I request an organizational unit for my groups with LDAP?

I tried many requests, but this gets my OU:

(&(objectCategory=organizationalUnit)(Name=MyOU)) (I just got here here)

I tried using (&(objectCategory=organizationalUnit)(objectClass=group)(Name=MyOU)) but could not.

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

I am trying to get groups inside OU. I searched a lot, but could not think of. How to find groups in the department? I have a program that will print groups. I just can't get the request correctly.

Thanks for any help.

+6
active-directory ldap domaincontroller
source share
3 answers

cn=MyOU,dc=mytop,dc=mysuffix not included in the filter - this is the base DN of your search.

The required filter is simple (objectClass=group) .

+6
source share

Try specifying a search base instead of adding to the query. From ldapsearch you will do the following:

-s dc = MyOU, dc = com Your search base may differ

From vb you must specify it in the object:

DirectoryEntry ("LDAP: // IP server // DC = MyOU, DC = com" ...

From there, the filter (objectclass = group) should get what you need.

+2
source share

If you are using powershell, just use the -SearchBase parameter

+1
source share

All Articles