Zentyal Forum, Linux Small Business Server

Zentyal Server => Directory and Authentication => Topic started by: ATT1 on September 22, 2019, 06:21:55 pm

Title: clone old zentyal 4.1 users incl. password to new zentyal 6?
Post by: ATT1 on September 22, 2019, 06:21:55 pm
Hello,
I have the need to freshly install a new Zentyal 6 on some machine and then to add all the existing users from an existing old Zentyal 4.1 installation, which exists on the old machine.
Somehow I would not want to manually add all users again.
Is there a script or something like that, which will add all users, including all their previous passwords and groups, to a new Zentyal 6 installation from an existing Zentyal 4.1 installation ?
Title: Re: clone old zentyal 4.1 users incl. password to new zentyal 6?
Post by: doncamilo on September 24, 2019, 02:42:46 pm
 :)
In your old Zentyal server:

Code: [Select]
sudo ldbsearch -H /var/lib/samba/private/sam.ldb '(&(objectclass=user)(!(isCriticalSystemObject=TRUE)))' >> users.ldif

This users.ldif have to be cleaned by removing some of the lines (ldbadd will help you when importing telling you the lines which you have to remove for each one of the records).

Code: [Select]
sed -i '/^#/d' users.ldif
...
# do the same for lines which begin with GENSEC, primaryGroupID, sAMAccountType,
# objectGUID, pwdLastSet, memberOf  and any other that ldbadd will complain about it.
# It depends on the modules which you have used on Zentyal 4.0 and the modules which
# you have enabled in Zentyal 6.0 before to do this task

Use this command in order to view the next uid and gid which you have to use for your new users:

Code: [Select]
for i in `wbinfo -u`;do getent passwd $i | cut -d ":" -f 1,3,4 ;done;

Copy the users.ldif file on your new Zentyal 6.0:

Code: [Select]
sudo ldbadd -U lab6.lan/lacayo%lacayo -H ldap://zen6.lab6.lan users.ldif
# lab6.lan is my domain name
# lacayo is an Domain Administrator account that I have created on Webadmin with password 'lacayo'
# zen6 is my hostname
# users.ldif the fiel which you have copied

Check your new users:

Code: [Select]
sudo wbinfo -u

Use smbpasswd in order to re-new the passwords for each one of the users.

You should be able to view your users in your new Zentyal

Cheers!
Title: Re: clone old zentyal 4.1 users incl. password to new zentyal 6?
Post by: ATT1 on October 01, 2019, 02:26:53 am
Oh. My. God.
I think adding all users again, including all their groups and all their "fetch external email" is easier.....  :-(
Title: Re: clone old zentyal 4.1 users incl. password to new zentyal 6?
Post by: doncamilo on October 01, 2019, 11:30:56 am
Oh. My. God.
I think adding all users again, including all their groups and all their "fetch external email" is easier.....  :-(

Really it's not so difficult, but actually, this way of doing doesn't introduce the groups (you'll have to do with groups the same process)  ;)

Cheers!