03 Mayıs 2009

Import/Export Objects between two LDAP servers with ldapsearch, and ldapadd

I am having a lot of trouble with moving data between two ldap servers, with a GUI tool it really is messy, so I had to use good old fashioned console commands.

1. Export data into an ldif with ldapsearch:

ldapsearch -x -h [hostname] -p [port] -D [adminuserdn] -w [adminuserpassword] -b [searchbasedn] -s sub "objectclass=*" dn objectclass cn sn employeenumber > export.ldif

the stuff coming at the very end of the command is the list of attributes that I want to include in ldif. Default is include all.. If object has some attributes that is not allowed to be imported (like encrypted passwords etc.) you have to leave them out.

2. Import data into the target ldap server:
ldapadd -x -c -v -h [hostname] -p [port] -D [adminuserdn] -w [adminuserpassword] -f export.ldif -S export.ldif.log

Hiç yorum yok: