public static LdapName escapeForJNDI(Rdn... rdn)
    {
        // Create a clone, to prevent changes to ordering of elements to affect the original array.
        final Rdn[] copy = Arrays.copyOf(rdn, rdn.length);
        final List<Rdn> rdns = Arrays.asList(copy);
        Collections.reverse(rdns);

        // LdapName is a JNDI name that will apply all relevant escaping.
        return new LdapName(rdns);
    }
Returns a JNDI Name for an array of RDNs that is suitable to use to
access LDAP through JNDI.

This method applies JDNI-suitable escaping to each RDN

<blockquote>When using the JNDI to access an LDAP service, you should be
aware that the forward slash character ("/") in a string name has special
meaning to the JNDI. If the LDAP entry's name contains this character,
then you need to escape it (using the backslash character ("\")).
For example, an LDAP entry with the name "cn=O/R" must be presented as
the string "cn=O\\/R" to the JNDI context methods.</blockquote>

@param rdn The names to escape (cannot be null).
@return A JNDI name representation of the values (never null).
@see <a href="https://docs.oracle.com/javase/tutorial/jndi/ldap/jndi.html">JNDI</a>
@see <a href="https://docs.oracle.com/javase/jndi/tutorial/beyond/names/syntax.html">Handling Special Characters</a>
xmppserver/src/main/java/org/jivesoftware/openfire/ldap/LdapManager.java