Directory Services |
The ldap_search function searches search the LDAP directory and returns a requested set of attributes for each entry matched.
ULONG ldap_search( LDAP* ld, PCHAR base, ULONG scope, PCHAR filter, PCHAR attrs[], ULONG attrsonly );
Value | Meaning |
---|---|
LDAP_SCOPE_BASE | Search the base entry only. |
LDAP_SCOPE_ONELEVEL | Search all entries in the first level below the base entry, excluding the base entry. |
LDAP_SCOPE_SUBTREE | Search the base entry and all entries in the tree below the base. |
If the function succeeds, it returns the message ID of the search operation.
If the function fails, it returns –1 and sets the session error parameters in the LDAP data structure.
The ldap_search function initiates an asynchronous search operation.
You can use the ldap_set_option function with the ld session handle to set the LDAP_OPT_SIZELIMIT, LDAP_OPT_TIMELIMIT, and LDAP_OPT_DEREF options that determine how the search is performed. For more information, see Session Options.
As an asynchronous function, ldap_search returns a message ID for the operation. Call ldap_result with the message ID to get the result of the operation. To cancel an asynchronous search operation before it has completed, call ldap_abandon.
If you prefer to have the function return the results directly, use the synchronous routine ldap_search_s. Use ldap_search_ext or ldap_search_ext_s if you need support for LDAP 3 server and client controls.
Multithreading: Calls to ldap_search are thread-safe, provided that LdapGetLastError is used to retrieve the actual session error code when the function call returns the -1 failure code.
Note When connecting to an LDAP 2 server, the application must perform a bind operation (by calling one of the ldap_bind or ldap_simple_bind routines) before attempting other operations.
Client: Included in Windows XP and
Windows 2000 Professional.
Server: Included in Windows Server 2003 and
Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension
on Windows NT 4.0 SP6a and Windows 95/98/Me.
Unicode: Implemented as Unicode and ANSI versions on all
platforms.
Header: Declared in Winldap.h.
Library: Use Wldap32.lib.
Functions, LDAP, ldap_abandon, ldap_bind, ldap_result, ldap_search_ext, ldap_search_ext_s, ldap_search_s, ldap_simple_bind