====== Migrate vpopmail Accounts to LDAP ======
1. Dump the accounts from MySQL
mysqldump -u root -p vpopmail vpopmail > vpopmail.mydump
2. Convert mysql dump to LDIF with reformatting
awk -F\' 'BEGIN {OFS="\n";} NF==15 {print "dn: cn="$8",ou="$4",ou=qmail,o=company","cn: "$8,"objectClass: top","objectClass: person","objectClass: qmailUser","mail: "$2"@"$4,"sn: "$8,"uid: "$2"@"$4,"mailMessageStore: "$10,"userPassword: {CRYPT}"$6,""}' vpopmail.mydump > qmail-ldap.ldif
Accounts which contain an apostrophe will be missing (O'Reilly) because that is what we're using for delimeters. Find offenders with:
awk -F\' 'NF > 15' vpopmail.mydump
3. Manually add a section to the top of the LDIF file to create each domain OU. You should also clean up any records which are obviously invalid.
dn: ou=domain.com,ou=qmail,o=company
objectClass: top
objectClass: organizationalUnit
ou: domain.com
description: domain.com
4. Import the LDIF file into the LDAP directory
ldapadd -vx -h localhost -D "cn=manager,o=company" -W -f qmail-ldap.ldif