Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
2 |
# $Id: ldap.php 2465 2017-12-17 23:00:14Z richard $
|
2 |
# $Id: ldap.php 2475 2017-12-30 02:25:12Z tom.houdayer $
|
3 |
|
3 |
|
4 |
/* written by steweb57, Rexy & Tom HOUDAYER */
|
4 |
/* written by steweb57, Rexy & Tom HOUDAYER */
|
5 |
/****************************************************************
|
5 |
/****************************************************************
|
6 |
* GLOBAL FILE PATHS *
|
6 |
* GLOBAL FILE PATHS *
|
7 |
*****************************************************************/
|
7 |
*****************************************************************/
|
Line 72... |
Line 72... |
72 |
$l_ldap_test_bind_ok = "L'authentification a réussie";
|
72 |
$l_ldap_test_bind_ok = "L'authentification a réussie";
|
73 |
$l_ldap_test_dn_failed = "Le DN de la base semble incorrect (vérifiez le)";
|
73 |
$l_ldap_test_dn_failed = "Le DN de la base semble incorrect (vérifiez le)";
|
74 |
$l_ldap_test_dn_ok = "Le DN de la base semble correct";
|
74 |
$l_ldap_test_dn_ok = "Le DN de la base semble correct";
|
75 |
$l_ldap_error = "erreur LDAP";
|
75 |
$l_ldap_error = "erreur LDAP";
|
76 |
$l_ldap_entries = "entrées dans la base";
|
76 |
$l_ldap_entries = "entrées dans la base";
|
77 |
$l_check = "Vérifier cette configuration";
|
77 |
$l_check = "Vérifier cette configuration";
|
- |
|
78 |
$l_checkingConf = "Vérification de cette configuration...";
|
78 |
} else { // English
|
79 |
} else { // English
|
79 |
$l_ldap_update = "LDAP settings updated";
|
80 |
$l_ldap_update = "LDAP settings updated";
|
80 |
$l_ldap_title = "External authentication : LDAP";
|
81 |
$l_ldap_title = "External authentication : LDAP";
|
81 |
$l_ldap_legend = "LDAP authentication";
|
82 |
$l_ldap_legend = "LDAP authentication";
|
82 |
$l_ldap_auth_enable_label = "Edit the LDAP configuration :";
|
83 |
$l_ldap_auth_enable_label = "Edit the LDAP configuration :";
|
Line 99... |
Line 100... |
99 |
$l_ldap_test_service_ok = "A port 389 is open on this server";
|
100 |
$l_ldap_test_service_ok = "A port 389 is open on this server";
|
100 |
$l_ldap_test_connection_failed = "LDAP connexion failed (check the LDAP service on this server)";
|
101 |
$l_ldap_test_connection_failed = "LDAP connexion failed (check the LDAP service on this server)";
|
101 |
$l_ldap_test_connection_ok = "A LDAP connexion is established";
|
102 |
$l_ldap_test_connection_ok = "A LDAP connexion is established";
|
102 |
$l_ldap_test_bind_failed = "LDAP authentication failed (check the LDAP user and password)";
|
103 |
$l_ldap_test_bind_failed = "LDAP authentication failed (check the LDAP user and password)";
|
103 |
$l_ldap_test_bind_ok = "Successful authentication";
|
104 |
$l_ldap_test_bind_ok = "Successful authentication";
|
104 |
$l_ldap_test_dn_failed = "DN of the base seems to be wrong (check it)";
|
105 |
$l_ldap_test_dn_failed = "DN of the base seems to be wrong (check it)";
|
105 |
$l_ldap_test_dn_ok = "DN of the base seems to be ok";
|
106 |
$l_ldap_test_dn_ok = "DN of the base seems to be ok";
|
106 |
$l_ldap_error = "LDAP error";
|
107 |
$l_ldap_error = "LDAP error";
|
107 |
$l_ldap_entries = "entries in the base";
|
108 |
$l_ldap_entries = "entries in the base";
|
108 |
$l_check = "Check this config";
|
109 |
$l_check = "Check this config";
|
- |
|
110 |
$l_checkingConf = "Checking this configuration...";
|
109 |
}
|
111 |
}
|
110 |
|
112 |
|
111 |
|
113 |
|
112 |
function ldap_checkServerConfig($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_basedn, $f_ldap_uid, $f_ldap_port = 389) {
|
114 |
function ldap_checkServerConfig($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_basedn, $f_ldap_uid, $f_ldap_port = 389) {
|
113 |
// Socket to the LDAP port of the server
|
115 |
// Socket to the LDAP port of the server
|
Line 214... |
Line 216... |
214 |
$ldap_password = $conf['LDAP_PASSWORD'];
|
216 |
$ldap_password = $conf['LDAP_PASSWORD'];
|
215 |
$ldap_base_dn = $conf['LDAP_BASE'];
|
217 |
$ldap_base_dn = $conf['LDAP_BASE'];
|
216 |
$ldap_uid = $conf['LDAP_UID'];
|
218 |
$ldap_uid = $conf['LDAP_UID'];
|
217 |
$ldap_base_filter = $conf['LDAP_FILTER'];
|
219 |
$ldap_base_filter = $conf['LDAP_FILTER'];
|
218 |
|
220 |
|
219 |
// TODO : check LDAP PHP extension loaded?
|
- |
|
220 |
// if (!extension_loaded('ldap')) {
|
- |
|
221 |
// exit();
|
- |
|
222 |
// }
|
- |
|
223 |
|
- |
|
224 |
$pos = strpos($ldap_server, '//');
|
- |
|
225 |
if ($pos !== false) {
|
- |
|
226 |
// TODO : useless?
|
- |
|
227 |
$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"
|
- |
|
228 |
} else {
|
- |
|
229 |
$new_ldap_server = $ldap_server;
|
- |
|
230 |
}
|
- |
|
231 |
|
- |
|
232 |
// AJAX LDAP configuration checker
|
221 |
// AJAX LDAP configuration checker
|
233 |
if (isset($_GET['conf_check'])) {
|
222 |
if (isset($_GET['conf_check'])) {
|
234 |
$response = [
|
223 |
$response = [
|
235 |
'enable' => $ldap_status
|
224 |
'enable' => $ldap_status
|
236 |
];
|
225 |
];
|
Line 316... |
Line 305... |
316 |
};
|
305 |
};
|
317 |
|
306 |
|
318 |
// Format HTTP POST data
|
307 |
// Format HTTP POST data
|
319 |
var post_data = Object.keys(ldap_config).map( function (k) { return encodeURIComponent(k) + '=' + encodeURIComponent(ldap_config[k]) } ).join('&');
|
308 |
var post_data = Object.keys(ldap_config).map( function (k) { return encodeURIComponent(k) + '=' + encodeURIComponent(ldap_config[k]) } ).join('&');
|
320 |
|
309 |
|
321 |
messagesElem.innerHTML = '<?= 'Checking configuration...' /* TODO: need to translate */ ?>';
|
310 |
messagesElem.innerHTML = '<?= $l_checkingConf ?>';
|
322 |
|
311 |
|
323 |
var xhr = new XMLHttpRequest();
|
312 |
var xhr = new XMLHttpRequest();
|
324 |
xhr.onreadystatechange = function() {
|
313 |
xhr.onreadystatechange = function() {
|
325 |
if (this.readyState == 4) {
|
314 |
if (this.readyState == 4) {
|
326 |
if (this.status == 200) {
|
315 |
if (this.status == 200) {
|
Line 404... |
Line 393... |
404 |
<dt>
|
393 |
<dt>
|
405 |
<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
|
394 |
<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
|
406 |
<?= $l_ldap_server_text ?>
|
395 |
<?= $l_ldap_server_text ?>
|
407 |
</dt>
|
396 |
</dt>
|
408 |
<dd>
|
397 |
<dd>
|
409 |
<input id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>" oninput="onLdapStatusChange();">
|
398 |
<input type="text" id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>" oninput="onLdapStatusChange();">
|
410 |
</dd>
|
399 |
</dd>
|
411 |
</dl>
|
400 |
</dl>
|
412 |
<dl>
|
401 |
<dl>
|
413 |
<dt>
|
402 |
<dt>
|
414 |
<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
|
403 |
<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
|
415 |
<?= $l_ldap_base_dn_text ?>
|
404 |
<?= $l_ldap_base_dn_text ?>
|
416 |
</dt>
|
405 |
</dt>
|
417 |
<dd>
|
406 |
<dd>
|
418 |
<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>" oninput="onLdapStatusChange();">
|
407 |
<input type="text" id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>" oninput="onLdapStatusChange();">
|
419 |
</dd>
|
408 |
</dd>
|
420 |
</dl>
|
409 |
</dl>
|
421 |
<dl>
|
410 |
<dl>
|
422 |
<dt>
|
411 |
<dt>
|
423 |
<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
|
412 |
<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
|
424 |
<?= $l_ldap_uid_text ?>
|
413 |
<?= $l_ldap_uid_text ?>
|
425 |
</dt>
|
414 |
</dt>
|
426 |
<dd>
|
415 |
<dd>
|
427 |
<input id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>" oninput="onLdapStatusChange();">
|
416 |
<input type="text" id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>" oninput="onLdapStatusChange();">
|
428 |
</dd>
|
417 |
</dd>
|
429 |
</dl>
|
418 |
</dl>
|
430 |
<dl>
|
419 |
<dl>
|
431 |
<dt>
|
420 |
<dt>
|
432 |
<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
|
421 |
<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
|
433 |
<?= $l_ldap_base_filter_text ?>
|
422 |
<?= $l_ldap_base_filter_text ?>
|
434 |
</dt>
|
423 |
</dt>
|
435 |
<dd>
|
424 |
<dd>
|
436 |
<input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>" oninput="onLdapStatusChange();">
|
425 |
<input type="text" id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>" oninput="onLdapStatusChange();">
|
437 |
</dd>
|
426 |
</dd>
|
438 |
</dl>
|
427 |
</dl>
|
439 |
<dl>
|
428 |
<dl>
|
440 |
<dt>
|
429 |
<dt>
|
441 |
<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
|
430 |
<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
|
442 |
<?= $l_ldap_user_text ?>
|
431 |
<?= $l_ldap_user_text ?>
|
443 |
</dt>
|
432 |
</dt>
|
444 |
<dd>
|
433 |
<dd>
|
445 |
<input id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>" oninput="onLdapStatusChange();">
|
434 |
<input type="text" id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>" oninput="onLdapStatusChange();">
|
446 |
</dd>
|
435 |
</dd>
|
447 |
</dl>
|
436 |
</dl>
|
448 |
<dl>
|
437 |
<dl>
|
449 |
<dt>
|
438 |
<dt>
|
450 |
<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
|
439 |
<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
|
451 |
<?= $l_ldap_password_text ?>
|
440 |
<?= $l_ldap_password_text ?>
|
452 |
</dt>
|
441 |
</dt>
|
453 |
<dd>
|
442 |
<dd>
|
454 |
<input id="ldap_password" type="password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>" oninput="onLdapStatusChange();">
|
443 |
<input type="text" id="ldap_password" type="password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>" oninput="onLdapStatusChange();">
|
455 |
</dd>
|
444 |
</dd>
|
456 |
</dl>
|
445 |
</dl>
|
457 |
<p>
|
446 |
<p>
|
458 |
<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>
|
447 |
<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>
|
459 |
<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit" title="<?= 'You need to check before submit' /* TODO: need to translate */ ?>">
|
448 |
<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit">
|
460 |
</p>
|
449 |
</p>
|
461 |
</fieldset>
|
450 |
</fieldset>
|
462 |
</form>
|
451 |
</form>
|
463 |
</div>
|
452 |
</div>
|
464 |
</div>
|
453 |
</div>
|