(PHP 7 >= 7.2.0, PHP 8)
ldap_exop — Performs an extended operation
$ldap,$request_oid,$request_data = null,$controls = null,&$response_data = ?,&$response_oid = ?
Performs an extended operation on the specified ldap with
request_oid the OID of the operation and
request_data the data.
Using more than 4 parameters has been deprecated, use ldap_exop_sync() instead.
ldaprequest_oidLDAP_EXOP_*
constants,
or a string with the OID of the operation.
request_dataLDAP_EXOP_WHO_AM_I, may also need to be BER encoded.
controlsresponse_dataresponse_oid
When used with response_data, returns true on success or false on error.
When used without response_data, returns a result identifier or false on error.
| 版本 | 说明 |
|---|---|
| 8.4.0 | Using more than 4 parameters has been deprecated, use ldap_exop_sync() instead. |
| 8.1.0 |
现在 ldap 参数接受 LDAP\Connection
实例,之前接受有效的 ldap link resource。
|
| 7.3.0 |
Support for controls added
|
示例 #1 Whoami extended operation
<?php
$ds = ldap_connect("localhost"); // assuming the LDAP server is on this host
if ($ds) {
// bind with appropriate dn to give update access
$bind = ldap_bind($ds, "cn=root, o=My Company, c=US", "secret");
if (!$bind) {
echo "Unable to bind to LDAP server";
exit;
}
// Call WHOAMI EXOP
$r = ldap_exop($ds, LDAP_EXOP_WHO_AM_I);
// Parse the result object
ldap_parse_exop($ds, $r, $retdata);
// Output: string(31) "dn:cn=root, o=My Company, c=US"
var_dump($retdata);
// Same thing using $response_data parameter
$success = ldap_exop($ds, LDAP_EXOP_WHO_AM_I, NULL, NULL, $retdata, $retoid);
if ($success) {
var_dump($retdata);
}
ldap_close($ds);
} else {
echo "Unable to connect to LDAP server";
}
?>