ldap_set_option

Sets the value of session-wide parameters.

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_set_option (
     LDAP               *ld,
     int                 option,
     LDAP_CONST void    *invalue);
  
  

Parameters

ld

(IN) Points to the session handle. If this is NULL, the function accesses the global defaults.

option

(IN) Specifies the name of the option which is being set (see Section 6.10, Session Preference Options).

invalue

(IN) Points to the value to which the specified option is set.

Return Values

0x00

LDAP_SUCCESS

-1

Failure

Remarks

The ldap_init function returns the value for the ld parameter. If you use the ldap_set_option function before calling ldap_init and use NULL for the ld parameter, the values are set globally and copied to all LDAP session handles you create afterwards. If the ldap_set_option function is called after the ldap_init function, one of the following occurs:

  • If the ld parameter is NULL, the values are set globally but do not affect the values in currently created LDAP session handles.

  • If the ld parameter is set to the value returned by the ldap_init function, the values are set for only that LDAP session handle.

The following examples illustrate how to globally set two of the options.

  /* Don’t chase referrals */
  rc = ldap_set_option( NULL, LDAP_OPT_REFERRALS, LDAP_OPT_OFF );  
  
  /* Set LDAP version 3 */
  int version = LDAP_VERSION3;
  rc = ldap_set_option( NULL, LDAP_OPT_PROTOCOL_VERSION, &version );  
  

See Also

ldap_get_option