Convert Csv To Ldif

Edit the csv

You have to change the attribute names (first line csv) in ldap attribute names.

example csv file

"cn=Kristof Vansant,ou=Contactlist,dc=domain,dc=com",inetOrgPerson,ICT,Kristof Vansant,Vansant,Somewhere 1,3000,Gent,05 455 54 74,05 482 05 68,moc.thgir|haey#moc.thgir|haey
"cn=Lupus Vansant,ou=Contactlist,dc=domain,dc=com",inetOrgPerson,ICT,Lupus Vansant,Vansant,Somewhere 1,3000,Gent,05 455 54 74,,moc.thgir|2haey#moc.thgir|2haey

the character + in dn is not allowed use & instead

Warning: dn,ObjectClass, cn and sn must be filled in, the rest is optional!!

cn name must be unique (KriStoF and kristof are the same!)

The CSV should be in a format where the first row has column headings and the first column
should be the DN

You should know that outlook will search ldap like this: (&(|(mail=%s*)(cn=%s*)(sn=%s*)(givenName=%s*)))

We use the inetOrgPerson object because this has all the attributes we need.
The cn in the dn and the other cn on the same line must match.

convert the csv to ldif

download perl

Pick the latest win32 MSI install release

Warning: Don’t install on windows 2003 running IIS6 (seems to be fixed but haven't tested my self!)

download csv2ldif

To convert the cvs file to ldif you need following tool:

convert csv to ldif

You need to use the version if you have fields in the csv with no data.
Is needed for example if you don't have the telephone number of all the people in the list.

If your csv file has ; instead of , as seperation you have to edit and change

$separator=','; in $separator=';';

convert ASCII to UTF-8

The ldif file is now in ASCII format. Ldap won't be able to import data with special letters like é.
You have to convert the ASCII file to UTF-8 first.

download libiconv

convert ASCII to UTF-8

in cmd type

path=%path%;C:\Program Files\GnuWin32\bin
iconv -f iso8859-1 -t utf-8 foo.ldif > foonew.ldif


Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.