> On 6/26/07, Murray Trainer <[EMAIL PROTECTED]> wrote:
> > The perl script we are using to add new users is having performance
> > issues because of the time it takes to work out the next free uid in the
> > LDAP directory.  It currently gets the full list of users then goes
> > through them in ascending order until a free uid is found.  Is there a
> > faster and more elegant query to find out the next free uid?  The bigger
> > our ldap directory gets the longer it takes to find the next available
> > uid.  As a workaround, a simple and fast query that gives the next free
> > uid ignoring holes (ie deleted users) would be helpful.
> 
> If you only update from one source, why worry about the 'next
> uidnumber'. Just use a
> randon uidnumber.
> 
> A snipett of perl we use to do this:
> 
> # random search
> 
>     my $maxcount = 25;
> 
>     RAND_UID_SEARCH:
> 
>     for my $count (1..$maxcount){
> 
>         my $guess = $uidMin + int(rand($uidMax-$uidMin+1));
> 
>         next RAND_UID_SEARCH if uidNumberExists($ldap, $guess);
> 
>         next RAND_UID_SEARCH if gidNumberExists($ldap, $guess);
> 
>         print STDERR "uid=$guess, random guesses=$count\n" if $verbose;
> 
>         return $guess;
> 
>     }
> 
> 
> 
> # Random search failed, try linear
> 
>     LINEAR_UID_SEARCH:
> 
>     for my $guess ($uidMin..$uidMax){
> 
>         next LINEAR_UID_SEARCH if uidNumberExists($ldap, $guess);
> 
>         next LINEAR_UID_SEARCH if gidNumberExists($ldap, $guess);
> 
>         printf STDERR "uid=%d, random guesses=%d, linear trys=%d\n",
> 
>                       $guess, $maxcount, ($guess-$uidMin+1) if $verbose;
> 
>         return $guess;
> 
>     }
> 
> 
> 
>     croak "No free uidNumber";
> 
> 
> -- 
> Norman Gaywood, Systems Administrator
> University of New England, Armidale,
> NSW 2351, Australia


Hi,

I have certainly missed something, but what is that script that you are
using to add users?
In the same topic I am wondering, for an architecture using LDAP as a NIS
(with PAM and NSS), how it is done the users management in our local
network? How can we change the password of a user s for example in order
to be synchronized with for example a local copy of the user.
Finally I am also looking for a solution using LDAP to control file
access, and to monitor users activity (who is logged in, what are the
commands executed....)


Thanks,


NM



---
You are currently subscribed to [EMAIL PROTECTED] as: [EMAIL PROTECTED]
To unsubscribe send email to [EMAIL PROTECTED] with the word UNSUBSCRIBE as the 
SUBJECT of the message.

Reply via email to