Search code examples
active-directoryldapldap-query

ldap query with wildcard


I have a query like below

(|(distinguishedName=cn=Game_BI_CHARGE_BACK,ou=Groups,ou=FC,dc=na,dc=company,dc=com)(distinguishedName=cn=Game_BI_Compliance,ou=Groups,ou=FC,dc=na,dc=company,dc=com)(distinguishedName=cn=Game_BI_Finance,ou=Groups,ou=FC,dc=na,dc=company,dc=com)(distinguishedName=cn=Game_BI_GP,ou=Groups,ou=FC,dc=na,dc=company,dc=com)(distinguishedName=cn=Game_BI_MANAGED_CARE,ou=Groups,ou=FC,dc=na,dc=company,dc=com)(distinguishedName=cn=Game_BI_MEDICAID,ou=Groups,ou=FC,dc=na,dc=company,dc=com)(distinguishedName=cn=Game_BI_PowerUser,ou=Groups,ou=FC,dc=na,dc=company,dc=com)(distinguishedName=cn=Game_BI_TRADE,ou=Groups,ou=FC,dc=na,dc=company,dc=com)(distinguishedName=cn=Game_BI_TRICARE,ou=Groups,ou=FC,dc=na,dc=company,dc=com))

I want to shorten it using wildcard, All the group names start with Game_BI. The above query works, I just want to make it short.

Thanks Shashi


Solution

  • You cannot use the wildcard * character to filter the distinguishedName attribute - only exact matches will work. You can read more about that here, under the LDAP Clauses section :

    http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx

    However, according to your current filter, you could do a wildcard search by canonical name, or cn, and get the same result :

    (&(objectClass=group)(cn=Game_BI*))

    That says, "Give me all the groups that have a canonical name that begins with "Game_BI".