Previous | Next | Trail Map | Tips for LDAP Users | Frequently Asked Questions

Names

Why do I get an empty string as a name in my SearchResult(in the API reference documentation)?

getName()(in the API reference documentation) always returns a name relative to the target context of the search. So, if the target context satisfies the search filter, then the name returned will be "" (the empty name) because that is the name relative to the target context. See the Searches (in the Tips for LDAP Users trail) lesson for details.

Why do I get a URL string as a name in my SearchResult(in the API reference documentation)?

The LDAP entry was retrieved by following either an alias or a referral, so its name is a URL. See the Searches (in the Tips for LDAP Users trail) lesson for details.

Is the Name(in the API reference documentation) argument to the Context(in the API reference documentation) and DirContext(in the API reference documentation) methods a CompoundName(in the API reference documentation) or a CompositeName(in the API reference documentation)?

The string forms accept the string representation of a composite name. That is, using a string name is equivalent to calling new CompositeName(stringName) and passing the results to the Context/DirContext method. The Name argument can be any object that implements the Name interface. If it is an instance of CompositeName, then the name is treated as a composite name; otherwise, it is treated as a compound name.

Can I pass the name I got back from NameParser(in the API reference documentation) to Context(in the API reference documentation) methods?

This is related to the previous question. Yes, you can. NameParser.parse()(in the API reference documentation) returns a compound name that implements the Name interface. This name can be passed to the Context methods, which will interpret it as a compound name.

What's the relationship between the name I use for the Context.SECURITY_PRINCIPAL(in the API reference documentation) property and the directory?

You can think of the principal name as coming from a different namespace than the directory. See RFC 2829 and the Security (in the Tips for LDAP Users trail) lesson for details on LDAP authentication mechanisms. Sun's LDAP service provider accepts a string principal name, which it passes directly to the LDAP server. Some LDAP servers accept DNs, whereas others support the schemes proposed by RFC 2829.

Why are there strange quotation marks and escapes in the names that I read from the directory?

Sun's LDAP name parser is conservative with respect to quoting rules, but it nevertheless produces "correct" names. Also, remember that the names of entries returned by NamingEnumerations(in the API reference documentation) are composite names that can be passed back to the Context and DirContext methods. So, if the name contains a character that conflicts with the composite name syntax (such as the forward slash character "/"), then the LDAP provider will provide an encoding to ensure that the slash character will be treated as part of the LDAP name rather than as a composite name separator.

How do I get an LDAP entry's full DN?

You can use Context.getNameInNamespace()(in the API reference documentation).


Previous | Next | Trail Map | Tips for LDAP Users | Frequently Asked Questions