[Samba] Rename Samba 4 Users

Rowland Penny rpenny at samba.org
Tue Mar 21 20:05:09 UTC 2017

On Tue, 21 Mar 2017 16:23:13 -0300
Edson Tadeu Almeida da Silveira <edson.tadeu at gmail.com> wrote:

> Hi Rowland.
> After change users name and properties i had a problem when searching
> them with windows administration tool.
> All users that i have changed i cant find with search tool.
> Do you known if there is something i can do?
> Thanks!!!

Not sure, did they actually rename ?
I take it you tried with just one for a start 

I have just tried it myself and it works for me:

ldbrename -H /usr/local/samba/private/sam.ldb CN=User8,CN=Users,DC=test,DC=tld CN=User20,CN=Users,DC=test,DC=tld
Renamed 1 record

Created an ldif


dn: CN=User20,CN=Users,DC=test,DC=tld
changetype: modify
replace: sAMAccountName
sAMAccountName: User20
replace: userPrincipalName
userPrincipalName: User20 at test.tld

I didn't bother trying to change the 'cn' to itself ;-)

I then ran ldbmodify on the ldif:

ldbmodify -H /usr/local/samba/private/sam.ldb /tmp/user.ldif

Try to find the user by its new name:

ldbsearch -H /usr/local/samba/private/sam.ldb -b CN=Users,DC=test,DC=tld -s sub '(samaccountname=User20)'

dn: CN=User20,CN=Users,DC=test,DC=tld
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: user
instanceType: 4
whenCreated: 20170318131326.0Z
uSNCreated: 3840
objectGUID: 02149d6b-a6a7-43fc-bf1e-3de5b6cb0c3d
badPwdCount: 0
codePage: 0
countryCode: 0
badPasswordTime: 0
lastLogoff: 0
lastLogon: 0
primaryGroupID: 513
objectSid: S-1-5-21-799899434-4025241831-2425910908-1110
accountExpires: 9223372036854775807
logonCount: 0
sAMAccountType: 805306368
objectCategory: CN=Person,CN=Schema,CN=Configuration,DC=test,DC=tld
uid: User8
uidNumber: 10006
gidNumber: 10000
gecos: User8
loginShell: /bin/bash
unixHomeDirectory: /home/User8
msSFU30NisDomain: test
msSFU30Name: User8
unixUserPassword: ABCD!efgh12345$67890
pwdLastSet: 131343164067988970
userAccountControl: 512
cn: User20
name: User20
sAMAccountName: User20
userPrincipalName: User20 at test.tld
whenChanged: 20170321195521.0Z
uSNChanged: 3890
distinguishedName: CN=User20,CN=Users,DC=test,DC=tld

# returned 1 records
# 1 entries
# 0 referrals


More information about the samba mailing list