[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Auto-Increment



Robert Canary wrote:
Is it possible to create an auto-incrementing field in LDAP? I would
like to use it in my uidNumber field from the accoun schema.


It would certain be a wonderfull feature, IMHO.

As somebody already said, it isn't supported in OpenLDAP, but it can be accomplished at your application layer. I just released code that does exactly this with an OpenLDAP based weblog application:


http://www.mentata.com/ldaphttp/examples/gospel/jesusblog.htm

The relevant routine is in the file linked with "comment.java" and is called "getNextIdentifier". When new entries are created in a directory database with my software, I have a "preCreate" method that enables internal pre-processing, which for this object includes the creation of its identifier. Here I call this routine, which when it is first run will use a simple linear algorithm (I'm sure Howard et al could craft a better one) to determine the highest identifier value and store it. Any subsequent creations just increment and pull the next identifier value from memory. I do this in synchronized blocks to avoid the obvious race conditions.

New blog entries should be added to this example on a weekly basis, starting this weekend. I encourage you and anyone on this list to post your own comments to see this routine and OpenLDAP in action.

Jon Roberts
www.mentata.com