Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using wildcards in LDAP search filters/queries

I have very limited knowledge in AD and LDAP queries so I have a simple question on how to use wildcards.

Supposed there is object with a displayName of "ITSM - Problem Management"

My current implementation of the filter with a wildcard is as such:

(displayName=SEARCHKEYWORD*) 

If a user would enter a keyword of "Problem", he wouldn't be able to find the object since it needs the first part of the name, that is "ITSM - "

I would like to implement the wildcard on both ends like below:

(displayName=*SEARCHKEYWORD*) 

Ideally, this would allow the entry of "Problem" and have it search for "ITSM - Problem Management". But the wildcard doesn't seem to work when you put it at the start. When I tried it, it just seems to hang-up and not return any results.

Any ideas or thoughts on how I can resolve this? Any input would be highly appreciated. Thanks!

like image 957
AnimaSola Avatar asked Mar 05 '12 09:03

AnimaSola


People also ask

Can you use wildcards in Active Directory search?

Active Directory Wildcard Searches with PowerShellYou can literally use wildcards (“*”) in your LDAP filters. You just don't need that with ANR as they are inherently wildcard searches.

How do LDAP filters work?

If an entry has one or more values for an attribute that are determined to be greater than or equal to the target value, then the filter will match that entry, even if it has other values that are determined to be less than the target value.


2 Answers

A filter argument with a trailing * can be evaluated almost instantaneously via an index lookup. A leading * implies a sequential search through the index, so it is O(N). It will take ages.

I suggest you reconsider the requirement.

like image 147
user207421 Avatar answered Oct 12 '22 16:10

user207421


Your best bet would be to anticipate prefixes, so:

"(|(displayName=SEARCHKEY*)(displayName=ITSM - SEARCHKEY*)(displayName=alt prefix - SEARCHKEY*))" 

Clunky, but I'm doing a similar thing within my organization.

like image 25
Rich Avatar answered Oct 12 '22 15:10

Rich