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

Re: Greatest value



why don't u just store the actually numbers of users in a ldap-entry or in a file?
doing a search for uid=* every time whe u add a new user is really crazy, and on a
bigger system hardly not possible... this would at least allow you to leave away
the search for uid=*, allthouhght it's not a solution for the problem at all....

regards
daniel

--
Daniel Tiefnig
Servertechnology
INFONOVA IT GmbH

weston@itdonline.net wrote:

> 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.