DN parsing (was: [patch] Demo/simplebrowse.py fixes/enhancemnts)

Michael Ströder michael at stroeder.com
Wed Dec 19 17:37:01 CET 2001

David Leonard wrote:
> On Wed, 19 Dec 2001, Michael Ströder typed thusly:
> > Note that in X.500 DNs are usually noted from root to entry's RDN in
> > the order left-to-right. In opposite with LDAP the order from tree
> > root to entry's RDN is right-to-left (separated by comma, see RFC
> > 2253).
> ahhhh... that was the cause of some of my confusion.  thanks.

Over LDAP you always get the LDAP DN string representation of the
DN. No matter if the LDAP server just acts as a gateway to a X.500
DSA or as a stand-alone LDAP server with own DB backend.

BTW: Even OpenLDAP does not do the DN parsing completely. Comparing
equality of DNs is not trivial. I thought about implementing a
Python class for that.

David, do you have a suggestion how to implement parsing DNs? E.g.
break up

'cn=Stroeder\, Michael+mail=michael at stroeder.com,ou=Weird

into a Python data structure:

    ('cn',u'Stroeder, Michael'),
    ('mail',u'michael at stroeder.com')
    ('ou',u'Weird chars=+,#')

Note the multi-valued RDN. See RFC 2253 for the BNF of this mess...

Ciao, Michael.

More information about the python-ldap mailing list