When using JNDI with LDAP, how can I get the DN (Distinguished Name) from a DirContext?

Fdo J. Rendón Quiles

If you get the DN for a DirContext you have to use the method, getNameInNamespace(). This method retrieves the full name of this context within its own namespace. For example:

DirContext ctx;
// ...