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

Re: Auto Number




Another thing that's pertinent to this, if someone wants to implement it , is server-side sorting of the resultant set. If a sort and a reverse sort flag is introduced, then one can get do a 'limit 1' query to get a simple MIN and MAX functions, and hence also auto-increment.


Peter Marschall wrote:
Hi,

On Monday 01 April 2002 08:20, you wrote:

	Is it possible to have auto number generation in LDAP. Like we have
in RDBMS, usually the primary key number is set to auto number and it keeps
incrementing as new records are added to the table. I dont think this will
be possible with LDAP ?? Any idea how can I achieve this ??


One thing you could try is:
1) Have one container for those numbers reserverd: o=IDs
2) Loop
2a) Randomly select a new number NUM
2b) Try to create an object cn=NUM,o=IDs
      On success: NUM is the new id; end
      On Failure: continue

This is not exaclty numbering (and tus is not restricted to numbers),
but it should provide you with unique identifiers and should work on
any LDAP server.

Yours
Peter




-- http://linuxquestions.org/ - Ask linux questions, give linux help. http://splint.org/ - Write safe C code. splint source-code analyzer.