Subversion Repositories ALCASAR

Rev

Rev 2731 | Rev 2817 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2731 Rev 2809
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: ldap.php 2731 2019-05-26 21:09:18Z tom.houdayer $
2
# $Id: ldap.php 2809 2020-04-12 17:35:46Z rexy $
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 166... Line 166...
166
		exit();
166
		exit();
167
	}
167
	}
168
 
168
 
169
	// Check LDAP service
169
	// Check LDAP service
170
	if ($ldap_port_636) {
170
	if ($ldap_port_636) {
171
if (PHP_VERSION_ID >= 70100):
-
 
172
		// Set LDAP SSL options
171
	// Set LDAP SSL options
173
		ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
172
		ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
174
endif;
-
 
175
		$ldapconn = @ldap_connect('ldaps://'.$ldap_server);
173
		$ldapconn = @ldap_connect('ldaps://'.$ldap_server);
176
		if (!$ldapconn) {
174
		if (!$ldapconn) {
177
			$ldap_srv_636 = false;
175
			$ldap_srv_636 = false;
178
		} else {
176
		} else {
179
			ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
177
			ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
Line 283... Line 281...
283
		// no network connection
281
		// no network connection
284
		return -2;
282
		return -2;
285
	}
283
	}
286
	fclose($sock);
284
	fclose($sock);
287
 
285
 
288
if (PHP_VERSION_ID >= 70100):
-
 
289
	// Set LDAP SSL options
286
	// Set LDAP SSL options
290
	if ($f_ldap_ssl) {
287
	if ($f_ldap_ssl) {
291
		if ($f_ldap_cert_required) {
288
		if ($f_ldap_cert_required) {
292
			if ($f_ldap_cert) {
289
			if ($f_ldap_cert) {
293
				ldap_set_option(null, LDAP_OPT_X_TLS_CACERTFILE, $f_ldap_cert);
290
				ldap_set_option(null, LDAP_OPT_X_TLS_CACERTFILE, $f_ldap_cert);
Line 296... Line 293...
296
 
293
 
297
		} else {
294
		} else {
298
			ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
295
			ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
299
		}
296
		}
300
	}
297
	}
301
endif;
-
 
302
 
298
 
303
	// if ok, Test LDAP connection
299
	// if ok, Test LDAP connection
304
	$ldapconn = @ldap_connect((($f_ldap_ssl)?'ldaps':'ldap').'://'.$f_ldap_server);
300
	$ldapconn = @ldap_connect((($f_ldap_ssl)?'ldaps':'ldap').'://'.$f_ldap_server);
305
	if (!$ldapconn) {
301
	if (!$ldapconn) {
306
		// LDAP connection failed
302
		// LDAP connection failed
Line 512... Line 508...
512
<html>
508
<html>
513
<head>
509
<head>
514
	<meta charset="UTF-8">
510
	<meta charset="UTF-8">
515
	<title><?= $l_ldap_title ?></title>
511
	<title><?= $l_ldap_title ?></title>
516
	<link type="text/css" href="/css/style.css" rel="stylesheet">
512
	<link type="text/css" href="/css/style.css" rel="stylesheet">
517
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
-
 
518
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
513
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
519
	<script>
514
	<script>
520
	function onLdapStatusChange() {
515
	function onLdapStatusChange() {
521
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password', 'ldap_ssl', 'ldap_cert_required', 'ldap_cert'];
516
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password', 'ldap_ssl', 'ldap_cert_required', 'ldap_cert'];
522
		var formSubmit = document.querySelector('form input[type="submit"]');
517
		var formSubmit = document.querySelector('form input[type="submit"]');
Line 538... Line 533...
538
				document.getElementById('ldap_cert').style.backgroundColor = '#c0c0c0';
533
				document.getElementById('ldap_cert').style.backgroundColor = '#c0c0c0';
539
				document.getElementById('ldap_cert').disabled = true;
534
				document.getElementById('ldap_cert').disabled = true;
540
			}
535
			}
541
			formSubmit.style.display = 'none';
536
			formSubmit.style.display = 'none';
542
			btn_checkConf.style.display = null;
537
			btn_checkConf.style.display = null;
543
<?php if (PHP_VERSION_ID < 70100): ?>
-
 
544
			// Compatibility with PHP < 7.1.0 # TODO : remove if ever Mageia 7 is released
-
 
545
			formSubmit.style.display = null;
-
 
546
<?php endif; ?>
-
 
547
		} else {
538
		} else {
548
			for (var i=0; i<listToDisables.length; i++) {
539
			for (var i=0; i<listToDisables.length; i++) {
549
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
540
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
550
				document.getElementById(listToDisables[i]).disabled = true;
541
				document.getElementById(listToDisables[i]).disabled = true;
551
			}
542
			}
Line 600... Line 591...
600
						btn_checkConf.style.display = 'none';
591
						btn_checkConf.style.display = 'none';
601
					} else {
592
					} else {
602
						formSubmit.style.display = 'none';
593
						formSubmit.style.display = 'none';
603
						btn_checkConf.style.display = null;
594
						btn_checkConf.style.display = null;
604
					}
595
					}
605
<?php if (PHP_VERSION_ID < 70100): ?>
-
 
606
					// Compatibility with PHP < 7.1.0 # TODO : remove if ever Mageia 7 is released
-
 
607
					formSubmit.style.display = null;
-
 
608
<?php endif; ?>
-
 
609
 
596
 
610
					if (typeof data.errors !== 'undefined') {
597
					if (typeof data.errors !== 'undefined') {
611
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
598
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
612
					}
599
					}
613
					if (typeof data.warnings !== 'undefined') {
600
					if (typeof data.warnings !== 'undefined') {