[Samba] Scripting the next UID/GID number to use

Rowland Penny rpenny at samba.org
Wed May 30 14:53:09 UTC 2018


On Wed, 30 May 2018 16:19:11 +0200
Prunk Dump via samba <samba at lists.samba.org> wrote:

> #######################################
> # set primarySID corresponding to gid #
> #######################################
> 
> #get the group sid from the gid
> strsid=$(wbinfo --gid-to-sid=$userGid)
> primarygid=$(echo $strsid | cut -d "-" -f 8)
> 
> 
> # set the user primarySID
> echo "dn: CN=$userName,$userClassDN,$baseDN
> changetype: modify
> replace: primarygroupid
> primarygroupid: $primarygid" > /tmp/$userName
> 
> ldbmodify --url=$samDatabase -b $baseDN /tmp/$userName
> rm /tmp/$userName
> 

I wouldn't do the above, Windows expects every user to be a member of
'Domain Users' and if you change a users 'primarygroupid', you will
break this. If you want your Unix users to have a different Unix
primary group, then use a version of Samba >= 4.6.0 and use the
winbind 'ad' backend and set (in smb.conf):

 idmap config <DOMAIN> : unix_primary_group = yes

Give your user a gidNumber containing the ID of the required group.

Rowland



More information about the samba mailing list