184,9 → 184,10 |
$l_ldap_password_text = "Laissez vide pour un accès invité. Sinon, indiquez le mot de passe de connexion. Requis pour les serveurs possédant un Active Directory."; |
$l_ldap_submit = "Enregistrer"; |
$l_ldap_reset = "Annuler"; |
$l_ldap_test_ok = "Connexion LDAP réussie..."; |
$l_ldap_test_hs = "Connexion LDAP échouée..."; |
$l_ldap_test_hs2 = "Impossible de se connecter au serveur LDAP."; |
$l_ldap_test_network_failed = "Pas de connectivité réseau avec le serveur LDAP."; |
$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..."; |
} else { |
$l_ldap_title = "External authentication : LDAP"; |
$l_ldap_legend = "LDAP authentication"; |
207,14 → 208,16 |
$l_ldap_password_text = "Leave blank to use anonymous binding. Else fill in the password for the above user. Required for Active Directory Servers."; |
$l_ldap_submit = "Save"; |
$l_ldap_reset = "Reset"; |
$l_ldap_test_ok = "LDAP connexion success..."; |
$l_ldap_test_hs = "LDAP connexion failed..."; |
$l_ldap_test_hs2 = "LDAP server is not reachable."; |
$l_ldap_test_network_failed = "LDAP server is not reachable."; |
$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..."; |
} |
|
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_port = "389"){ |
// Test du serveur |
if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) { |
// no network connection |
return -1; |
} else { |
fclose($sock); |
224,16 → 227,17 |
if ($ldapconn) { |
$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password); |
if ($ldapbind) { |
$resp = 1; |
ldap_unbind($ldapconn); |
// LDAP Bind success |
ldap_unbind($ldapconn); |
return 1; |
} else { |
$resp = 0; |
// LDAP Bind failed |
return 0; |
} |
return $resp; |
} else { |
return -1; |
// LDAP connection failed |
return -2; |
} |
return 1; |
} |
} |
|
279,20 → 283,27 |
<fieldset> |
<legend> |
<?php |
echo $message; |
$tmp_host = explode("//",$ldap_server); //pour discriminer le host et le protocole |
//to do : pour la prochaine version, prise en compte du choix du port LDAP (configurable par le formulaire) |
echo $message; |
$pos = strpos($ldap_server, "//"); |
if ($pos!==false){ |
$new_ldap_server = explode("//",$ldap_server); //pour discriminer le host et le protocole dans la notation "ldap://192.168.182.10" ou "ldaps://monldap.monentreperise.com" |
} else { |
$new_ldap_server = $ldap_server. |
} |
if (($ldap == "ldap") && (function_exists('ldap_connect'))){ |
echo "<div align='center'><br>"; |
switch(ldap_test($tmp_host[1], $ldap_identity, $ldap_password)){ |
switch(ldap_test($new_ldap_server, $ldap_identity, $ldap_password)){ |
case -2: |
echo "<font color='red'>".$l_ldap_test_connection_failed."</font>"; |
break; |
case -1: |
echo "<font color='red'>".$l_ldap_test_hs2."</font>"; |
echo "<font color='red'>".$l_ldap_test_network_failed."</font>"; |
break; |
case 0: |
echo "<font color='red'>".$l_ldap_test_hs."</font>"; |
echo "<font color='red'>".$l_ldap_test_bind_failed."</font>"; |
break; |
case 1: |
echo "<font color='green'>".$l_ldap_test_ok."</font>"; |
echo "<font color='green'>".$l_ldap_test_bind_ok."</font>"; |
break; |
default: |
echo "LDAP error"; |