ldap_bind

(PHP 3, PHP 4 )

ldap_bind -- Bindung zu einem LDAP Verzeichnis

Beschreibung

bool ldap_bind ( resource Verbindungs-Kennung [, string bind_rdn [, string bind_kennwort]])

Bindung für ein LDAP Verzeichnis mit angegebenem RDN und Kennwort. Gibt bei Erfolg TRUE zurück, im Fehlerfall FALSE.

Die ldap_bind() Funktion führt eine bind Operation auf einem Verzeichnis aus. Die Parameter bind_rdn und bind_kennwort sind optional, wenn diese fehlen wird ein anonymes bind versucht.

Beispiel 1. Verwenden von LDAP Bind

<?php

// verwenden von ldap bind
$ldaprdn  = 'uname';     // ldap rdn oder dn
$ldappass = 'password';  // entsprechendes password

// verbinden zum ldap server
$ldapconn = ldap_connect("ldap.example.com")
    or die("Keine Verbindung zum LDAP server möglich.");

if ($ldapconn) {

    // binden zum ldap server
    $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);

    // Bindung überpfrüfen
    if ($ldapbind) {
        echo "LDAP bind erfolgreich...";
    } else {
        echo "LDAP bind fehlgeschlagen...";
    }
        
}

?>

Beispiel 2. Anonymes LDAP Bind

<?php

//verwenden von anonymen ldap bind

// verbinden zum ldap server
$ldapconn = ldap_connect("ldap.example.com")
    or die("Could not connect to LDAP server.");

if ($ldapconn) {

    // anonymes binding
    $ldapbind = ldap_bind($ldapconn);

    if ($ldapbind) {
        echo "anonymes LDAP bind erfolgreich...";
    } else {
        echo "anonymes LDAP bind fehlgeschlagen...";
    }
 
}
    
?>