[Samba] Get last uidNumber

Jonathon Reinhart jonathon.reinhart at gmail.com
Tue Nov 3 16:38:42 UTC 2020


On Tue, Nov 3, 2020 at 11:25 AM basti via samba <samba at lists.samba.org> 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

Hi, it looks like you're trying to assign uidNumber automatically. A
couple things:

See this post where Rowland suggested using these attributes to store
the maximum value in LDAP. (These are not automatically calculated,
your script would need to keep them updated.)

- msSFU30MaxUidNumber
- msSFU30MaxGidNumber

https://lists.samba.org/archive/samba/2019-June/223499.html

But also, check out my project ADMan, which does several things, one
of which is assign uidNumber / gidNumber attributes to new users:

https://gitlab.com/JonathonReinhart/adman/

Regards,
Jonathon



More information about the samba mailing list