directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <>
Subject Re: Empty DN ("") String Value?
Date Tue, 27 Nov 2007 10:39:58 GMT
Hi guys,

> Jon Roberts wrote:
>> Since there is a no-argument constructor DN(), perhaps the original
>> thinking was that null and the rootDSE "" are synonymous. 
It was not really a thinking, much more a literal implementation of the 

RFC 4514 states :

 2.1.  Converting the RDNSequence

    If the RDNSequence is an empty sequence, the result is the empty or
    zero-length string.

In java, the zero-length String is "", not null. In no way null and "" 
(which is _not_ representing the rootDSE - a very common misconception : 
A => B does not necessarily implies that B => A - ) are synonymous.

Talking about Apache DS LdapDN implementation, our internal data 
structure handling DNs, the empty constructor is used when you need to 
manipulate DNs by adding RDNs to it. And if you have :

LdapDN dn = new LdapDN();
System.out.println( dn ) ;

you will obtain just a empty line (ie, ""), not 'null'.
>> On the other
>> hand, the existence of this constructor makes as much sense to me as the
>> redundant addRDN() and addRDNToFront() methods (ie. none at all). I
>> suppose *somebody* may want to build a DN instance iteratively, but I
>> would consider it easier to do so concatenating strings for submission
>> to the more relevant constructor with argument.
DN are not Strings, DNs are structures which have a String 
representation (so the RFC 4514). Inside a LDAP server, it's much better 
to hold DNs into such a structure instead of manipulation Strings. A 
simple exemple : how do you compare those two DNs and how can you tell 
if they are equal ? :

dn1: dc=example, dc=com
dn2: |0.9.2342.19200300.100.1.25=Example, ||0.9.2342.19200300.100.1.25=COM

As String, you bet they are different, but they are just representing 
the very same element.
Hope it helps.

cordialement, regards,
Emmanuel L├ęcharny

View raw message