On Tue, 28 Nov 2000, Corisen wrote:

> Hi Thornton, thanks for your help once again. Phew....this means that to add
> a new user, I'll have to extract the uidnumber of all existing users, put it
> in an array, sort the array, find the max+1. Not very efficient but no
> choice since there's no max/min function in LDAP.  Thanks.

A simpler algorithm would be something like:

 maxuid=0
 while(uid = get_next_ldap_uid()) {
   maxuid = (maxuid < uid) ? uid : maxuid
 }

No need to store the array, and a single pass should be faster than a
sort.

Anyway, if you get clever, you can start setting your search to something
like (uidnumber > 1000) if you know a starting point and at least cut your
search down a little.

LDAP won't sort on the server, won't tell you a max, and won't lock
records by attribute, though. All these things considered for any
production system you might consider an external uidnumber locking and
incrementing system.

thornton



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to