[Samba] Get last uidNumber

Rowland penny rpenny at samba.org
Tue Nov 3 16:46:46 UTC 2020


On 03/11/2020 16:24, basti via samba wrote:
> Hello,
> is there a way to get the last uidNumber from ldap.
>
> I can do a ldapsearch like:
>
> ldapsearch -h samdom.example.com -D "administrator at samdom.example.com" 
> -w "changeit"  -b "DC=samdom,DC=example,DC=com" -x -LLL 
> "(uidNumber=*)" uidNumber | grep -Po "(?<=uidNumber: )([0-9]{4})" | 
> sort | tail -n1
>
> But there is no guarantee that the last returned numer is the last 
> uidNumber in LDAP.
>
> Is there a limit set by samba how many lines are returned by a query?
> Is there a attribute where the last number is stored?
>
> Best Regards
>
OK, I never told told you this, so keep it to your self 😂

How do you think the Unix attributes tabs worked in ADUC ?

You had to to install IDMU with ADUC which installed an ldif that Samba 
calls ypServ30.ldif. Amongst the objects that are installed in AD is one 
with the DN:

CN=<workgroup>,CN=ypservers,CN=ypServ30,CN=RpcServices,CN=System,DC=X

Where <workgroup> is your Netbios domain name (aka workgroup) and DC=X 
is the ldap default naming context e.g. DC=samdom,DC=example,DC=com

Now what isn't there are the two attributes you need to store the next 
uidNumber & gidNumber:

msSFU30MaxUidNumber
msSFU30MaxGidNumber

Just store the last *idNumber + 1 in each and then write a script around 
'samba-tool user add' which obtains the required ID number, uses this 
and then updates it upon successful user creation.

Rowland





More information about the samba mailing list