Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This functionsearches search the LDAP directory and returns a requested set of attributes for each entry matched.

Syntax

ULONG ldap_search_ext(
  LDAP* 
ld,
  UNICODE PTCHAR 
base,
  ULONG 
scope,
  UNICODE PTCHAR 
filter,
  UNICODE PTCHAR 
attrs[],
  ULONG 
attrsonly,
  LDAPControl** 
ServerControls,
  LDAPControl** 
ClientControls,
  ULONG 
TimeLimit,
  ULONG 
SizeLimit,
  ULONG* 
MessageNumber
);

Parameters

ld

[in] Session handle.

base

[in] Distinguished name of the entry at which to start the search.

scope

[in] Specifies a value to indicate the scope of the search. The following table shows the possible values.

Value Description

LDAP_SCOPE_BASE

Searches the base entry only.

LDAP_SCOPE_ONELEVEL

Searches all entries in the first level below the base entry, excluding the base entry.

LDAP_SCOPE_SUBTREE

Searches the base entry and all entries in the tree below the base.

filter

[in] Pointer to a null-terminated string that specifies the search filter.

attrs

[in] Null-terminated array of strings indicating which attributes to return for each matching entry. Pass NULL to retrieve all available attributes.

attrsonly

[in] Boolean value that should be zero if both attribute types and values are to be returned and nonzero if only types are wanted.

ServerControls

[in] List of LDAP server controls.

ClientControls

[in] List of client controls.

TimeLimit

[in] Specifies both the local search time-out value in seconds and the operation time limit that is sent to the server within the search request.

SizeLimit

[in] Limit on the number of entries to return from the search. A value of zero means there is no limit.

MessageNumber

[out] Message identifier of the request.

Return Value

If this function succeeds, the return value is LDAP_SUCCESS.

If this function fails, it returns an error code. See the LDAP_RETCODEenumeration for a list of possible return values.

Remarks

This function initiates an asynchronous search operation. The parameters and effects of this function include 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.

You can use the ldap_set_optionfunction with the ldsession handle to set the LDAP_OPT_DEREF option that determines how the search is performed. Two other session options, LDAP_OPT_SIZELIMIT and LDAP_OPT_TIMELIMIT, are ignored in favor of the SizeLimitand TimeLimitparameters in this function.

If the operation succeeds, ldap_search_extpasses the message identifier to the caller as a parameter when the operation returns successfully. Call ldap_resultwith the message identifier 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 the size set to the desired page size and the cookie set to the zero-length string. The page size specified may be greater than zero and less than the SizeLimitvalue specified in the search request.

If the page size is greater than or equal to the SizeLimitvalue option, 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.

In a multithreading environment, calls to ldap_search_extare thread-safe.

Requirements

Header winldap.h
Library wldap32.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also