Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1394 → Rev 1395

/web/acc/admin/ldap.php
46,6 → 46,8
$l_ldap_test_connection_failed = "Impossible de se connecter au serveur LDAP.";
$l_ldap_test_bind_ok = "Connexion LDAP réussie...";
$l_ldap_test_bind_failed = "Echec d'authentification sur le serveur LDAP...Vérifiez votre configuration ldap...";
$l_ldap_test_dn_ok = "DN semble bon";
$l_ldap_test_dn_failed = "DN semble mauvais";
} else {
$l_file = "File ";
$l_not_found = " not found";
74,6 → 76,8
$l_ldap_test_connection_failed = "LDAP connexion failed...";
$l_ldap_test_bind_ok = "LDAP connexion success...";
$l_ldap_test_bind_failed = "LDAP authentication failed...Check your ldap setup...";
$l_ldap_test_dn_ok = "DN seems to be right";
$l_ldap_test_dn_failed = "DN seems to be wrong";
}
/********************************************************
* TEST DES FICHIERS DE CONFIGURATION *
153,7 → 157,7
$ldap_filter = $ldap->uid; // others options only in alcasar 3.x ($ldap->filter)
$ldap_base_filter = $ldap->base_filter;
 
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_port = "389"){
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_basedn, $f_ldap_filter, $f_ldap_port = "389"){
// Test du serveur
if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
// no network connection
167,16 → 171,40
$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
if ($ldapbind) {
// LDAP Bind success
//try search
$query = $f_ldap_filter."=*";
if($search = ldap_search($ldapconn, $f_ldap_basedn, $query)){
ldap_unbind($ldapconn);
return 2;
} else {
ldap_unbind($ldapconn);
return 1;
}
} else {
// Test LDAP Version 3
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
if ($ldapbind) {
// LDAP Bind success
//try search
$query = $f_ldap_filter."=*";
if($search = ldap_search($ldapconn, $f_ldap_basedn, $query)){
ldap_unbind($ldapconn);
return 2;
} else {
ldap_unbind($ldapconn);
return 1;
} else {
// LDAP Bind failed
return 0;
}
} else {
// LDAP Bind failed
return 0;
}
}
} else {
// LDAP connection failed
return -2;
}
 
}
}
 
231,7 → 259,8
}
if (($ldap_on == "ldap") && (function_exists('ldap_connect'))){
echo "<div align='center'><br>";
switch(ldap_test($new_ldap_server, $ldap_identity, $ldap_password)){
 
switch(ldap_test($new_ldap_server, $ldap_identity, $ldap_password, $ldap_basedn, $ldap_filter)){
case -2:
echo "<font color='red'>".$l_ldap_test_connection_failed."</font>";
break;
243,6 → 272,13
break;
case 1:
echo "<font color='green'>".$l_ldap_test_bind_ok."</font>";
echo "<br>";
echo "<font color='red'>".$l_ldap_test_dn_failed."</font>";
break;
case 2:
echo "<font color='green'>".$l_ldap_test_bind_ok."</font>";
echo "<br>";
echo "<font color='green'>".$l_ldap_test_dn_ok."</font>";
break;
default:
echo "LDAP error";