简体   繁体   中英

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM