40.7 SEARCH Function
The SEARCH
function searches the LDAP repository and returns an object table of (dn, name, val) that can be used in table queries.
Syntax
APEX_LDAP.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,
p_credential_static_id IN VARCHAR2 DEFAULT NULL )
RETURN apex_t_ldap_attributes pipelined;
Parameters
Parameter | Descriptions |
---|---|
p_username |
Username to connect as (can be null for anonymous binds).
|
p_pass |
Password of p_username (can be null for anonymous binds).
|
p_auth_base |
Authentication base dn for p_username (can be null for anonymous binds).
|
p_host |
LDAP server hostname. |
p_port |
LDAP server port (default 389 ).
|
p_use_ssl |
Y if a SSL connection is required (default N ).
|
p_search_base |
dn base for the search. |
p_search_filter |
LDAP search filter expression. |
p_scope |
Search scope (default descends into sub-trees). |
p_timeout_sec |
Timeout for the search (default 3 seconds).
|
p_attribute_names |
Comma-separated list of return attribute names. |
p_credential_static_id |
The credential static ID (can be null for anonymous or username/pass binds). If it is not null and the credential could not be found, then raises the error no_data_found .
|
Example 1
SELECT val group_dns
FROM table(apex_ldap.search (
p_host => 'ldap.example.com',
p_port => '636',
p_use_ssl => 'A',
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_port => '636',
p_use_ssl => 'A',
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 ))
Parent topic: APEX_LDAP