Igor Goroshko
Igor Goroshko

Reputation: 263

DirectorySearcher contains filter on two properties

I need to search users in active directory and apply 'contains' filter on two concatenated properties. So it should be something like:

(&(objectClass=user)(property1 + " " + property2=*keyword*))  

Is it possible to achieve this with DirectorySearcher?

Upvotes: 1

Views: 4870

Answers (1)

Gabriel Luci
Gabriel Luci

Reputation: 40938

No, you cannot do any concatenations in LDAP filters.

But you could split it up and check if either property contains a keyword:

(&(objectClass=user)(|(property1=*keyword*)(property2=*keyword*)))

Note that any searches that use a wildcard at the beginning can make the search perform very slowly since no indexes can be used to do that matching.

The documentation on how to construct LDAP queries is here.

Upvotes: 4

Related Questions