This commit is contained in:
Christian Paminger
2009-04-14 08:56:16 +00:00
parent 9a53fa7a12
commit c5000a00f8
+13 -12
View File
@@ -34,6 +34,7 @@ function get_uid()
return strtolower(trim($_SERVER['REMOTE_USER']));
// fuer Testzwecke
//return 'oesi';
//return 'pam';
}
function crlf()
@@ -343,45 +344,45 @@ function checkalias($alias)
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)
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)
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)
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)
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)
if (($link_id = @ldap_bind($connect, $user_dn, $password)) == false)
{
return false;
}
return true;
@ldap_close($connect);
}