[Samba] smbpasswd to LDAP

Luca Olivetti luca at wetron.es
Thu Mar 17 16:46:02 GMT 2005

Matt Lung wrote:
> Is there a way to take users samba passwords from an old 2.x Samba server, and
> insert them into a new 3.x Samba server that using an LDAP backend?  The new
> server is already populated with all users and groups in LDAP and is currently
> on a test network.  All that is needed is the users samba passwords from the
> old server that is using the smbpasswd file.

If there aren't samba attributes in ldap you can use

pdbedit -i smbpasswd:<smbpasswd-file-path>

If there are already samba attributes this won't work.

What I did was:
- clean the ldap database (easy here since I was just testing)
- smbldap-populate -k 0 -a root
- obtain /etc/passwd, /etc/shadow, /etc/samba/smbpasswd from the old machine
- remove all machine accounts, system groups and other users/groups you 
don't in ldap from all these files

at this point, if you have special characters (like, á, é, í, etc.) in 
your files, you'll have to make somewhat a cleaned-up copy, since the 
idealx tools don't work with non us-ascii characters

-temporarily add users in /etc/passwd of the new machine
-pdbedit -i smbpasswd:<smbpasswd-file>
-remove the users previously added to /etc/passwd
-smbldap-migrate-passwd -d account -a -P <your cleansed passwd file> -S 
<your shadow file>
-smbldap-migrate-group -a -G <your cleansed group file>

What I done may be totally wrong, YMMV, etc., but it seems it has worked 
fine so far.
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004      Fax +34 93 5883007

More information about the samba mailing list