I am working on a project that needs to do LDAP lookups, and lots of them. Some of my searches are for a single name, others are for multiple, and some allow partial matches (begin with passed string) while others don’t.
A simple LDAP test for equality filter might look like this: uid=jsmith. Searching for multiple users (an OR search, so that any of them match) requires a syntax like this: (|(uid=jsmith)(uid=jdoe)(uid=bjones)). And then to allow wildcard searching you’d need to add a * after the name (or each name in the OR example).
To make all of this simpler I wrote this little UDF. You pass it the attribute to search on, the text to search for (lists are allowed), and whether or not wildcard searches are allowed. The string that is returned can be passed to
Leave a Reply