Line 182... |
Line 182... |
182 |
$l_ldap_user_text = "Laissez vide pour utiliser un accès invité. Si renseigné, il se connectera au serveur LDAP en tant qu'un utilisateur spécifié, exemple: 'uid=Utilisateur,ou=MonUnité,o=MaCompagnie,c=FR'. Requis pour les serveurs possédant un Active Directory.";
|
182 |
$l_ldap_user_text = "Laissez vide pour utiliser un accès invité. Si renseigné, il se connectera au serveur LDAP en tant qu'un utilisateur spécifié, exemple: 'uid=Utilisateur,ou=MonUnité,o=MaCompagnie,c=FR'. Requis pour les serveurs possédant un Active Directory.";
|
183 |
$l_ldap_password_label = "Mot de passe LDAP:";
|
183 |
$l_ldap_password_label = "Mot de passe LDAP:";
|
184 |
$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.";
|
184 |
$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.";
|
185 |
$l_ldap_submit = "Enregistrer";
|
185 |
$l_ldap_submit = "Enregistrer";
|
186 |
$l_ldap_reset = "Annuler";
|
186 |
$l_ldap_reset = "Annuler";
|
187 |
$l_ldap_test_ok = "Connexion LDAP réussie...";
|
187 |
$l_ldap_test_network_failed = "Pas de connectivité réseau avec le serveur LDAP.";
|
- |
|
188 |
$l_ldap_test_connection_failed = "Impossible de se connecter au serveur LDAP.";
|
188 |
$l_ldap_test_hs = "Connexion LDAP échouée...";
|
189 |
$l_ldap_test_bind_ok = "Connexion LDAP réussie...";
|
189 |
$l_ldap_test_hs2 = "Impossible de se connecter au serveur LDAP.";
|
190 |
$l_ldap_test_bind_failed = "Echec d'authentification sur le serveur LDAP...Vérifiez votre configuration ldap...";
|
190 |
} else {
|
191 |
} else {
|
191 |
$l_ldap_title = "External authentication : LDAP";
|
192 |
$l_ldap_title = "External authentication : LDAP";
|
192 |
$l_ldap_legend = "LDAP authentication";
|
193 |
$l_ldap_legend = "LDAP authentication";
|
193 |
$l_ldap_auth_enable_label = "Use LDAP authentication :";
|
194 |
$l_ldap_auth_enable_label = "Use LDAP authentication :";
|
194 |
$l_ldap_YES = "YES";
|
195 |
$l_ldap_YES = "YES";
|
Line 205... |
Line 206... |
205 |
$l_ldap_user_text = "Leave blank to use anonymous binding. If filled uses the specified distinguished name on login attempts to find the correct user, e.g. 'uid=Username,ou=MyUnit,o=MyCompany,c=US'. Required for Active Directory Servers.";
|
206 |
$l_ldap_user_text = "Leave blank to use anonymous binding. If filled uses the specified distinguished name on login attempts to find the correct user, e.g. 'uid=Username,ou=MyUnit,o=MyCompany,c=US'. Required for Active Directory Servers.";
|
206 |
$l_ldap_password_label = "LDAP password:";
|
207 |
$l_ldap_password_label = "LDAP password:";
|
207 |
$l_ldap_password_text = "Leave blank to use anonymous binding. Else fill in the password for the above user. Required for Active Directory Servers.";
|
208 |
$l_ldap_password_text = "Leave blank to use anonymous binding. Else fill in the password for the above user. Required for Active Directory Servers.";
|
208 |
$l_ldap_submit = "Save";
|
209 |
$l_ldap_submit = "Save";
|
209 |
$l_ldap_reset = "Reset";
|
210 |
$l_ldap_reset = "Reset";
|
210 |
$l_ldap_test_ok = "LDAP connexion success...";
|
211 |
$l_ldap_test_network_failed = "LDAP server is not reachable.";
|
211 |
$l_ldap_test_hs = "LDAP connexion failed...";
|
212 |
$l_ldap_test_connection_failed = "LDAP connexion failed...";
|
212 |
$l_ldap_test_hs2 = "LDAP server is not reachable.";
|
213 |
$l_ldap_test_bind_ok = "LDAP connexion success...";
|
- |
|
214 |
$l_ldap_test_bind_failed = "LDAP authentication failed...Check your ldap setup...";
|
213 |
}
|
215 |
}
|
214 |
|
216 |
|
215 |
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_port = "389"){
|
217 |
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_port = "389"){
|
216 |
// Test du serveur
|
218 |
// Test du serveur
|
217 |
if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
|
219 |
if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
|
- |
|
220 |
// no network connection
|
218 |
return -1;
|
221 |
return -1;
|
219 |
} else {
|
222 |
} else {
|
220 |
fclose($sock);
|
223 |
fclose($sock);
|
221 |
// Connexion au serveur LDAP
|
224 |
// Connexion au serveur LDAP
|
222 |
$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
|
225 |
$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
|
223 |
ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
|
226 |
ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
|
224 |
if ($ldapconn) {
|
227 |
if ($ldapconn) {
|
225 |
$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
|
228 |
$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
|
226 |
if ($ldapbind) {
|
229 |
if ($ldapbind) {
|
227 |
$resp = 1;
|
230 |
// LDAP Bind success
|
228 |
ldap_unbind($ldapconn);
|
231 |
ldap_unbind($ldapconn);
|
- |
|
232 |
return 1;
|
229 |
} else {
|
233 |
} else {
|
- |
|
234 |
// LDAP Bind failed
|
230 |
$resp = 0;
|
235 |
return 0;
|
231 |
}
|
236 |
}
|
232 |
return $resp;
|
- |
|
233 |
} else {
|
237 |
} else {
|
- |
|
238 |
// LDAP connection failed
|
234 |
return -1;
|
239 |
return -2;
|
235 |
}
|
240 |
}
|
236 |
return 1;
|
- |
|
237 |
}
|
241 |
}
|
238 |
}
|
242 |
}
|
239 |
|
243 |
|
240 |
/********************************
|
244 |
/********************************
|
241 |
* TO DO *
|
245 |
* TO DO *
|
Line 277... |
Line 281... |
277 |
<tr><td valign="middle" align="left">
|
281 |
<tr><td valign="middle" align="left">
|
278 |
<form name="config_ldap" method="post" action="update_ldap.php">
|
282 |
<form name="config_ldap" method="post" action="update_ldap.php">
|
279 |
<fieldset>
|
283 |
<fieldset>
|
280 |
<legend>
|
284 |
<legend>
|
281 |
<?php
|
285 |
<?php
|
282 |
echo $message;
|
286 |
echo $message;
|
283 |
$tmp_host = explode("//",$ldap_server); //pour discriminer le host et le protocole
|
287 |
$pos = strpos($ldap_server, "//");
|
- |
|
288 |
if ($pos!==false){
|
284 |
//to do : pour la prochaine version, prise en compte du choix du port LDAP (configurable par le formulaire)
|
289 |
$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"
|
- |
|
290 |
} else {
|
- |
|
291 |
$new_ldap_server = $ldap_server.
|
- |
|
292 |
}
|
285 |
if (($ldap == "ldap") && (function_exists('ldap_connect'))){
|
293 |
if (($ldap == "ldap") && (function_exists('ldap_connect'))){
|
286 |
echo "<div align='center'><br>";
|
294 |
echo "<div align='center'><br>";
|
287 |
switch(ldap_test($tmp_host[1], $ldap_identity, $ldap_password)){
|
295 |
switch(ldap_test($new_ldap_server, $ldap_identity, $ldap_password)){
|
- |
|
296 |
case -2:
|
- |
|
297 |
echo "<font color='red'>".$l_ldap_test_connection_failed."</font>";
|
- |
|
298 |
break;
|
288 |
case -1:
|
299 |
case -1:
|
289 |
echo "<font color='red'>".$l_ldap_test_hs2."</font>";
|
300 |
echo "<font color='red'>".$l_ldap_test_network_failed."</font>";
|
290 |
break;
|
301 |
break;
|
291 |
case 0:
|
302 |
case 0:
|
292 |
echo "<font color='red'>".$l_ldap_test_hs."</font>";
|
303 |
echo "<font color='red'>".$l_ldap_test_bind_failed."</font>";
|
293 |
break;
|
304 |
break;
|
294 |
case 1:
|
305 |
case 1:
|
295 |
echo "<font color='green'>".$l_ldap_test_ok."</font>";
|
306 |
echo "<font color='green'>".$l_ldap_test_bind_ok."</font>";
|
296 |
break;
|
307 |
break;
|
297 |
default:
|
308 |
default:
|
298 |
echo "LDAP error";
|
309 |
echo "LDAP error";
|
299 |
}
|
310 |
}
|
300 |
echo "<br><br></div>";
|
311 |
echo "<br><br></div>";
|