Subversion Repositories ALCASAR

Rev

Rev 2475 | Rev 2705 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2475 Rev 2532
1
<?php
1
<?php
2
# $Id: ldap.php 2475 2017-12-30 02:25:12Z tom.houdayer $
2
# $Id: ldap.php 2532 2018-04-30 03:55:35Z 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
*****************************************************************/
8
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
8
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
9
 
9
 
10
/****************************************************************
10
/****************************************************************
11
*			FILE reading test			*
11
*			FILE reading test			*
12
*****************************************************************/
12
*****************************************************************/
13
$conf_files = array(CONF_FILE);
13
$conf_files = array(CONF_FILE);
14
foreach ($conf_files as $file) {
14
foreach ($conf_files as $file) {
15
	if (!file_exists($file)) {
15
	if (!file_exists($file)) {
16
		exit("Fichier $file non présent");
16
		exit("Fichier $file non présent");
17
	}
17
	}
18
	if (!is_readable($file)) {
18
	if (!is_readable($file)) {
19
		exit("Vous n'avez pas les droits de lecture sur le fichier $file");
19
		exit("Vous n'avez pas les droits de lecture sur le fichier $file");
20
	}
20
	}
21
}
21
}
22
 
22
 
23
/****************************************************************
23
/****************************************************************
24
*			Read CONF_FILE				*
24
*			Read CONF_FILE				*
25
*****************************************************************/
25
*****************************************************************/
26
$file_conf = fopen(CONF_FILE, 'r');
26
$file_conf = fopen(CONF_FILE, 'r');
27
if (!$file_conf) {
27
if (!$file_conf) {
28
	exit('Error opening the file '.CONF_FILE);
28
	exit('Error opening the file '.CONF_FILE);
29
}
29
}
30
while (!feof($file_conf)) {
30
while (!feof($file_conf)) {
31
	$buffer = fgets($file_conf, 4096);
31
	$buffer = fgets($file_conf, 4096);
32
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
32
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
33
		$tmp = explode('=', $buffer, 2);
33
		$tmp = explode('=', $buffer, 2);
34
		$conf[trim($tmp[0])] = trim($tmp[1]);
34
		$conf[trim($tmp[0])] = trim($tmp[1]);
35
	}
35
	}
36
}
36
}
37
fclose($file_conf);
37
fclose($file_conf);
38
 
38
 
39
/****************************************************************
39
/****************************************************************
40
*			Choice of language			*
40
*			Choice of language			*
41
*****************************************************************/
41
*****************************************************************/
42
$Language = 'en';
42
$Language = 'en';
43
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
43
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
44
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
44
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
45
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
45
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
46
}
46
}
47
if ($Language === 'fr') {		// French
47
if ($Language === 'fr') {		// French
48
	$l_ldap_update			= "Mise à jour des paramètres LDAP effectuée";
48
	$l_ldap_update			= "Mise à jour des paramètres LDAP effectuée";
49
	$l_ldap_title			= "Authentification externe : LDAP";
49
	$l_ldap_title			= "Authentification externe : LDAP";
50
	$l_ldap_legend			= "Authentification LDAP";
50
	$l_ldap_legend			= "Authentification LDAP";
51
	$l_ldap_auth_enable_label	= "Éditer la configuration LDAP:";
51
	$l_ldap_auth_enable_label	= "Éditer la configuration LDAP:";
52
	$l_ldap_YES			= "OUI";
52
	$l_ldap_YES			= "OUI";
53
	$l_ldap_NO			= "NON";
53
	$l_ldap_NO			= "NON";
54
	$l_ldap_server_label		= "Serveur LDAP:";
54
	$l_ldap_server_label		= "Serveur LDAP:";
55
	$l_ldap_server_text		= "Adresse IP du serveur";
55
	$l_ldap_server_text		= "Adresse IP du serveur";
56
	$l_ldap_base_dn_label		= "DN de la base:";
56
	$l_ldap_base_dn_label		= "DN de la base:";
57
	$l_ldap_base_dn_text		= "Le DN (Distinguished Name) définit où se situent les informations des utilisateurs dans l'annuaire.<br> - Exemple LDAP: 'o=mycompany, c=FR'.<br> - Exemple AD 'cn=Users,dc=server_name,dc=localdomain'";
57
	$l_ldap_base_dn_text		= "Le DN (Distinguished Name) définit où se situent les informations des utilisateurs dans l'annuaire.<br> - Exemple LDAP: 'o=mycompany, c=FR'.<br> - Exemple AD 'cn=Users,dc=server_name,dc=localdomain'";
58
	$l_ldap_uid_label		= "Identifiant d'utilisateur (UID):";
58
	$l_ldap_uid_label		= "Identifiant d'utilisateur (UID):";
59
	$l_ldap_uid_text		= "Clé utilisée pour rechercher un identifiant de connexion.<br> - Exemple LDAP: 'uid', 'sn', etc.<br> - Pour A.D. mettre 'sAMAccountName'.";
59
	$l_ldap_uid_text		= "Clé utilisée pour rechercher un identifiant de connexion.<br> - Exemple LDAP: 'uid', 'sn', etc.<br> - Pour A.D. mettre 'sAMAccountName'.";
60
	$l_ldap_base_filter_label	= "Filtre de recherche des utilisateurs (optionnel):";
60
	$l_ldap_base_filter_label	= "Filtre de recherche des utilisateurs (optionnel):";
61
	$l_ldap_base_filter_text	= "Vous pouvez limiter les objets recherchés avec des filtres additionnels.<br> Exemple 'objectClass=posixGroup' ajouterait le filtre '(&amp;(uid=username)(objectClass=posixGroup))'";
61
	$l_ldap_base_filter_text	= "Vous pouvez limiter les objets recherchés avec des filtres additionnels.<br> Exemple 'objectClass=posixGroup' ajouterait le filtre '(&amp;(uid=username)(objectClass=posixGroup))'";
62
	$l_ldap_user_label		= "CN de l'utilisateur exploité par ALCASAR:";
62
	$l_ldap_user_label		= "CN de l'utilisateur exploité par ALCASAR:";
63
	$l_ldap_user_text		= "CN=Common Name. Laissez vide pour utiliser un accès invité (ou anonyme). Obligatoire sur un AD.<br> - Exemple LDAP : 'uid=username,ou=my_lan,o=mycompany,c=FR'.<br> - Exemple AD : 'username' ou 'cn=username,cn=Users,dc=server_name,dc=localdomain'";
63
	$l_ldap_user_text		= "CN=Common Name. Laissez vide pour utiliser un accès invité (ou anonyme). Obligatoire sur un AD.<br> - Exemple LDAP : 'uid=username,ou=my_lan,o=mycompany,c=FR'.<br> - Exemple AD : 'username' ou 'cn=username,cn=Users,dc=server_name,dc=localdomain'";
64
	$l_ldap_password_label		= "Mot de passe:";
64
	$l_ldap_password_label		= "Mot de passe:";
65
	$l_ldap_password_text		= "Laissez vide pour un accès invité (ou anonyme). Obligatoire sur un AD.";
65
	$l_ldap_password_text		= "Laissez vide pour un accès invité (ou anonyme). Obligatoire sur un AD.";
66
	$l_ldap_submit			= "Enregistrer";
66
	$l_ldap_submit			= "Enregistrer";
67
	$l_ldap_test_service_failed	= "Service LDAP injoignable sur ce serveur (vérifiez l'@IP).";
67
	$l_ldap_test_service_failed	= "Service LDAP injoignable sur ce serveur (vérifiez l'@IP).";
68
	$l_ldap_test_service_ok		= "Un port 389 est actif sur ce serveur";
68
	$l_ldap_test_service_ok		= "Un port 389 est actif sur ce serveur";
69
	$l_ldap_test_connection_failed	= "Connexion LDAP impossible (vérifiez le service LDAP sur ce serveur)";
69
	$l_ldap_test_connection_failed	= "Connexion LDAP impossible (vérifiez le service LDAP sur ce serveur)";
70
	$l_ldap_test_connection_ok	= "Une connexion LDAP a été établie";
70
	$l_ldap_test_connection_ok	= "Une connexion LDAP a été établie";
71
	$l_ldap_test_bind_failed	= "Echec d'authentification (vérifiez l'utilisateur et le mot de passe)";
71
	$l_ldap_test_bind_failed	= "Echec d'authentification (vérifiez l'utilisateur et le mot de passe)";
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
	$l_checkingConf			= "Vérification de cette configuration...";
79
} else {				// English
79
} else {				// English
80
	$l_ldap_update			= "LDAP settings updated";
80
	$l_ldap_update			= "LDAP settings updated";
81
	$l_ldap_title			= "External authentication : LDAP";
81
	$l_ldap_title			= "External authentication : LDAP";
82
	$l_ldap_legend			= "LDAP authentication";
82
	$l_ldap_legend			= "LDAP authentication";
83
	$l_ldap_auth_enable_label	= "Edit the LDAP configuration :";
83
	$l_ldap_auth_enable_label	= "Edit the LDAP configuration :";
84
	$l_ldap_YES			= "YES";
84
	$l_ldap_YES			= "YES";
85
	$l_ldap_NO			= "NO";
85
	$l_ldap_NO			= "NO";
86
	$l_ldap_server_label		= "LDAP server :";
86
	$l_ldap_server_label		= "LDAP server :";
87
	$l_ldap_server_text		= "IP address of the LDAP server.";
87
	$l_ldap_server_text		= "IP address of the LDAP server.";
88
	$l_ldap_base_dn_label		= "DN of the base:";
88
	$l_ldap_base_dn_label		= "DN of the base:";
89
	$l_ldap_base_dn_text		= "The DN (Distinguished Name) is used to locate the users information in the directory.<br> e.g. LDAP : 'o=MyCompany,c=US'.<br> e.g. AD : 'cn=Users,dc=server_name,dc=localdomain'";
89
	$l_ldap_base_dn_text		= "The DN (Distinguished Name) is used to locate the users information in the directory.<br> e.g. LDAP : 'o=MyCompany,c=US'.<br> e.g. AD : 'cn=Users,dc=server_name,dc=localdomain'";
90
	$l_ldap_uid_label		= "User IDentifier (UID):";
90
	$l_ldap_uid_label		= "User IDentifier (UID):";
91
	$l_ldap_uid_text		= "Key used to search for a given login identity.<br>e.g. 'uid', 'sn', etc.. For AD use 'sAMAccountName'.";
91
	$l_ldap_uid_text		= "Key used to search for a given login identity.<br>e.g. 'uid', 'sn', etc.. For AD use 'sAMAccountName'.";
92
	$l_ldap_base_filter_label	= "User search filter (optional):";
92
	$l_ldap_base_filter_label	= "User search filter (optional):";
93
	$l_ldap_base_filter_text	= "You can further limit the searched objects with additional filters.<br> For example 'objectClass=posixGroup' would result in the use of '(&amp;(uid=username)(objectClass=posixGroup))'";
93
	$l_ldap_base_filter_text	= "You can further limit the searched objects with additional filters.<br> For example 'objectClass=posixGroup' would result in the use of '(&amp;(uid=username)(objectClass=posixGroup))'";
94
	$l_ldap_user_label		= "CN of the user operated by ALCASAR:";
94
	$l_ldap_user_label		= "CN of the user operated by ALCASAR:";
95
	$l_ldap_user_text		= "CN=Common Name. Leave blank to use anonymous binding. Mandatory for AD.<br> e.g. LDAP :'uid=Username,ou=my_lan,o=mycompany,c=US'.<br> e.g. AD : 'username' or 'cn=username,cn=Users,dc=server_name,dc=localdomain'";
95
	$l_ldap_user_text		= "CN=Common Name. Leave blank to use anonymous binding. Mandatory for AD.<br> e.g. LDAP :'uid=Username,ou=my_lan,o=mycompany,c=US'.<br> e.g. AD : 'username' or 'cn=username,cn=Users,dc=server_name,dc=localdomain'";
96
	$l_ldap_password_label		= "Password:";
96
	$l_ldap_password_label		= "Password:";
97
	$l_ldap_password_text		= "Leave blank to use anonymous binding. Mandatory for AD.";
97
	$l_ldap_password_text		= "Leave blank to use anonymous binding. Mandatory for AD.";
98
	$l_ldap_submit			= "Save";
98
	$l_ldap_submit			= "Save";
99
	$l_ldap_test_service_failed	= "LDAP service is not reachable on that server (check IP)";
99
	$l_ldap_test_service_failed	= "LDAP service is not reachable on that server (check IP)";
100
	$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";
101
	$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)";
102
	$l_ldap_test_connection_ok	= "A LDAP connexion is established";
102
	$l_ldap_test_connection_ok	= "A LDAP connexion is established";
103
	$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)";
104
	$l_ldap_test_bind_ok		= "Successful authentication";
104
	$l_ldap_test_bind_ok		= "Successful authentication";
105
	$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)";
106
	$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";
107
	$l_ldap_error			= "LDAP error";
107
	$l_ldap_error			= "LDAP error";
108
	$l_ldap_entries			= "entries in the base";
108
	$l_ldap_entries			= "entries in the base";
109
	$l_check			= "Check this config";
109
	$l_check			= "Check this config";
110
	$l_checkingConf			= "Checking this configuration...";
110
	$l_checkingConf			= "Checking this configuration...";
111
}
111
}
112
 
112
 
113
 
113
 
114
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) {
115
	// Socket to the LDAP port of the server
115
	// Socket to the LDAP port of the server
116
	if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
116
	if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
117
		// no network connection
117
		// no network connection
118
		return -2;
118
		return -2;
119
	}
119
	}
120
	fclose($sock);
120
	fclose($sock);
121
 
121
 
122
	// if ok, Test LDAP connection
122
	// if ok, Test LDAP connection
123
	$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
123
	$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
124
	ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
124
	ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
125
	if (!$ldapconn) {
125
	if (!$ldapconn) {
126
		// LDAP connection failed
126
		// LDAP connection failed
127
		return -1;
127
		return -1;
128
	}
128
	}
129
 
129
 
130
	// if ok, test a ldap-bind with the user used by ALCASAR
130
	// if ok, test a ldap-bind with the user used by ALCASAR
131
	$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
131
	$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
132
	if (!$ldapbind) {
132
	if (!$ldapbind) {
133
		// Test LDAP Version 3
133
		// Test LDAP Version 3
134
		ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
134
		ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
135
		$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
135
		$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
136
		if (!$ldapbind) {
136
		if (!$ldapbind) {
137
			// LDAP Bind failed
137
			// LDAP Bind failed
138
			return 0;
138
			return 0;
139
		}
139
		}
140
	}
140
	}
141
 
141
 
142
	// if ok, try to query the directory of users
142
	// if ok, try to query the directory of users
143
	$query = $f_ldap_uid."=*";
143
	$query = $f_ldap_uid.'=*';
144
	$ldap_result = ldap_search($ldapconn, $f_ldap_basedn, $query);
144
	$ldap_result = ldap_search($ldapconn, $f_ldap_basedn, $query);
145
	if (ldap_search($ldapconn, $f_ldap_basedn, $query)) {
145
	if ($ldap_result) {
146
		$ldap_users_count = ldap_count_entries($ldapconn, $ldap_result);
146
		$ldap_users_count = ldap_count_entries($ldapconn, $ldap_result);
147
		return ($ldap_users_count + 2);
147
		return ($ldap_users_count + 2);
148
	} else {
148
	} else {
149
		return 1;
149
		return 1;
150
	}
150
	}
151
	ldap_unbind($ldapconn);
151
	ldap_unbind($ldapconn);
152
}
152
}
153
 
153
 
154
$messages = '';
154
$messages = '';
155
 
155
 
156
if (isset($_POST['auth_enable'])) {
156
if (isset($_POST['auth_enable'])) {
157
	if ($_POST['auth_enable'] === '1') {
157
	if ($_POST['auth_enable'] === '1') {
158
		$varErrors = [];
158
		$varErrors = [];
159
		if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');
159
		if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');
160
		if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');
160
		if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');
161
		if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');
161
		if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');
162
		if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');
162
		if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');
163
		if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');
163
		if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');
164
		if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');
164
		if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');
165
 
165
 
166
		// Validation
166
		// Validation
167
		if (isset($ldap_server)) {
167
		if (isset($ldap_server)) {
168
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
168
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
169
				$ldap_server = gethostbyname($ldap_server);
169
				$ldap_server = gethostbyname($ldap_server);
170
			}
170
			}
171
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
171
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
172
				array_push($varErrors, 'Invalid LDAP server IP');
172
				array_push($varErrors, 'Invalid LDAP server IP');
173
			}
173
			}
174
		}
174
		}
175
 
175
 
176
		if (!empty($varErrors)) { 
176
		if (!empty($varErrors)) { 
177
			foreach ($varErrors as $error) {
177
			foreach ($varErrors as $error) {
178
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
178
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
179
			}
179
			}
180
		} else {
180
		} else {
181
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
181
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
182
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
182
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
183
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
183
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
184
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
184
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
185
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
185
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
186
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
186
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
187
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
187
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
188
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
188
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
189
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
189
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
190
		}
190
		}
191
	} else {
191
	} else {
192
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
192
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
193
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
193
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
194
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
194
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
195
	}
195
	}
196
 
196
 
197
	// Reload configuration
197
	// Reload configuration
198
	$file_conf = fopen(CONF_FILE, 'r');
198
	$file_conf = fopen(CONF_FILE, 'r');
199
	if (!$file_conf) {
199
	if (!$file_conf) {
200
		exit('Error opening the file '.CONF_FILE);
200
		exit('Error opening the file '.CONF_FILE);
201
	}
201
	}
202
	while (!feof($file_conf)) {
202
	while (!feof($file_conf)) {
203
		$buffer = fgets($file_conf, 4096);
203
		$buffer = fgets($file_conf, 4096);
204
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
204
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
205
			$tmp = explode('=', $buffer, 2);
205
			$tmp = explode('=', $buffer, 2);
206
			$conf[trim($tmp[0])] = trim($tmp[1]);
206
			$conf[trim($tmp[0])] = trim($tmp[1]);
207
		}
207
		}
208
	}
208
	}
209
	fclose($file_conf);
209
	fclose($file_conf);
210
}
210
}
211
 
211
 
212
// LDAP configuration params
212
// LDAP configuration params
213
$ldap_status      = ($conf['LDAP'] === 'on');
213
$ldap_status      = ($conf['LDAP'] === 'on');
214
$ldap_server      = $conf['LDAP_SERVER'];
214
$ldap_server      = $conf['LDAP_SERVER'];
215
$ldap_user        = $conf['LDAP_USER'];
215
$ldap_user        = $conf['LDAP_USER'];
216
$ldap_password    = $conf['LDAP_PASSWORD'];
216
$ldap_password    = $conf['LDAP_PASSWORD'];
217
$ldap_base_dn     = $conf['LDAP_BASE'];
217
$ldap_base_dn     = $conf['LDAP_BASE'];
218
$ldap_uid	  = $conf['LDAP_UID'];
218
$ldap_uid	  = $conf['LDAP_UID'];
219
$ldap_base_filter = $conf['LDAP_FILTER'];
219
$ldap_base_filter = $conf['LDAP_FILTER'];
220
 
220
 
221
// AJAX LDAP configuration checker
221
// AJAX LDAP configuration checker
222
if (isset($_GET['conf_check'])) {
222
if (isset($_GET['conf_check'])) {
223
	$response = [
223
	$response = [
224
		'enable' => $ldap_status
224
		'enable' => $ldap_status
225
	];
225
	];
226
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
226
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
227
		$varErrors = [];
227
		$varErrors = [];
228
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
228
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
229
			if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');		// TODO: need to translate
229
			if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');		// TODO: need to translate
230
			if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');		// TODO: need to translate
230
			if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');		// TODO: need to translate
231
			if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');		// TODO: need to translate
231
			if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');		// TODO: need to translate
232
			if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');	// TODO: need to translate
232
			if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');	// TODO: need to translate
233
			if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');		// TODO: need to translate
233
			if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');		// TODO: need to translate
234
			if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');		// TODO: need to translate
234
			if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');		// TODO: need to translate
235
		}
235
		}
236
 
236
 
237
		// Validation
237
		// Validation
238
		if (isset($ldap_server)) {
238
		if (isset($ldap_server)) {
239
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
239
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
240
				$ldap_server = gethostbyname($ldap_server);
240
				$ldap_server = gethostbyname($ldap_server);
241
			}
241
			}
242
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
242
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
243
				array_push($varErrors, 'Invalid LDAP server IP');	// TODO: need to translate
243
				array_push($varErrors, 'Invalid LDAP server IP');	// TODO: need to translate
244
			}
244
			}
245
		}
245
		}
246
 
246
 
247
		if (!empty($varErrors)) {
247
		if (!empty($varErrors)) {
248
			$response['errors'] = $varErrors;
248
			$response['errors'] = $varErrors;
249
		} else {
249
		} else {
250
			$response['result'] = ldap_checkServerConfig($ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_uid);
250
			$response['result'] = ldap_checkServerConfig($ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_uid);
251
		}
251
		}
252
	}
252
	}
253
 
253
 
254
	header('Content-Type: application/json');
254
	header('Content-Type: application/json');
255
	echo json_encode($response);
255
	echo json_encode($response);
256
	exit();
256
	exit();
257
}
257
}
258
 
258
 
259
?>
259
?>
260
<!DOCTYPE html>
260
<!DOCTYPE html>
261
<html>
261
<html>
262
<head>
262
<head>
263
	<meta charset="UTF-8">
263
	<meta charset="UTF-8">
264
	<title><?= $l_ldap_title ?></title>
264
	<title><?= $l_ldap_title ?></title>
265
	<link type="text/css" href="/css/style.css" rel="stylesheet">
265
	<link type="text/css" href="/css/style.css" rel="stylesheet">
266
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
266
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
267
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
267
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
268
	<script>
268
	<script>
269
	function onLdapStatusChange() {
269
	function onLdapStatusChange() {
270
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password'];
270
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password'];
271
		var formSubmit = document.querySelector('form input[type="submit"]');
271
		var formSubmit = document.querySelector('form input[type="submit"]');
272
		var btn_checkConf = document.getElementById('btn-checkconf');
272
		var btn_checkConf = document.getElementById('btn-checkconf');
273
		var isChecked = false;
273
		var isChecked = false;
274
 
274
 
275
		if (document.getElementById('auth_enable').value === '1') {
275
		if (document.getElementById('auth_enable').value === '1') {
276
			for (var i=0; i<listToDisables.length; i++) {
276
			for (var i=0; i<listToDisables.length; i++) {
277
				document.getElementById(listToDisables[i]).style.backgroundColor = '#ffffff';
277
				document.getElementById(listToDisables[i]).style.backgroundColor = '#ffffff';
278
				document.getElementById(listToDisables[i]).disabled = false;
278
				document.getElementById(listToDisables[i]).disabled = false;
279
			}
279
			}
280
			formSubmit.style.display = 'none';
280
			formSubmit.style.display = 'none';
281
			btn_checkConf.style.display = null;
281
			btn_checkConf.style.display = null;
282
		} else {
282
		} else {
283
			for (var i=0; i<listToDisables.length; i++) {
283
			for (var i=0; i<listToDisables.length; i++) {
284
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
284
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
285
				document.getElementById(listToDisables[i]).disabled = true;
285
				document.getElementById(listToDisables[i]).disabled = true;
286
			}
286
			}
287
			formSubmit.style.display = null;
287
			formSubmit.style.display = null;
288
			btn_checkConf.style.display = 'none';
288
			btn_checkConf.style.display = 'none';
289
		}
289
		}
290
	}
290
	}
291
 
291
 
292
	function checkConfig() {
292
	function checkConfig() {
293
		var messagesElem = document.querySelector('fieldset > legend > div');
293
		var messagesElem = document.querySelector('fieldset > legend > div');
294
		var formSubmit   = document.querySelector('form input[type="submit"]');
294
		var formSubmit   = document.querySelector('form input[type="submit"]');
295
		var btn_checkConf = document.getElementById('btn-checkconf');
295
		var btn_checkConf = document.getElementById('btn-checkconf');
296
 
296
 
297
		var ldap_config = {
297
		var ldap_config = {
298
			ldap_status:     (document.getElementById('auth_enable').value === '1'),
298
			ldap_status:     (document.getElementById('auth_enable').value === '1'),
299
			ldap_server:      document.getElementById('ldap_server').value,
299
			ldap_server:      document.getElementById('ldap_server').value,
300
			ldap_user:        document.getElementById('ldap_user').value,
300
			ldap_user:        document.getElementById('ldap_user').value,
301
			ldap_password:    document.getElementById('ldap_password').value,
301
			ldap_password:    document.getElementById('ldap_password').value,
302
			ldap_base_dn:     document.getElementById('ldap_dn').value,
302
			ldap_base_dn:     document.getElementById('ldap_dn').value,
303
			ldap_uid:         document.getElementById('ldap_uid').value,
303
			ldap_uid:         document.getElementById('ldap_uid').value,
304
			ldap_base_filter: document.getElementById('ldap_base_filter').value
304
			ldap_base_filter: document.getElementById('ldap_base_filter').value
305
		};
305
		};
306
 
306
 
307
		// Format HTTP POST data
307
		// Format HTTP POST data
308
		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('&');
309
 
309
 
310
		messagesElem.innerHTML = '<?= $l_checkingConf ?>';
310
		messagesElem.innerHTML = '<?= $l_checkingConf ?>';
311
 
311
 
312
		var xhr = new XMLHttpRequest();
312
		var xhr = new XMLHttpRequest();
313
		xhr.onreadystatechange = function() {
313
		xhr.onreadystatechange = function() {
314
			if (this.readyState == 4) {
314
			if (this.readyState == 4) {
315
				if (this.status == 200) {
315
				if (this.status == 200) {
316
					var data = JSON.parse(this.responseText);
316
					var data = JSON.parse(this.responseText);
317
 
317
 
318
					var messages = '';
318
					var messages = '';
319
 
319
 
320
					if (typeof data.result !== 'undefined') {
320
					if (typeof data.result !== 'undefined') {
321
						if (data.result === -2) {
321
						if (data.result === -2) {
322
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
322
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
323
						} else {
323
						} else {
324
							messages += "<span style=\"color: green\"><?= $l_ldap_test_service_ok ?></span>";
324
							messages += "<span style=\"color: green\"><?= $l_ldap_test_service_ok ?></span>";
325
							if (data.result === -1) {
325
							if (data.result === -1) {
326
								messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
326
								messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
327
							} else {
327
							} else {
328
								messages += "<br><span style=\"color: green\"><?= $l_ldap_test_connection_ok ?></span>";
328
								messages += "<br><span style=\"color: green\"><?= $l_ldap_test_connection_ok ?></span>";
329
								if (data.result === 0) {
329
								if (data.result === 0) {
330
									messages += "<br><span style=\"color: red\"><?= $l_ldap_test_bind_failed ?></span>";
330
									messages += "<br><span style=\"color: red\"><?= $l_ldap_test_bind_failed ?></span>";
331
								} else {
331
								} else {
332
									messages += "<br><span style=\"color: green\"><?= $l_ldap_test_bind_ok ?></span>";
332
									messages += "<br><span style=\"color: green\"><?= $l_ldap_test_bind_ok ?></span>";
333
									if (data.result === 1) {
333
									if (data.result === 1) {
334
										messages += "<br><span style=\"color: red\"><?= $l_ldap_test_dn_failed ?></span>";
334
										messages += "<br><span style=\"color: red\"><?= $l_ldap_test_dn_failed ?></span>";
335
									} else {
335
									} else {
336
										messages += "<br><span style=\"color: green\"><?= $l_ldap_test_dn_ok ?> (" + (data.result - 2) + " <?= $l_ldap_entries?>)</span>";
336
										messages += "<br><span style=\"color: green\"><?= $l_ldap_test_dn_ok ?> (" + (data.result - 2) + " <?= $l_ldap_entries?>)</span>";
337
									}
337
									}
338
								}
338
								}
339
							}
339
							}
340
						}
340
						}
341
					}
341
					}
342
 
342
 
343
					if (data.result > 1) {
343
					if (data.result > 1) {
344
						formSubmit.style.display = null;
344
						formSubmit.style.display = null;
345
						btn_checkConf.style.display = 'none';
345
						btn_checkConf.style.display = 'none';
346
					} else {
346
					} else {
347
						formSubmit.style.display = 'none';
347
						formSubmit.style.display = 'none';
348
						btn_checkConf.style.display = null;
348
						btn_checkConf.style.display = null;
349
					}
349
					}
350
 
350
 
351
					if (typeof data.errors !== 'undefined') {
351
					if (typeof data.errors !== 'undefined') {
352
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
352
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
353
					}
353
					}
354
 
354
 
355
					messagesElem.innerHTML = messages;
355
					messagesElem.innerHTML = messages;
356
				} else {
356
				} else {
357
					messagesElem.innerHTML = 'server error';
357
					messagesElem.innerHTML = 'server error';
358
				}
358
				}
359
			}
359
			}
360
		};
360
		};
361
		xhr.open('POST', 'ldap.php?conf_check', true);
361
		xhr.open('POST', 'ldap.php?conf_check', true);
362
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
362
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
363
		xhr.send(post_data);
363
		xhr.send(post_data);
364
	}
364
	}
365
	</script>
365
	</script>
366
</head>
366
</head>
367
<body onLoad="onLdapStatusChange();">
367
<body onLoad="onLdapStatusChange();">
368
	<div class="panel">
368
	<div class="panel">
369
		<div class="panel-header"><?= $l_ldap_legend ?></div>
369
		<div class="panel-header"><?= $l_ldap_legend ?></div>
370
		<div class="panel-body">
370
		<div class="panel-body">
371
			<form name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
371
			<form name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
372
				<fieldset>
372
				<fieldset>
373
					<legend>
373
					<legend>
374
						<br>
374
						<br>
375
						<div style="text-align: center">
375
						<div style="text-align: center">
376
							<?php if ($messages): ?>
376
							<?php if ($messages): ?>
377
								<?= $messages ?>
377
								<?= $messages ?>
378
							<?php endif; ?>
378
							<?php endif; ?>
379
						</div>
379
						</div>
380
					</legend>
380
					</legend>
381
					<dl>
381
					<dl>
382
						<dt>
382
						<dt>
383
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
383
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
384
						</dt>
384
						</dt>
385
						<dd>
385
						<dd>
386
							<select id="auth_enable" name="auth_enable" onchange="onLdapStatusChange();">
386
							<select id="auth_enable" name="auth_enable" onchange="onLdapStatusChange();">
387
								<option value="1"<?= ($ldap_status)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
387
								<option value="1"<?= ($ldap_status)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
388
								<option value="0"<?= (!$ldap_status) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
388
								<option value="0"<?= (!$ldap_status) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
389
							</select>
389
							</select>
390
						</dd>
390
						</dd>
391
					</dl>
391
					</dl>
392
					<dl>
392
					<dl>
393
						<dt>
393
						<dt>
394
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
394
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
395
							<?= $l_ldap_server_text ?>
395
							<?= $l_ldap_server_text ?>
396
						</dt>
396
						</dt>
397
						<dd>
397
						<dd>
398
							<input type="text" 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();">
399
						</dd>
399
						</dd>
400
					</dl>
400
					</dl>
401
					<dl>
401
					<dl>
402
						<dt>
402
						<dt>
403
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
403
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
404
							<?= $l_ldap_base_dn_text ?>
404
							<?= $l_ldap_base_dn_text ?>
405
						</dt>
405
						</dt>
406
						<dd>
406
						<dd>
407
							<input type="text" 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();">
408
						</dd>
408
						</dd>
409
					</dl>
409
					</dl>
410
					<dl>
410
					<dl>
411
						<dt>
411
						<dt>
412
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
412
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
413
							<?= $l_ldap_uid_text ?>
413
							<?= $l_ldap_uid_text ?>
414
						</dt>
414
						</dt>
415
						<dd>
415
						<dd>
416
							<input type="text" 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();">
417
						</dd>
417
						</dd>
418
					</dl>
418
					</dl>
419
					<dl>
419
					<dl>
420
						<dt>
420
						<dt>
421
							<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>
422
							<?= $l_ldap_base_filter_text ?>
422
							<?= $l_ldap_base_filter_text ?>
423
						</dt>
423
						</dt>
424
						<dd>
424
						<dd>
425
							<input type="text" 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();">
426
						</dd>
426
						</dd>
427
					</dl>
427
					</dl>
428
					<dl>
428
					<dl>
429
						<dt>
429
						<dt>
430
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
430
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
431
							<?= $l_ldap_user_text ?>
431
							<?= $l_ldap_user_text ?>
432
						</dt>
432
						</dt>
433
						<dd>
433
						<dd>
434
							<input type="text" 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();">
435
						</dd>
435
						</dd>
436
					</dl>
436
					</dl>
437
					<dl>
437
					<dl>
438
						<dt>
438
						<dt>
439
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
439
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
440
							<?= $l_ldap_password_text ?>
440
							<?= $l_ldap_password_text ?>
441
						</dt>
441
						</dt>
442
						<dd>
442
						<dd>
443
							<input type="text" 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();">
444
						</dd>
444
						</dd>
445
					</dl>
445
					</dl>
446
					<p>
446
					<p>
447
						<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>
447
						<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>
448
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit">
448
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit">
449
					</p>
449
					</p>
450
				</fieldset>
450
				</fieldset>
451
			</form>
451
			</form>
452
		</div>
452
		</div>
453
	</div>
453
	</div>
454
</body>
454
</body>
455
</html>
455
</html>
456
 
456