This commit is contained in:
Andreas Österreicher
2008-04-07 15:29:55 +00:00
parent c04e60cbe2
commit 0e080b46c8
14 changed files with 737 additions and 553 deletions
+57
View File
@@ -319,4 +319,61 @@ function checkalias($alias)
return false;
}
// ****************************************************************
// * Prueft ob im LDAP ein User mit diesem Passwort existiert
// ****************************************************************
function checkldapuser($username,$password)
{
if($connect=@ldap_connect(LDAP_SERVER))
{
// bind to ldap connection
if(($bind=@ldap_bind($connect)) == false)
{
print "bind:__FAILED__<br>\n";
return false;
}
// search for user
if (($res_id = ldap_search( $connect, LDAP_BASE_DN, "uid=$username")) == false)
{
print "failure: search in LDAP-tree failed<br>";
return false;
}
if (ldap_count_entries($connect, $res_id) != 1)
{
print "failure: username $username found more than once<br>\n";
return false;
}
if (( $entry_id = ldap_first_entry($connect, $res_id))== false)
{
print "failur: entry of searchresult couln't be fetched<br>\n";
return false;
}
if (( $user_dn = ldap_get_dn($connect, $entry_id)) == false)
{
print "failure: user-dn coulnd't be fetched<br>\n";
return false;
}
/* Authentifizierung des User */
if (($link_id = @ldap_bind($connect, $user_dn, $password)) == false)
{
return false;
}
return true;
@ldap_close($connect);
}
else
{
// no conection to ldap server
echo "no connection to '$ldap_server'<br>\n";
}
@ldap_close($connect);
return(false);
}
?>