Platform SDK: Active Directory, ADSI, and Directory Services

ldap_search_ext_s

The ldap_search_ext_s function searches the LDAP directory and returns a requested set of attributes for each entry matched.

ULONG ldap_search_ext_s(
  LDAP* ld,
  PCHAR base,
  ULONG scope,
  PCHAR filter,
  PCHAR attrs[],
  ULONG attrsonly,
  PLDAPControl* ServerControls,
  PLDAPControl* ClientControls,
  struct l_timeval* timeout,
  ULONG SizeLimit,
  LDAPMessage** res
);

Parameters

ld
[in] The session handle.
base
[in] The distinguished name of the entry at which to start the search.
scope
[in] The scope of the search. See Remarks for a description.
filter
[in] The search filter.
attrs
[in] A null-terminated array of strings indicating which attributes to return for each matching entry. Pass NULL to retrieve all available attributes.
attrsonly
[in] A boolean value that should be zero if both attribute types and values are to be returned, nonzero if only types are wanted.
ServerControls
[in] A list of LDAP server controls.
ClientControls
[in] A list of client controls.
timeout
[in] Specifies both the local search time-out value and the operation time limit that is sent to the server within the search request.
SizeLimit
[in] A limit on the number of entries to return from the search. A value of zero means no limit.
res
[out] Contains the results of the search upon completion of the call.

Return Values

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.

Remarks

The ldap_search_ext_s function initiates a synchronous search operation. The parameters and effects of ldap_search_ext_s subsume those of ldap_search_s. The extended routine includes additional parameters to support client and server controls, 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 in the Session Options also determines how the search is performed. Two other search options, LDAP_OPT_SIZELIMIT and LDAP_OPT_TIMELIMIT, are ignored in favor of the SizeLimit and TimeLimit option parameters in this function.

Upon completion of the search operation, ldap_search_ext_s returns to the caller. Use ldap_search_ext if you prefer to have the operation carried out asynchronously.

Multithreading: Calls to ldap_search_ext_s are thread-safe.

Requirements

  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.

See Also

Functions, ldap_search_ext, ldap_search_s, Return Values, Session Options