[patch] Demo/simplebrowse.py fixes/enhancemnts

Michael Ströder michael at stroeder.com
Wed Dec 19 16:33:25 CET 2001

David Leonard wrote:
> On Thu, 13 Dec 2001, Michael Ströder typed thusly:
> > >   I like simplebrowse.py - it's kind of utility I was always missing
> > > in my communication with LDAP ;-) . I'm missing "cd .." though, and it
> > > keeps saying "invalid command" for almost any entered one. Fix is
> > > attached.
> >
> > I've commited it.
> But, the structure of DNs is not that simple. What you're saying is that
> you want to find the 'parent' object of an object. But the simple removing
> of some component of the DN isn't guaranteed to work.


David, you're right that DN parsing is not that simple (escaping of
special chars). Therefore I've commited a patch that uses
ldap.explode_dn(dn) instead string.split(dn,",") hoping that the
LDAP lib does it right.

But going up one level in the LDAP DN hierarchy is exactly removing
the RDN, the first DN component (first item of list returned by

> e.g.  A=a,B=b,C=c may not have as parent A=a,B=b but instead B=b,C=c.
> I found this out the hard way when doing some testing ..

Yes. The parent entry of A=a,B=b,C=c with LDAP is B=b,C=c. That's
exactly what Paul's patch is doing.

> Now, I don't fully understand X.500 so maybe someone else knows a way of
> properly defining and implementing "cd .."?

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

Ciao, Michael.

More information about the python-ldap mailing list