LDAP/LDIF Parsing

Michael Ströder michael at stroeder.com
Fri Feb 2 08:59:25 EST 2007


Cruelemort wrote:
> I was wondering the best way to do this? I have installed and used the
> python-ldap libraries and these allow me to access and search the
> server, but the searches always return a horrible nesting of lists,
> tuples and dictionaries, below is an example of returning just one
> record -
> 
> ('dc=example,dc=com', {'objectClass': ['top', 'dcObject',
> 'organization'], 'dc': ['example'], 'o': ['Example Organisation']})

It's just modeled after the X.500 data model. A DN and the entry. The
entry consists of attributes which consists of attribute type and a set
of attribute values.

You could write your own wrapper class around ldap.ldapobject.LDAPObject
and overrule method search_s().

> (there is an ldif library available but
> it is not obvious how this works, i cannot see much documentation, and
> it seems to be deprecated...).

Module ldif is not deprecated. It's actively maintained by me like the
rest of python-ldap. It parses LDIF and returns the same data structure
as above. You don't need it for LDAP access anyway. Only for reading
LDIF files.

Ciao, Michael.



More information about the Python-list mailing list