php8.5
Home/ Manual/ ldap / functions/ ldap_get_option

ldap_get_option

PHP function Edit on GitHub ✎

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

Get the current value for given option

Description

ldap_get_option(LDAP\Connection|null $ldap, int $option, array|string|int $value = null): bool

Sets value to the value of the specified option.

Parameters

ldap

Either an LDAP\Connection instance, returned by ldap_connect(), to get the option for that connection, or null to get the global option.

option

The parameter option can be one of:

OptionTypesince
LDAP_OPT_DEREFint
LDAP_OPT_SIZELIMITint
LDAP_OPT_TIMELIMITint
LDAP_OPT_NETWORK_TIMEOUTint
LDAP_OPT_PROTOCOL_VERSIONint
LDAP_OPT_ERROR_NUMBERint
LDAP_OPT_DIAGNOSTIC_MESSAGEstring
LDAP_OPT_REFERRALSint
LDAP_OPT_RESTARTint
LDAP_OPT_HOST_NAMEstring
LDAP_OPT_ERROR_STRINGstring
LDAP_OPT_MATCHED_DNstring
LDAP_OPT_SERVER_CONTROLSarray
LDAP_OPT_CLIENT_CONTROLSarray
LDAP_OPT_X_KEEPALIVE_IDLEint7.1
LDAP_OPT_X_KEEPALIVE_PROBESint7.1
LDAP_OPT_X_KEEPALIVE_INTERVALint7.1
LDAP_OPT_X_TLS_CACERTDIRstring7.1
LDAP_OPT_X_TLS_CACERTFILEstring7.1
LDAP_OPT_X_TLS_CERTFILEstring7.1
LDAP_OPT_X_TLS_CIPHER_SUITEstring7.1
LDAP_OPT_X_TLS_CRLCHECKint7.1
LDAP_OPT_X_TLS_CRL_NONEint7.1
LDAP_OPT_X_TLS_CRL_PEERint7.1
LDAP_OPT_X_TLS_CRL_ALLint7.1
LDAP_OPT_X_TLS_CRLFILEstring7.1
LDAP_OPT_X_TLS_DHFILEstring7.1
LDAP_OPT_X_TLS_KEYFILEstring7.1
LDAP_OPT_X_TLS_PACKAGEstring7.1
LDAP_OPT_X_TLS_PROTOCOL_MINint7.1
LDAP_OPT_X_TLS_PROTOCOL_MAXint8.4
LDAP_OPT_X_TLS_RANDOM_FILEstring7.1
LDAP_OPT_X_TLS_REQUIRE_CERTint
value

This will be set to the option value.

Return Values

Success

Changelog

VersionDescription
8.5.0ldap is now nullable. A ValueError is now thrown when passing an invalid option.

Examples

Check protocol version

php
<?php
// $ds is a valid LDAP\Connection instance for a directory server
if (ldap_get_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version)) {
    echo "Using protocol version $version\n";
} else {
    echo "Unable to determine protocol version\n";
}
?>

Notes

Note

This function is only available when using OpenLDAP 2.x.x OR Netscape Directory SDK x.x.

See Also

Source: reference/ldap/functions/ldap-get-option.xml · from the official PHP manual (php/doc-en)