<?php
$ds = ldap_connect("localhost"); // Es wird angenommen, dass der LDAP-Server auf diesem Host läuft
if ($ds) {
// Mit einem geeigneten DN binden, das Schreibrechte besitzt
$bind = ldap_bind($ds, "cn=root, o=My Company, c=US", "secret");
if (!$bind) {
echo "Unable to bind to LDAP server";
exit;
}
// WHOAMI-EXOP aufrufen
$r = ldap_exop($ds, LDAP_EXOP_WHO_AM_I);
// Das Ergebnisobjekt auswerten
ldap_parse_exop($ds, $r, $retdata);
// Ausgabe: string(31) "dn:cn=root, o=My Company, c=US"
var_dump($retdata);
// Dasselbe mit dem $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";
}
?>