Author: NetworkAdminKB.com

Created: 2009-12-06

Modified: 2009-12-11

 

Version: 1.1

The CSV2LDIF utility can be used to convert any CSV file to the LDIF file format.  The LDIF file format allows making changes to objects in a LDAP directory while CSV format only allows creating new objects.  However, the CSV file format is what most utilities will export data in.

 

Requirements and Limitations

1)      The DN field is required in the CSV.  No other verification of valid field names is done.  All other fields are optional.

2)      Empty fields are not written to the LDIF file.

3)      VB6 Runtime may be required on Windows 2000 or earlier OS.

 

Notes:

1)      While not required, objectClass is recommended as a field in the CSV file.  If present, objectClass is placed as the second field in the LDIF output file.

2)      Alignment errors are reported to the screen for review later, but the lines are still processed as is.

3)      This utility was tested using Windows 2003 CSVDE to export and LDIFDE to import.

4)      CSVDE exports the escape character “\”, as double backslashes “\\”.  However, LDIF will not properly handle double backslashes.  CSV2LDIF will automatically reduce double backslashes to a single backslash.

 

Syntax:

CSV2LDIF  /i=InputFile /o=OutputFile

 

/i=InputFile   Specify the CSV file to convert to LDIF.

/o=OutputFile  Specify the filename to write the LDIF file to.

 

Example:

C:\>csv2ldif /i=contacts.csv /o=contacts.ldif

Author: NetworkAdminKB.com

Version: 1.1.0

Copyright (c) 2008-2009 NetworkAdminKB.com, All rights reserved.

Purpose: Convert a CSV (from CSVDE) to the LDIF format for LDIFDE.

 

The following line has to few columns

Tom Jones,"CN=Tom Jones,OU=Contacts,DC=domain,DC=com",contact,Jones,Tom

 

The following line has to many columns

John Smith,"CN=John Smith,OU=Contacts,DC=domain,DC=com",,Smith,,john.smith@domain.com,

 

Input: Contacts.csv

name,DN,objectClass,sn,givenName,mail

Jen Snow,"CN=Jen Snow,OU=Contacts,DC=domain,DC=com",contact,Snow,Jen,Jen.Snow@domain.com

Tom Jones,"CN=Tom Jones,OU=Contacts,DC=domain,DC=com",contact,Jones,Tom

John Smith,"CN=John Smith,OU=Contacts,DC=domain,DC=com",,Smith,,john.smith@domain.com,

 

Output: Contacts.ldif

dn: CN=Jen Snow,OU=Contacts,DC=domain,DC=com

objectclass: contact

name: Jen Snow

sn: Snow

givenname: Jen

mail: Jen.Snow@domain.com

 

dn: CN=Tom Jones,OU=Contacts,DC=domain,DC=com

objectclass: contact

name: Tom Jones

sn: Jones

givenname: Tom

 

dn: CN=John Smith,OU=Contacts,DC=domain,DC=com

name: John Smith

sn: Smith

mail: john.smith@domain.com

 

Download CSV2LDIF

Article ID: 149, Created On: 9/17/2011, Modified: 9/17/2011