ldap_search function
The ldap_search function searches the LDAP directory and returns a requested set of attributes for each matched entry.
Syntax
ULONG ldap_search( _In_ LDAP *ld, _In_ PCHAR base, _In_ ULONG scope, _In_ PCHAR filter, _In_ PCHAR attrs[], _In_ ULONG attrsonly );
Parameters
- ld [in]
-
A session handle.
- base [in]
-
A pointer to a null-terminated string that contains the distinguished name of the entry at which to start the search.
- scope [in]
-
A data type that specifies one of the following values to indicate the search scope.
- filter [in]
-
A pointer to a null-terminated string that specifies the search filter. For more information, see Search Filter Syntax.
- attrs [in]
-
A null-terminated array of null-terminated strings that indicate which attributes to return for each matching entry. Pass NULL to retrieve available attributes.
- attrsonly [in]
-
Boolean value that should be zero if both attribute types and values are to be returned, nonzero if only types are required.
Return value
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.
Remarks
The ldap_search function initiates an asynchronous search operation.
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.
To have the function return the results directly, use the synchronous routine ldap_search_s. Use ldap_search_ext or ldap_search_ext_s to implement 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.
Requirements
|
Minimum supported client |
Windows Vista |
|---|---|
|
Minimum supported server |
Windows Server 2008 |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names |
ldap_searchW (Unicode) and ldap_searchA (ANSI) |
See also
- Functions
- LDAP
- ldap_abandon
- ldap_bind
- ldap_result
- ldap_search_ext
- ldap_search_ext_s
- ldap_search_s
- ldap_simple_bind