Ok, I decided it myself. Here's how I migrated the current LDAP database to the new domain:
- Export the old LDAP database to the ldif file.
- Remove old databaes
- Create a new LDAP database with a new domain name
- Modify the exported ldif file above to match the new domain (dn root)
- Import modified ldif file into a new database
Assuming I have a new domain name, dc = my, dc = new, dc = ldap, dc = domain , and I want to move all existing LDAP data to a new one.
I took the following steps
Back up the old LDAP database
Stop OpenLDAP Server
Removing an Old LDAP Database
# cd /var/lib/ldap
Make sure LDAP is not running
NOTE. add the following lines and save
Change the current LDAP settings in the following files
/etc/ldapscripts/ldapscripts.conf
... SERVER="ldap://localhost" BINDDN="cn=admin,dc=my,dc=new,dc=ldap,dc=domain" BINDPWDFILE="/etc/ldapscripts/ldapscripts.passwd" ...
/etc/ldap/slapd.d/cn=config/olcDatabase\={1}hdb.ldif
... olcSuffix: dc=my,dc=new,dc=ldap,dc=domain olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymous auth by dn="cn=admin,dc=my,dc=new,dc=ldap,dc=domain" write by * none olcAccess: {2}to * by self write by dn="cn=admin,dc=my,dc=new,dc=ldap,dc=domain" write by * read olcRootDN: cn=admin,dc=my,dc=new,dc=ldap,dc=domain olcRootPW: <new administrator password> ...
Prepare a new LDAP directory structure, data, new_ldap.ldif , or change old_ldap.ldif to a new dn)
# Root dn: dc=my,dc=new,dc=ldap,dc=domain description: New LDAP BaseDN dc: parent o: parent.my.new.ldap.domain objectClass: top objectClass: dcObject objectClass: organization structuralObjectClass: organization # administrator dn: cn=admin,dc=my,dc=new,dc=ldap,dc=domain objectClass: simpleSecurityObject objectClass: organizationalRole cn: admin description: LDAP administrator userPassword: <new administrator password> structuralObjectClass: organizationalRole # Subtree for Users dn: ou=Users,dc=my,dc=new,dc=ldap,dc=domain ou: Users description: Parent Ldap Users objectClass: organizationalUnit objectClass: top structuralObjectClass: organizationalUnit # Subtree for Groups dn: ou=Groups,dc=my,dc=new,dc=ldap,dc=domain ou: Groups description: Parent LDAP Groups objectClass: organizationalUnit objectClass: top structuralObjectClass: organizationalUnit ...
Check out the new ldif
# slapadd -b "dc=my,dc=new,dc=ldap,dc=domain" -v -u -l new_ldap.ldif
NOTE. -u means running the command in test mode
If everything is in order, the result will look something like this:
added: "dc=my,dc=new,dc=ldap,dc=domain" added: "cn=admin,dc=my,dc=new,dc=ldap,dc=domain" added: "ou=Users,dc=my,dc=new,dc=ldap,dc=domain" added: "ou=Groups,dc=my,dc=new,dc=ldap,dc=domain" _
Add new LDAP data to the server
# slapadd -b "dc=my,dc=new,dc=ldap,dc=domain" -v -l new_ldap.ldif
You can check for updates in your blog post about this issue: http://iambusychangingtheworld.blogspot.com/2013/10/ldap-create-new-ldap-directory.html
source share