views:

25

answers:

2

Hi everyone,

I'd like to know whether it's possible to implement autocompletion on a search form which is querying a LDAP directory.

I'm creating a small widget that allows users to look for people in the LDAP directory and then display information such as phone number etc.

There's a lot of people in the directory, so it would be nice to help users by auto-completing the form according to what they wrote so far.

It's actually pretty much what jQuery UI does with Autocomplete

Do I have to request directly the LDAP directory every time the user hits a key? Or maybe should I cache (locally or on the server)?

Thanks for your help

+1  A: 

You could definitely perform an LDAP search using a wild card filter like (givenName=E*). LDAP is optimized for directory searches, and usually if you're only using the replicas, this can scale pretty well.

If you're running into capacity issues, I would recommend you perform a single list operation and cache the results. My preferable caching strategy would be on the server side, since that would reduce the load on your server.

Eran Harel
That sounds good! Could you be a little bit more specific about what you mean by replicas? Now, if I read you right, you'd cache the list on your web server side, to reduce the load on your ldap server? Thanks :)
Pedro
Sorry, I wasn't clear indeed...LDAP has a mechanism called Referrals. There a pretty good overview about this in the Sun tutorial here: http://ow.ly/283LDIn general what you should strive to do is to have a master LDAP server which serves the writes, and several slave nodes. You perform your operations on the slave nodes, and on write operations they "refer" you to the master node for writing. There are several options for how you configure this, and I am not a great master in this area. You can get an idea of what can be done from the openldap site: http://ow.ly/283KsHope this helps
Eran Harel
Ok that's great, thanks a lot for your explanations :)
Pedro
+1  A: 

Sure you can, but due to the round-trip of the request, even with the quickest of LDAP servers, you'll want to use a "delayed observer" event listener on the search field. This means that the request for the search won't go immediately on every keypress, but only after the user types some characters and pauses for a while.

I believe jquery UI already implements a delayed observer for its autocomplete things, as does scriptaculous' autocomplete widget.

P.S. Caching of all users in the directory locally in javascript and local lookup won't really work for more than a couple of hundreds of users, IMHO.

Avel
Thanks for your input, that's very helpful. And you're right, I can't actually cache all my users (more than a thousand entries)...
Pedro