tags:

views:

540

answers:

2

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.

+1  A: 

Try specifying a searchbase instead of adding it to the query. From ldapsearch, you'd do this:

-s dc=MyOU,dc=com your searchbase may vary

From vb, you'd specify it in the object:

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

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

vinny
+2  A: 

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).

Andrew Strong
I actually found this just before I came back here. I changed my initial search base in my php string from dc=mydomain,dc=domainsuffix, to ou=myou,dc=mydomain,dc=domainsuffix. Walking away and coming back does wonders sometimes. Thanks again (to all answerers)/
johnny