LDAP/LDIF Parsing

Diez B. Roggisch deets at nospam.web.de
Thu Feb 1 12:27:11 EST 2007


> 
> 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']})


But this is exactly what your LDAP-record contains. What else should there
be? And no, you don't need a parser, as the above _is_ the parsed result.
No parser can possibly give you anything else.

You can of course create wrapper-objects, that you instantiate based on the
values in 'objectClass', and that allow convenient access to certain
properties. Yet this is entirely up to you, as there is no one else who can
forsee how things should look and work like in _your_ application.

Diez



More information about the Python-list mailing list