Platform SDK: Active Directory, ADSI, and Directory Services |
The ldap_search_ext function searches search the LDAP directory and returns a requested set of attributes for each entry matched.
ULONG ldap_search_ext( LDAP* ld, PCHAR base, ULONG scope, PCHAR filter, PCHAR attrs[], ULONG attrsonly, PLDAPControl* ServerControls, PLDAPControl* ClientControls, ULONG TimeLimit, ULONG SizeLimit, ULONG* MessageNumber );
If the function succeeds, the return value is LDAP_SUCCESS.
If the function fails, it returns an error code. See Return Values for more information.
The ldap_search_ext function initiates an asynchronous search operation. The parameters and effects of ldap_search_ext subsume those of ldap_search. The extended routine includes additional parameters to support client and server controls and thread safety, and to specify size and time limits for each search operation.
The scope of the search is determined by the value of the scope parameter, as follows:
Scope Constant | 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. |
The LDAP_OPT_DEREF option defined in Session Options also determines how the search is performed. Two other session options, LDAP_OPT_SIZELIMIT and LDAP_OPT_TIMELIMIT, are ignored in favor of the SizeLimit and TimeLimit parameters in this function.
If the operation succeeds, ldap_search_ext passes the message ID to the caller as a parameter when the operation returns successfully. Call ldap_result with the message ID to get the result of the operation.
An LDAP client application that needs to control the rate at which results are returned may specify the search request to provide a paged results control with size set to the desired page size and cookie set to the zero-length string. The page size specified may be greater than zero and less than the SizeLimit value specified in the search request.
If the page size is greater than or equal to the SizeLimit value option described in Session Options, the server should ignore the control because the request can be satisfied in a single page. If the server does not support this control, the server must return an error of unsupported Critical Extension if the client requested it as critical, otherwise the server should ignore the control. The remainder of this section assumes the server does not ignore the client's paged results control.
The client sends the server a search request with the simple paged results control, along with an empty previous enumeration key (also known as a "cookie") and the initial page size. The server then returns the number of entries specified by the page size and also returns a cookie issued on the next client request to get the next page of results. The client then issues a search, with the cookie included, (optionally resetting the page size). The server then responds by returning the results, up to the specified number of entries. If you prefer to have the function return the results directly, use the synchronous routine ldap_search_ext_s.
Multithreading: Calls to ldap_search_ext are thread-safe.
Notifications are asynchronous operations. When modifications occur, the server will return search entry responses to the client, which contain the objects that have changed, using the same LDAP message ID as the original notification request.
You can register up to five notification requests on a single LDAP connection. You must have a dedicated thread that waits for the notifications and processes them as quickly as possible. When you call the ldap_search_ext function to register a notification request, the function returns a message identifier that identifies that request. You then use the ldap_result function to wait for change notifications. When a change occurs, the server sends you an LDAP message containing the message identifier for the notification request that generated the notification. This causes the ldap_result function to return with search results that identify the object that changed.
For more information on Active Directory Change Notifications, see Change Notifications in Active Directory.
Windows NT/2000: Requires Windows NT 4.0 SP4 or later.
Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
Header: Declared in Winldap.h.
Library: Use Wldap32.lib.
Unicode: Declared as Unicode and ANSI prototypes.
Change Notifications in Active Directory, Functions, ldap_result ldap_search, ldap_search_ext_s, Session Options