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.

Syntax

APEX_ESCAPE.LDAP_DN (
    p_string IN VARCHAR2,
    p_reserved_chars IN VARCHAR2 DEFAULT c_ldap_dn_reserved_chars,
    p_escaped_non_ascii IN BOOLEAN DEFAULT TRUE )
    return VARCHAR2;

Parameters

Table 12-9 LDAP_DN Function 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.

Example

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

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