Platform SDK: Active Directory, ADSI, and Directory Services

ldap_search_st

The ldap_search_st function searches the LDAP directory and returns a requested set of attributes for each entry matched. The function is identical to ldap_search_s, except that it takes an additional parameter that specifies a local time-out for the search.

ULONG ldap_search_st(
  LDAP* ld,
  PCHAR base,
  ULONG scope,
  PCHAR filter,
  PCHAR attrs[],
  ULONG attrsonly,
  struct l_timeval* timeout,
  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 that indicate 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.
timeout
[in] The local search time-out value.
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_st function initiates a synchronous search operation. The scope of the search is determined by the value of the scope parameter, as shown in the following table.

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.

Two options in the LDAP structure also determine how the search is performed: LDAP_OPT_SIZELIMIT, and LDAP_OPT_DEREF. The timeout parameter in ldap_search_st overrides the LDAP_OPT_TIMELIMIT in the Session Options.

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

Multithreading: Calls to ldap_search_st 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, ldap_search, ldap_search_s, ldap_search_ext, Session Options, Return Values