This tool converts vCard contact files (.vcf) into LDIF, the text format used to bulk-import entries into an LDAP directory such as OpenLDAP or Active Directory. Instead of adding contacts one at a time, you export your address book to a single .vcf, convert it here, and feed the result to ldapadd or ldifde to create every person in one operation.
How it works
A vCard is a sequence of BEGIN:VCARD … END:VCARD blocks, each containing properties like FN, EMAIL and TEL. The converter first unfolds continuation lines (lines that begin with a space continue the previous one, per RFC 6350), then parses each property along with its parameters such as TYPE=CELL.
Each contact is then mapped to an LDIF entry under the inetOrgPerson schema:
FNbecomes thecn, which also forms the entry’s relative distinguished name.Nis split intosn(family name) andgivenName.EMAILbecomes one or moremailattributes.TELwith aCELL/MOBILEtype becomesmobile, otherwisetelephoneNumber.ORGbecomesoplus anouper additional unit,TITLEbecomestitle.ADRis split intostreet,l(locality),st(region) andpostalCode.URLbecomeslabeledURIandNOTEbecomesdescription.
The distinguished name is cn=<name>,<base DN>, with RFC 4514 escaping applied to any commas or special characters in the name.
Base64 and encoding
LDIF is ASCII-oriented. Any value that contains non-ASCII characters (accented names, addresses in other scripts) or begins with a space or a reserved character must be base64-encoded. The converter detects this and emits those values using the attribute:: base64 form, which ldapadd decodes back to the original UTF-8 automatically.
Tips and example
Set the base DN to match your directory layout, for example ou=people,dc=example,dc=com. After downloading the file, import it with:
ldapadd -x -D "cn=admin,dc=example,dc=com" -W -f contacts.ldif
Review the generated cn values first — if two contacts share the same full name they will produce the same DN, so make those names unique before importing to avoid a duplicate-entry error.