21.9 LDAP_SEARCH_FILTER Function

The LDAP_SEARCH_FILTER function escapes reserved characters in an LDAP search filter, according to RFC 4515. The RFC describes *()\/ as reserved characters (see p_reserved_chars). These, 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.

Syntax

APEX_ESCAPE.LDAP_SEARCH_FILTER (
    p_string              IN VARCHAR2,
    p_reserved_chars      IN VARCHAR2 DEFAULT c_ldap_search_reserved_chars,
    p_escape_non_ascii    IN BOOLEAN  DEFAULT TRUE )
RETURN VARCHAR2;

Parameters

Table 21-10 LDAP_SEARCH_FILTER 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 \xx where xx is the character's ASCII hexadecimal code.
p_escape_non_ascii If TRUE, characters above ascii 127 in p_string are escaped with \xx where xx is the character's ASCII hexadecimal code. This is supported by RFCs 4514, but may cause errors with older LDAP servers and Microsoft AD.

Example

This example escapes the text 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_search_filter(l_name);
    htp.p(l_name||' becomes '||l_escaped);
END;