24.7 SEARCH Function

The SEARCH function searches the LDAP repository. The result is an object table of (dn, name, val) that can be used in table queries.

Syntax

function search (
   	    p_username          IN VARCHAR2 DEFAULT NULL,
   	    p_pass              IN VARCHAR2 DEFAULT NULL,
   	    p_auth_base         IN VARCHAR2 DEFAULT NULL,
   	    p_host              IN VARCHAR2,
   	    p_port              IN NUMBER DEFAULT 389,
   	    p_use_ssl           IN VARCHAR2 DEFAULT 'N',
   	    p_search_base       IN VARCHAR2,
   	    p_search_filter     IN VARCHAR2,
   	    p_scope             IN BINARY_INTEGER DEFAULT SYS.DBMS_LDAP.SCOPE_SUBTREE,
   	    p_timeout_sec       IN BINARY_INTEGER DEFAULT 3,
   	    p_attribute_names   IN VARCHAR2 )
   	    RETURN APEX_T_LDAP_ATTRIBUTES PIPELINED;

Parameters

Table 24-7 Search Parameters

Parameter Descriptions

p_username

Login name of the user (can be NULL for anonymous binds).

p_pass

The password for p_username (can be NULL for anonymous binds)

p_auth_base

The authentication base dn for p_username (for example, dc=users,dc=my,dc=org). Can be NULL for anonymous binds.

p_host

The LDAP server host name.

p_port

The LDAP server port number.

p_use_ssl

Set to 'Y' to use SSL in bind to LDAP server. Set to 'A' to use SSL with one way authentication (requires LDAP server certificate configured in an Oracle wallet). Set to 'N' to not use SSL (default).

p_search_base

dn base for the search.

p_search_filter

LDAP search filter expression.

p_scope

Search scope (default descends into subtrees).

p_timeout_sec

Timeout for the search (default is 3 seconds)

p_attribute_names

Comma separated list of return attribute names

Example 1

SELECT val group_dns
  FROM table(apex_ldap.search (
           p_host            => 'ldap.example.com',
           p_search_base     => 'dc=example,dc=com',
           p_search_filter   => 'uid='||apex_escape.ldap_search_filter(:APP_USER),
           p_attribute_names => 'memberof' ));

Example 2

SELECT dn, mail, dispname, phone
  from ( select dn, name, val
           from table(apex_ldap.search (
                          p_host            => 'ldap.example.com',
                          p_search_base     => 'dc=example,dc=com',
                          p_search_filter   => '&(objectClass=person)(ou=Test)',
                          p_attribute_names => 'mail,displayname,telephonenumber' )))
  pivot (min(val) for name in ( 'mail'            mail,
                                'displayname'     dispname,
                                'telephonenumber' phone ))