BLOGROLLS

Changing UID

By: Simon Quantrill On: Tue 13 January 2015
In: Unknown
Tags:

All users accounts have NEW UID in the ldap to change current accounts over these are the current draft procedures:

First we need to retrieve the users information stored on the ldap server but before that install the ldap-utils. ldapsearch -x -h mariner -b “dc=argoss,dc=nl” -s sub “cn= ”

aptitude install ldap-utils root@smart3:~# ldapsearch -x -h leonardo -b "dc=argoss,dc=nl" -s sub "cn=Simon Quantrill"

extended LDIF

LDAPv3

base with scope sub

filter: cn=Simon Quantrill

requesting: ALL

Simon Quantrill, people, argoss.nl

dn: cn=Simon Quantrill,ou=people,dc=argoss,dc=nl givenName: Simon sn: Quantrill cn: Simon Quantrill uidNumber: 1003 gidNumber: 300 homeDirectory: /home/quantrill zarafaAdmin: 1 mail: quantrill@argoss.nl objectClass: inetOrgPerson objectClass: posixAccount objectClass: top objectClass: zarafa-user uid: quantrill loginShell: /bin/bash

search result

search: 2 result: 0 Success

numResponses: 2

numEntries: 1

uidNumber: 1003 gidNumber: 300

Is the UID and the GID respectively

next retrieve the OLD UID/GID cat /etc/passwd | grep

root@smart3:~# cat /etc/passwd | grep quantrill quantrill:x:1001:1001:Simon Quantrill,,,:/home/quantrill:/bin/bash as can be seen the local entry in incorrect it should be the same as the one held on the ldap server. so it needs changing

to perform this task we have to modify the account information using usermod.

root@smart3:~# usermod -u 1003 -U quantrill root@smart3:~# usermod -g 300 quantrill Here we change the user information to the correct uid and gid found in the ldap. This only changes the users information at this point files owned by this user still use the old number so we need to search for there files and change them over.

root@smart3:~# find / -user 1001 -print | xargs -t chown quantrill At this point logout as root and log back in as the user just changed. check that all is as it should be..

If you can login its good sofar.. the use id to check the change

quantrill@smart3:~$ id uid=1003(quantrill) gid=300(agstaff) groups=300(agstaff) the user information here is correct next check the files

you need to login as root

root@smart3:~# find / -user 1003 /home/quantrill /home/quantrill/.bashrc /home/quantrill/.bash_profile /home/quantrill/.bash_logout /home/quantrill/.bash_history find: /proc/19429/task/19429/fd/4: No such file or directory find: /proc/19429/fd/4: No such file or directory root@smart3:~# find / -group 300 /var/run/console/quantrill:1 /home/quantrill/.bash_history find: /proc/19430/task/19430/fd/4: No such file or directory find: /proc/19430/fd/4: No such file or directory That.s it all done..


If you found the article helpful, please share or cite the article, and spread the word:


For any feedback or corrections, please write in to: Simon Quantrill