tags:

views:

26

answers:

1

Given the input from a free-form search field, I need to query the LDAP system and return user records. Our LDAP schema includes a "preferredName". Possible valid inputs include: "LastName", "GivenName", "PreferredName LastName", "LastName, PreferredName", "GivenName LastName", etc., including such variations as multiple-word last names (with or without hyphens).

Our current less-than-optimal process splits out the individual words, makes some assumptions about order (based on the presence or absence of a comma) and then makes several simple LDAP queries (e.g.: For "John Smith" it would submit the following queries:

(&(objectclass=person)(sn=*smith*)(preferredName=*john*))
(&(objectclass=person)(givenName=*john*)(sn=*smith*))

We then amalgamate and de-dupe the results of the multiple queries. A single-query solution would be much preferable, even if the query itself is complex. With my very basic understanding of LDAP query syntax, I could string together every possible permutation of the name words into one gigantic query, but I'm hoping that there's a more elegant solution.

+1  A: 

That's OK as long as all those attributes are indexed. But you can combine all those queries into one with the | operator, then the LDAP server will de-dupe it for you, and you will have much less network traffic, latency, etc.

EJP