ldap_search_st

Synchronously searches the directory within a specified time limit.

LDAP Version:v2 or higher
Library:*ldapsdk.*
NDS Version:7.xx or higher
Platform:NLM, Windows (NT, 95, 98, 2000, XP, Vista 32-bit and 64-bit ), Linux (32-bit and 64-bit), Solaris, AIX, and HP-UX

Syntax

  #include <ldap.h>
  
  int ldap_search_st (
     LDAP             *ld,
     const char       *base,
     int               scope,
     const char       *filter,
     char            **attrs,
     int               attrsonly,
     struct timeval   *timeout,
     LDAPMessage     **res);
  
  

Parameters

ld

(IN) Points to the handle for the LDAP session.

base

(IN) Points to the distinguished name of the entry from which to start the search.

scope

(IN) Specifies the scope of the search and uses one of the following flags:

  • LDAP_SCOPE_BASE (0x00)—searches the entry specified by the base parameter.

  • LDAP_SCOPE_ONELEVEL (0x01)—searches the immediate subordinates of the entry specified by the base parameter.

  • LDAP_SCOPE_SUBTREE (0x02)—searches the entire subtree starting with the entry specified by the base parameter.

filter

(IN) Points to a search filter.

If NULL is passed, a default filter ("objectclass=*") is used, a filter which matches all entries in the directory. Using a NULL filter is not recommended for subtree searches on trees that potentially have hundreds of thousands of entries.

Simple filters take the form of strings: attribute name=attribute value. For more complex filters, see Using Search Filters.

attrs

(IN) Points to a NULL-terminated array of strings indicating which attributes to return with each matching entry. To return only entry names (and no attributes), set the first, and only string in the array, to LDAP_NO_ATTRS. To return all attributes, set this parameter to NULL.

For example, to return the cn, surname, and givenName attributes, declare attrs as: char* attrs[]={"cn", "surname", "givenName", NULL};

attrsonly

(IN) Specifies whether to return just attributes or attributes and values.

  • Zero—return both attributes and values

  • Non-zero—return only attributes

timeout

(IN) Points to a timeval structure that specifies the maximum time to wait for the results of a search to complete. The structure specifies both the time the server waits for the operation to complete as well as the time the local function waits for the server to respond. If the timeout parameter is set to NULL, the client timeout is infinite and the server uses the timeout value stored in the session handle option, LDAP_OPT_TIMELIMIT (whose default value is no timeout). For more information about possible values, see timeval.

res

(OUT) Returns a pointer to an array of result messages if the search succeeds or NULL if no results are returned.

Return Values

0x00

LDAP_SUCCESS

Non-zero

Failure. For a complete list, see LDAP Return Codes.

0x53

LDAP_ENCODING_ERROR

0x55

LDAP_TIMEOUT

0X57

LDAP_FILTER_ERROR

Remarks

The LDAP_OPT_DEREF option in the LDAP session handle affects how aliases are handled during the search.

  • The LDAP_DEREF_FINDING value means aliases are dereferenced when locating the base object but not during the search.

  • The LDAP_DEREF_SEARCHING value means aliases are dereferenced during the search but not when locating the base object of the search.

The results in the res parameter are opaque to the caller. You must call ldap_parse_result to read the results.

Remarks

To check the results of the operation, use the ldap_result or the ldap_result2error function.

Server timeouts and size limits for this function are set using the LDAP_OPT_TIMELIMIT and LDAP_OPT_SIZELIMIT options on the LDAP handle. Client timeouts are set using the timeout parameter. This function has no client size limit.

See Also

ldap_search, ldap_search_ext, ldap_search_ext_s, ldap_search_s