24.19 LDAP_DN Function

The LDAP_DN function escapes reserved characters in an LDAP distinguished name, according to RFC 4514. The RFC describes "+,;<=>\ as reserved characters (see p_reserved_chars). These are escaped by a backslash, for example, " becomes \". Non-printable characters, ASCII 0 - 31, and ones with a code > 127 (see p_escape_non_ascii) are escaped as \xx, where xx is the hexadecimal character code. The space character at the beginning or end of the string and a # at the beginning is also escaped with a backslash.


    p_string            IN VARCHAR2,
    p_reserved_chars    IN VARCHAR2 DEFAULT c_ldap_dn_reserved_chars,
    p_escaped_non_ascii IN BOOLEAN  DEFAULT TRUE )


Table 24-21 LDAP_DN Parameters

Parameter Description
p_string The text string that is escaped.
p_reserved_chars A list of characters that when found in p_string is escaped with a backslash.
p_escaped_non_ascii If TRUE, characters above ASCII 127 in p_string are escaped with a backslash. This is supported by RFCs 4514 and 2253, but may cause errors with older LDAP servers and Microsoft AD.


This example escapes characters in l_name and places the result in l_escaped.

    l_name varchar2(4000) := 'Joe+User';
    l_escaped varchar2(4000);
    l_escaped := apex_escape.ldap_dn(l_name);
    htp.p(l_name||' becomes '||l_escaped);