LDAP Query to Find an OU by Contains

Active Directory does not provide “contains” as an option for searching.  If you want to find an OU by its partial name, you can do an advanced search.  For example, if you want to find every OU that contains the letters “grp,” you and find it with this advanced query:

(&(objectclass=organizationalunit)(name=*grp*))

Active Directory Advanced Custom LDAP Search

Active Directory Advanced Custom LDAP Search

 

By putting the * wildcard both in front and behind of grp in the name field, it will expand out for any name containing the character string “grp.”

You can modify this to find other types of objects by changing objectclass=organizationalunit to other object classes.  Some examples:

objectclass=user
objectclass=contact
objectclass=person
objectclass=group
objectclass=computer

Comments are closed.