Sets the value of session-wide parameters.
#include <ldap.h> int ldap_set_option ( LDAP *ld, int option, LDAP_CONST void *invalue);
(IN) Points to the session handle. If this is NULL, the function accesses the global defaults.
(IN) Specifies the name of the option which is being set (see Section 6.10, Session Preference Options).
(IN) Points to the value to which the specified option is set.
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 );