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

RE: Uid/Gid Question

Store the current max UID in the directory itself, use a single modify
request with
delete <old value>
add <new value>
to update it. Since the modify is atomic this operation will only succeed
if the supplied <old value> matches the one currently in the directory. No
need for app-level locks, but you may have to retry a few times if multiple
clients are updating at once. (That doesn't seem like a realistic concern
to me though.)

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc
  Symas: Premier OpenSource Development and Support 

> -----Original Message-----
> From: owner-openldap-software@OpenLDAP.org
> [mailto:owner-openldap-software@OpenLDAP.org]On Behalf Of Kervin L.
> Pierre
> Sent: Tuesday, August 13, 2002 5:01 PM
> To: Aly Dharshi
> Cc: openldap-software@OpenLDAP.org
> Subject: Re: Uid/Gid Question
> Ran into this issue as well.  I had to pull the entire ou everytime, 
> then sort and select the greatest one.  You can speed up things a little 
> by limiting the returned attribute to only the uidnumber.
> Another option is if your application keeps track of the next available 
> uid itself and increments this as necessary.  We use PHP so this is hard 
> to do, lots of locking issues.  JSP application server would do this 
> easily as you could keep the next available uid variable in application 
> scope.
> The totally LDAP approach, I'm guessing is to use the "server side sort" 
> control RFC2891 ( http://www.ietf.org/rfc/rfc2891.txt ) together with 
> the simple paged result control RFC2696 ( 
> http://www.ietf.org/rfc/rfc2696.txt ) .  But these controls aren't 
> supported in OpenLDAP as yet.  Using these, you'd be able to do a 
> reverse server side sort on uidnumber and limit the returned values to 1
> --Kervin
> Aly Dharshi wrote:
> > Hello All,
> > 
> >     I want to use perl to develop a script to add users and such other 
> > functionality. I just wanted to find out what would be the simplest way 
> > to get
> > the next available uid/gid combo, say if aly is 500:500 for user/group 
> > how could I get 501 for the next user ? Is there some function ?
> > 
> >     Cheers,
> > 
> >     Aly.
> > 
> >