polling LDAP for changes
June 9, 2005 7:56 PM
Subscribe
LDAPFilter: I'm writing an application that stores its configuration in an LDAP server. I'd like to have it poll the server and reload itself when the configuration changes. What's the best way to do this?
My product will run on eDirectory, but I'd like to make it as compatible with other servers (primarily OpenLDAP) as possible. If I were just worried about eDirectory then I'd simply use the Revision attribute because it is incremented each time there is a change. Then I noticed that both OpenLDAP and eDirectory include the operational attribute modifyTimestamp which seems like exactly what I needed... at first glance.
The problem is with eDirectory, partitions, and replicas. The server I connect to will only hold a sub-reference of a partition with multiple read-write replicas. Thus, if I modify an object and then immediately read the modifyTimestamp back then I'm not guaranteed that I'll hit the same replica for both operations (and I might get the old timestamp instead of the new one).
Couple solutions I've come up with: (1) just fudge the value in my software by 30 seconds, but then I'm relying on the fact that my machine has a synced time with the tree. (2) Sleep in my software for 30 seconds and then read the value out, but I hate to add extra delay, especially since it may be perceptable to the user. (3) Loop over a search until I get the updated timestamp. (4) Force the administrator to point my software at a single LDAP server holding a read-write replica, but then I lose redundancy.
I just wish OpenLDAP had an equivalent to the Counter syntax. Any developers out there have a good solution to this? Or should I just hack in one of 1-4 above? I want to write robust software, but I'm torn on what to do.
posted by sbutler to computers & internet (4 comments total)
Another possibility is to use some sort of hash function over the subsystems to figure out if something's changed. This again might be expensive because you have to read all the configuration data back.
Googling around reveals OpenLDAP does have a system for returning the modication date of an entry but it's probably not a standard shared by eDirectory. In this case you may just have to write code to handle both servers specifically. It's not clear that the standard LDAP protocol defines a mechanism for querying metadata like entry modification or creation date.
(BTW, this seems like a bad idea to me. I'd hate the idea of a production system just up and reconfiguring itself whenever it wanted. Mayhaps consider an option to turn it off.)
posted by nixerman at 8:07 PM on June 9, 2005