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

Re: Greatest value



I ran into this same problem. As far as I know, there is nothing intrinsic in 
OpenLDAP that provides for auto-incrementing numbers or searching for the 
maximum value, like SQL does. Although, I may be wrong. Here's some pseudo code 
for the rather inefficient way I ended up solving this problem. (it's close to 
something I wrote in PHP)

ldap_search( uid=* ) //find all entries
new_uidnumber = count(results) + 1 // add 1 to the total
while ( ldap_search( uidnumber=new_uidnumber ) ) 
      //loop and increment until the new number does 
      //not match an existing entry
      new_uidnumber++ 
//Use new number, confident it is unique....

Now, this is probably really dumb code, but it works for me. If anyone has any 
other suggestions, please let me know.

Quoting Matthew Hoskins <matth@ponyexpress.net>:

> This might be off topic, and if it is, I'd be happy to repost in the proper
> list.
> 
> Is there a way to search the directory for a maximum value?
> 
> Example:
> 
> 	My LDAP stores UIDnumbers for users on the UNIX systems we administer.  
To
> create a new user, I need the next available UID (which is the highest UID +
> 1).
> 
> In a standard sql database, I could just set this value as a key and have it
> auto-increment with each new record.  Is there a similar feature in LDAP, or
> a search filter that will give me the greatest value of an attribute?
> 
> 
> Thank you for any support. And again, I will be happy to repost in an
> appropriate place.
> 
> Matthew Hoskins -- Cisco Certified Network Associate
> Ponyexpress.net / MagicCablePC / NPGCO
> Systems Administrator
> 
> 


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/