Importing LDIFs with Python-LDAP

Michael Ströder michael at stroeder.com
Sun Feb 3 00:01:04 CET 2002


Peter van Rensburg wrote:
> 
> The "dn: blabla" line is not preffered at the top of the ldif. Seems
> like specifying the dn to ldap.add_s is enough. Duh.
> 
> Somewhere between Python-LDAP and OpenLDAP it cannot handle multiple
> lists with the same attribute name (in this case objectclass). This does
> work with Netscape's directory server though.

You should check out the module ldif and the sub-module ldap.modlist
shipped with python-ldap for this kind of task. I have to admit that
there's currently no good documentation, only pydoc generated stuff
linked at http://python-ldap.sf.net/docs.html.

Note that you have to take care that your LDIF file contains the
entries in the right tree-like order. This is not necessarily true
if exporting LDIF via e.g. OpenLDAP's ldapsearch tool.

Ciao, Michael.




More information about the python-ldap mailing list