ldap_set_option
ldap_set_option
Set the value of the given option
bool **ldap_set_option** $ldap int $option $value
Sets the value of the specified option to be .
value
ldap
Either an instance, returned by
, to set the option for that connection,
or null to set the option globally.
LDAP\Connection``ldap_connect
option
The parameter can be one of:
`option`
and
require a list of
controls, this means that the value must be an array of controls. A
control consists of an identifying the control,
an optional , and an optional flag for
. In PHP a control is given by an
array containing an element with the key
and string value, and two optional elements. The optional
elements are key with string value
and key with boolean value.
defaults to
if not supplied. See
for details. See also the second example below.
`LDAP_OPT_SERVER_CONTROLS``LDAP_OPT_CLIENT_CONTROLS`*oid**value**criticality**oid**value**iscritical**iscritical**false*draft-ietf-ldapext-ldap-c-api-xx.txt
Opmerking: > All TLS options must be set globally before for ldaps connection or for the connection before .
ldap_connect``ldap_start_tls
value
The new value for the specified .
option
return.success
Voorbeeld: Set protocol version
<?php
// $ds is a valid LDAP\Connection instance for a directory server
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "Using LDAPv3";
} else {
echo "Failed to set protocol version to 3";
}
?>
Voorbeeld: Set server controls
<?php
// $ds is a valid LDAP\Connection instance for a directory server
// control with no value
$ctrl1 = array("oid" => "1.2.752.58.10.1", "iscritical" => true);
// iscritical defaults to FALSE
$ctrl2 = array("oid" => "1.2.752.58.1.10", "value" => "magic");
// try to set both controls
if (!ldap_set_option($ds, LDAP_OPT_SERVER_CONTROLS, array($ctrl1, $ctrl2))) {
echo "Failed to set server controls";
}
?>
Opmerking: > This function is only available when using OpenLDAP 2.x.x OR Netscape Directory SDK x.x.
ldap_get_option