User Tools

Site Tools


migratevpopmailaccountstoldap

Migrate vpopmail Accounts to LDAP

<toc></toc> 1. Dump the accounts from MySQL

mysqldump -u root -p vpopmail vpopmail &gt; vpopmail.mydump

2. Convert mysql dump to LDIF with reformatting

awk -F\' 'BEGIN {OFS=&quot;\n&quot;;} NF==15 {print &quot;dn: cn=&quot;$8&quot;,ou=&quot;$4&quot;,ou=qmail,o=company&quot;,&quot;cn: &quot;$8,&quot;objectClass: top&quot;,&quot;objectClass: person&quot;,&quot;objectClass: qmailUser&quot;,&quot;mail: &quot;$2&quot;@&quot;$4,&quot;sn: &quot;$8,&quot;uid: &quot;$2&quot;@&quot;$4,&quot;mailMessageStore: &quot;$10,&quot;userPassword: {CRYPT}&quot;$6,&quot;&quot;}' vpopmail.mydump &gt; qmail-ldap.ldif

<em>Accounts which contain an apostrophe will be missing (O'Reilly) because that is what we're using for delimeters.</em> Find offenders with:

awk -F\' 'NF &gt; 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 &quot;cn=manager,o=company&quot; -W -f qmail-ldap.ldif
migratevpopmailaccountstoldap.txt · Last modified: 2020/02/13 22:55 (external edit)

free spam filter