LDAP-Problem, ldap_bind ungültige dn-syntax

Ich weiß, dass meine Fehler dich etwas wirklich einfach aber ich habe versucht das problem zu finden, und ich sehe es nicht, vielleicht können Sie mir helfen....

Ich versuche eine Funktion erstellen mit php, also kann ich eine Verbindung zu LDAP und die gewünschten Informationen finden.

Mein php code ist folgender:

$ldapconfig['host'] = "127.0.0.1";
$ldapconfig['port'] = NULL;
$ldapconfig['basedn'] = "dc=example,dc=com";
$ldapconfig['binddn'] = "user";
$ldapconfig['bindpw'] = "password";


function ldap_authenticate($user, $pass) {
global $ldapconfig;
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); 
if ($user != "" && $pass != "") {
    $ds=ldap_connect($ldapconfig['host'],$ldapconfig['port']);
    if(!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
        return NULL;
    }
    ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
    ldap_bind( $ds, $ldapconfig['binddn'], $ldapconfig['bindpw']);
    $r = ldap_search( $ds, $ldapconfig['basedn'], 'sAMAccountName=' . $user);
    if ($r) {
        $result = ldap_get_entries( $ds, $r);
        if ($result[0]) {
            if (ldap_bind( $ds, $result[0]['dn'], $pass) ) {
                return $result[0]['mail'][0];
            }
        }
    }
}
return NULL;

Wenn ich versuche, führen Sie den code, es gibt mir den folgenden Fehler:
ldap_bind ungültige DN-syntax in Zeile xxxx
und diese Linie ist die folgende:

ldap_bind( $ds, $ldapconfig['binddn'], $ldapconfig['bindpw']);
InformationsquelleAutor Humberto | 2012-11-21
Schreibe einen Kommentar