Subversion Repositories ALCASAR

Rev

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

Rev 2460 Rev 2461
1
<?php
1
<?php
2
# $Id: ldap.php 2460 2017-12-13 17:53:06Z tom.houdayer $
2
# $Id: ldap.php 2461 2017-12-14 23:01:41Z richard $
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 et vérifier";
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_ldap_push_config		= "Activer cette configuration";
77
	$l_check				= "Vérifier cette configuration";
78
} else {				// English
78
} else {				// English
79
	$l_ldap_update			= "LDAP settings updated";
79
	$l_ldap_update			= "LDAP settings updated";
80
	$l_ldap_title			= "External authentication : LDAP";
80
	$l_ldap_title			= "External authentication : LDAP";
81
	$l_ldap_legend			= "LDAP authentication";
81
	$l_ldap_legend			= "LDAP authentication";
82
	$l_ldap_auth_enable_label	= "Edit the LDAP configuration :";
82
	$l_ldap_auth_enable_label	= "Edit the LDAP configuration :";
83
	$l_ldap_YES			= "YES";
83
	$l_ldap_YES			= "YES";
84
	$l_ldap_NO			= "NO";
84
	$l_ldap_NO			= "NO";
85
	$l_ldap_server_label		= "LDAP server :";
85
	$l_ldap_server_label		= "LDAP server :";
86
	$l_ldap_server_text		= "IP address of the LDAP server.";
86
	$l_ldap_server_text		= "IP address of the LDAP server.";
87
	$l_ldap_base_dn_label		= "DN of the base:";
87
	$l_ldap_base_dn_label		= "DN of the base:";
88
	$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'";
88
	$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_uid_label		= "User IDentifier (UID):";
89
	$l_ldap_uid_label		= "User IDentifier (UID):";
90
	$l_ldap_uid_text		= "Key used to search for a given login identity.<br>e.g. 'uid', 'sn', etc.. For AD use 'sAMAccountName'.";
90
	$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_base_filter_label	= "User search filter (optional):";
91
	$l_ldap_base_filter_label	= "User search filter (optional):";
92
	$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))'";
92
	$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_user_label		= "CN of the user operated by ALCASAR:";
93
	$l_ldap_user_label		= "CN of the user operated by ALCASAR:";
94
	$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'";
94
	$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_password_label		= "Password:";
95
	$l_ldap_password_label		= "Password:";
96
	$l_ldap_password_text		= "Leave blank to use anonymous binding. Mandatory for AD.";
96
	$l_ldap_password_text		= "Leave blank to use anonymous binding. Mandatory for AD.";
97
	$l_ldap_submit			= "Save & Check";
97
	$l_ldap_submit			= "Save";
98
	$l_ldap_test_service_failed	= "LDAP service is not reachable on that server (check IP)";
98
	$l_ldap_test_service_failed	= "LDAP service is not reachable on that server (check IP)";
99
	$l_ldap_test_service_ok		= "A port 389 is open on this server";
99
	$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)";
100
	$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";
101
	$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)";
102
	$l_ldap_test_bind_failed	= "LDAP authentication failed (check the LDAP user and password)";
103
	$l_ldap_test_bind_ok		= "Successful authentication";
103
	$l_ldap_test_bind_ok		= "Successful authentication";
104
	$l_ldap_test_dn_failed          = "DN of the base seems to be wrong (check it)";
104
	$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";
105
	$l_ldap_test_dn_ok              = "DN of the base seems to be ok";
106
	$l_ldap_error			= "LDAP error";
106
	$l_ldap_error			= "LDAP error";
107
	$l_ldap_entries			= "entries in the base";
107
	$l_ldap_entries			= "entries in the base";
108
	$l_ldap_push_config		= "Activate this configuration";
108
	$l_check				= "Check this config";
109
}
109
}
110
 
110
 
111
 
111
 
112
function ldap_checkServerConfig($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_basedn, $f_ldap_uid, $f_ldap_port = 389) {
112
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
113
	// Socket to the LDAP port of the server
114
	if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
114
	if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
115
		// no network connection
115
		// no network connection
116
		return -2;
116
		return -2;
117
	}
117
	}
118
	fclose($sock);
118
	fclose($sock);
119
 
119
 
120
	// if ok, Test LDAP connection
120
	// if ok, Test LDAP connection
121
	$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
121
	$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
122
	ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
122
	ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
123
	if (!$ldapconn) {
123
	if (!$ldapconn) {
124
		// LDAP connection failed
124
		// LDAP connection failed
125
		return -1;
125
		return -1;
126
	}
126
	}
127
 
127
 
128
	// if ok, test a ldap-bind with the user used by ALCASAR
128
	// if ok, test a ldap-bind with the user used by ALCASAR
129
	$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
129
	$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
130
	if (!$ldapbind) {
130
	if (!$ldapbind) {
131
		// Test LDAP Version 3
131
		// Test LDAP Version 3
132
		ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
132
		ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
133
		$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
133
		$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
134
		if (!$ldapbind) {
134
		if (!$ldapbind) {
135
			// LDAP Bind failed
135
			// LDAP Bind failed
136
			return 0;
136
			return 0;
137
		}
137
		}
138
	}
138
	}
139
 
139
 
140
	// if ok, try to query the directory of users
140
	// if ok, try to query the directory of users
141
	$query = $f_ldap_uid."=*";
141
	$query = $f_ldap_uid."=*";
142
	$ldap_result = ldap_search($ldapconn, $f_ldap_basedn, $query);
142
	$ldap_result = ldap_search($ldapconn, $f_ldap_basedn, $query);
143
	if (ldap_search($ldapconn, $f_ldap_basedn, $query)) {
143
	if (ldap_search($ldapconn, $f_ldap_basedn, $query)) {
144
		$ldap_users_count = ldap_count_entries($ldapconn, $ldap_result);
144
		$ldap_users_count = ldap_count_entries($ldapconn, $ldap_result);
145
		return ($ldap_users_count + 2);
145
		return ($ldap_users_count + 2);
146
	} else {
146
	} else {
147
		return 1;
147
		return 1;
148
	}
148
	}
149
	ldap_unbind($ldapconn);
149
	ldap_unbind($ldapconn);
150
}
150
}
151
 
151
 
152
$messages = '';
152
$messages = '';
153
 
153
 
154
if (isset($_POST['auth_enable'])) {
154
if (isset($_POST['auth_enable'])) {
155
	if ($_POST['auth_enable'] === '1') {
155
	if ($_POST['auth_enable'] === '1') {
156
		$varErrors = [];
156
		$varErrors = [];
157
		if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');
157
		if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');
158
		if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');
158
		if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');
159
		if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');
159
		if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');
160
		if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');
160
		if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');
161
		if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');
161
		if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');
162
		if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');
162
		if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');
163
 
163
 
164
		// Validation
164
		// Validation
165
		if (isset($ldap_server)) {
165
		if (isset($ldap_server)) {
166
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
166
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
167
				$ldap_server = gethostbyname($ldap_server);
167
				$ldap_server = gethostbyname($ldap_server);
168
			}
168
			}
169
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
169
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
170
				array_push($varErrors, 'Invalid LDAP server IP');
170
				array_push($varErrors, 'Invalid LDAP server IP');
171
			}
171
			}
172
		}
172
		}
173
 
173
 
174
		if (!empty($varErrors)) { 
174
		if (!empty($varErrors)) { 
175
			foreach ($varErrors as $error) {
175
			foreach ($varErrors as $error) {
176
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
176
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
177
			}
177
			}
178
		} else {
178
		} else {
179
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
179
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
180
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
180
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
181
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
181
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
182
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
182
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
183
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
183
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
184
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
184
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
185
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
185
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
186
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
186
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
187
 
-
 
188
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
187
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
189
		}
188
		}
190
	} else {
189
	} else {
191
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
190
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
192
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
191
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
193
 
-
 
194
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
192
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
195
	}
193
	}
196
 
194
 
197
	// Reload configuration
195
	// Reload configuration
198
	$file_conf = fopen(CONF_FILE, 'r');
196
	$file_conf = fopen(CONF_FILE, 'r');
199
	if (!$file_conf) {
197
	if (!$file_conf) {
200
		exit('Error opening the file '.CONF_FILE);
198
		exit('Error opening the file '.CONF_FILE);
201
	}
199
	}
202
	while (!feof($file_conf)) {
200
	while (!feof($file_conf)) {
203
		$buffer = fgets($file_conf, 4096);
201
		$buffer = fgets($file_conf, 4096);
204
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
202
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
205
			$tmp = explode('=', $buffer, 2);
203
			$tmp = explode('=', $buffer, 2);
206
			$conf[trim($tmp[0])] = trim($tmp[1]);
204
			$conf[trim($tmp[0])] = trim($tmp[1]);
207
		}
205
		}
208
	}
206
	}
209
	fclose($file_conf);
207
	fclose($file_conf);
210
}
208
}
211
 
209
 
212
// LDAP configuration params
210
// LDAP configuration params
213
$ldap_status      = ($conf['LDAP'] === 'on');
211
$ldap_status      = ($conf['LDAP'] === 'on');
214
$ldap_server      = $conf['LDAP_SERVER'];
212
$ldap_server      = $conf['LDAP_SERVER'];
215
$ldap_user        = $conf['LDAP_USER'];
213
$ldap_user        = $conf['LDAP_USER'];
216
$ldap_password    = $conf['LDAP_PASSWORD'];
214
$ldap_password    = $conf['LDAP_PASSWORD'];
217
$ldap_base_dn     = $conf['LDAP_BASE'];
215
$ldap_base_dn     = $conf['LDAP_BASE'];
218
$ldap_uid	  = $conf['LDAP_UID'];
216
$ldap_uid	  = $conf['LDAP_UID'];
219
$ldap_base_filter = $conf['LDAP_FILTER'];
217
$ldap_base_filter = $conf['LDAP_FILTER'];
220
 
218
 
221
// TODO : check LDAP PHP extension loaded?
219
// TODO : check LDAP PHP extension loaded?
222
// if (!extension_loaded('ldap')) {
220
// if (!extension_loaded('ldap')) {
223
// 	exit();
221
// 	exit();
224
// }
222
// }
225
 
223
 
226
$pos = strpos($ldap_server, '//');
224
$pos = strpos($ldap_server, '//');
227
if ($pos !== false) {
225
if ($pos !== false) {
228
	// TODO : useless?
226
	// TODO : useless?
229
	$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"
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"
230
} else {
228
} else {
231
	$new_ldap_server = $ldap_server;
229
	$new_ldap_server = $ldap_server;
232
}
230
}
233
 
231
 
234
// AJAX LDAP configuration checker
232
// AJAX LDAP configuration checker
235
if (isset($_GET['conf_check'])) {
233
if (isset($_GET['conf_check'])) {
236
	$response = [
234
	$response = [
237
		'enable' => $ldap_status
235
		'enable' => $ldap_status
238
	];
236
	];
239
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
237
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
240
		$varErrors = [];
238
		$varErrors = [];
241
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
239
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
242
			if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');		// TODO: need to translate
240
			if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');		// TODO: need to translate
243
			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
241
			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
244
			if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');		// TODO: need to translate
242
			if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');		// TODO: need to translate
245
			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
243
			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
246
			if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');		// TODO: need to translate
244
			if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');		// TODO: need to translate
247
			if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');		// TODO: need to translate
245
			if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');		// TODO: need to translate
248
		}
246
		}
249
 
247
 
250
		// Validation
248
		// Validation
251
		if (isset($ldap_server)) {
249
		if (isset($ldap_server)) {
252
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
250
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
253
				$ldap_server = gethostbyname($ldap_server);
251
				$ldap_server = gethostbyname($ldap_server);
254
			}
252
			}
255
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
253
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
256
				array_push($varErrors, 'Invalid LDAP server IP');	// TODO: need to translate
254
				array_push($varErrors, 'Invalid LDAP server IP');	// TODO: need to translate
257
			}
255
			}
258
		}
256
		}
259
 
257
 
260
		if (!empty($varErrors)) {
258
		if (!empty($varErrors)) {
261
			$response['errors'] = $varErrors;
259
			$response['errors'] = $varErrors;
262
		} else {
260
		} else {
263
			$response['result'] = ldap_checkServerConfig($ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_uid);
261
			$response['result'] = ldap_checkServerConfig($ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_uid);
264
		}
262
		}
265
	}
263
	}
266
 
264
 
267
	header('Content-Type: application/json');
265
	header('Content-Type: application/json');
268
	echo json_encode($response);
266
	echo json_encode($response);
269
	exit();
267
	exit();
270
}
268
}
271
 
269
 
272
?>
270
?>
273
<!DOCTYPE html>
271
<!DOCTYPE html>
274
<html>
272
<html>
275
<head>
273
<head>
276
	<meta charset="UTF-8">
274
	<meta charset="UTF-8">
277
	<title><?= $l_ldap_title ?></title>
275
	<title><?= $l_ldap_title ?></title>
278
	<link type="text/css" href="/css/style.css" rel="stylesheet">
276
	<link type="text/css" href="/css/style.css" rel="stylesheet">
279
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
277
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
280
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
278
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
281
	<script>
279
	<script>
282
	function onPageLoad() {
280
	function onPageLoad() {
283
		onLdapStatusChange();
281
		onLdapStatusChange();
284
		if (document.getElementById('auth_enable').value === '1') {
282
		if (document.getElementById('auth_enable').value === '1') {
285
			checkConfig();
283
			checkConfig();
286
		}
284
		}
287
	}
285
	}
288
 
286
 
289
	function onLdapStatusChange() {
287
	function onLdapStatusChange() {
290
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password'];
288
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password'];
291
		var formSubmit = document.querySelector('form input[type="submit"]');
289
		var formSubmit = document.querySelector('form input[type="submit"]');
292
		var btn_checkConf = document.getElementById('btn-checkconf');
290
		var btn_checkConf = document.getElementById('btn-checkconf');
293
		var isChecked = false;
291
		var isChecked = false;
294
 
292
 
295
		if (document.getElementById('auth_enable').value === '1') {
293
		if (document.getElementById('auth_enable').value === '1') {
296
			for (var i=0; i<listToDisables.length; i++) {
294
			for (var i=0; i<listToDisables.length; i++) {
297
				document.getElementById(listToDisables[i]).style.backgroundColor = '#ffffff';
295
				document.getElementById(listToDisables[i]).style.backgroundColor = '#ffffff';
298
				document.getElementById(listToDisables[i]).disabled = false;
296
				document.getElementById(listToDisables[i]).disabled = false;
299
			}
297
			}
300
			formSubmit.style.display = 'none';
298
			formSubmit.style.display = 'none';
301
			btn_checkConf.style.display = null;
299
			btn_checkConf.style.display = null;
302
		} else {
300
		} else {
303
			for (var i=0; i<listToDisables.length; i++) {
301
			for (var i=0; i<listToDisables.length; i++) {
304
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
302
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
305
				document.getElementById(listToDisables[i]).disabled = true;
303
				document.getElementById(listToDisables[i]).disabled = true;
306
			}
304
			}
307
			formSubmit.style.display = null;
305
			formSubmit.style.display = null;
308
			btn_checkConf.style.display = 'none';
306
			btn_checkConf.style.display = 'none';
309
		}
307
		}
310
	}
308
	}
311
 
309
 
312
	function checkConfig() {
310
	function checkConfig() {
313
		var messagesElem = document.querySelector('fieldset > legend > div:last-child');
311
		var messagesElem = document.querySelector('fieldset > legend > div:last-child');
314
		var formSubmit   = document.querySelector('form input[type="submit"]');
312
		var formSubmit   = document.querySelector('form input[type="submit"]');
315
		var btn_checkConf = document.getElementById('btn-checkconf');
313
		var btn_checkConf = document.getElementById('btn-checkconf');
316
 
314
 
317
		var ldap_config = {
315
		var ldap_config = {
318
			ldap_status:     (document.getElementById('auth_enable').value === '1'),
316
			ldap_status:     (document.getElementById('auth_enable').value === '1'),
319
			ldap_server:      document.getElementById('ldap_server').value,
317
			ldap_server:      document.getElementById('ldap_server').value,
320
			ldap_user:        document.getElementById('ldap_user').value,
318
			ldap_user:        document.getElementById('ldap_user').value,
321
			ldap_password:    document.getElementById('ldap_password').value,
319
			ldap_password:    document.getElementById('ldap_password').value,
322
			ldap_base_dn:     document.getElementById('ldap_dn').value,
320
			ldap_base_dn:     document.getElementById('ldap_dn').value,
323
			ldap_uid:         document.getElementById('ldap_uid').value,
321
			ldap_uid:         document.getElementById('ldap_uid').value,
324
			ldap_base_filter: document.getElementById('ldap_base_filter').value
322
			ldap_base_filter: document.getElementById('ldap_base_filter').value
325
		};
323
		};
326
 
324
 
327
		var params = Object.keys(ldap_config).map( function (k) { return encodeURIComponent(k) + '=' + encodeURIComponent(ldap_config[k]) } ).join('&');
325
		var params = Object.keys(ldap_config).map( function (k) { return encodeURIComponent(k) + '=' + encodeURIComponent(ldap_config[k]) } ).join('&');
328
 
326
 
329
		messagesElem.innerHTML = '<?= 'Checking configuration...' /* TODO: need to translate */ ?>';
327
		messagesElem.innerHTML = '<?= 'Checking configuration...' /* TODO: need to translate */ ?>';
330
 
328
 
331
		var xhr = new XMLHttpRequest();
329
		var xhr = new XMLHttpRequest();
332
		xhr.onreadystatechange = function() {
330
		xhr.onreadystatechange = function() {
333
			if (this.readyState == 4) {
331
			if (this.readyState == 4) {
334
				if (this.status == 200) {
332
				if (this.status == 200) {
335
					var data = JSON.parse(this.responseText);
333
					var data = JSON.parse(this.responseText);
336
 
334
 
337
					var messages = '';
335
					var messages = '';
338
 
336
 
339
					if (typeof data.result !== 'undefined') {
337
					if (typeof data.result !== 'undefined') {
340
						if (data.result === -2) {
338
						if (data.result === -2) {
341
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
339
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
342
						} else {
340
						} else {
343
							messages += "<span style=\"color: green\"><?= $l_ldap_test_service_ok ?></span>";
341
							messages += "<span style=\"color: green\"><?= $l_ldap_test_service_ok ?></span>";
344
							if (data.result === -1) {
342
							if (data.result === -1) {
345
								messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
343
								messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
346
							} else {
344
							} else {
347
								messages += "<br><span style=\"color: green\"><?= $l_ldap_test_connection_ok ?></span>";
345
								messages += "<br><span style=\"color: green\"><?= $l_ldap_test_connection_ok ?></span>";
348
								if (data.result === 0) {
346
								if (data.result === 0) {
349
									messages += "<br><span style=\"color: red\"><?= $l_ldap_test_bind_failed ?></span>";
347
									messages += "<br><span style=\"color: red\"><?= $l_ldap_test_bind_failed ?></span>";
350
								} else {
348
								} else {
351
									messages += "<br><span style=\"color: green\"><?= $l_ldap_test_bind_ok ?></span>";
349
									messages += "<br><span style=\"color: green\"><?= $l_ldap_test_bind_ok ?></span>";
352
									if (data.result === 1) {
350
									if (data.result === 1) {
353
										messages += "<br><span style=\"color: red\"><?= $l_ldap_test_dn_failed ?></span>";
351
										messages += "<br><span style=\"color: red\"><?= $l_ldap_test_dn_failed ?></span>";
354
									} else {
352
									} else {
355
										messages += "<br><span style=\"color: green\"><?= $l_ldap_test_dn_ok ?> (" + (data.result - 2) + " <?= $l_ldap_entries?>)</span>";
353
										messages += "<br><span style=\"color: green\"><?= $l_ldap_test_dn_ok ?> (" + (data.result - 2) + " <?= $l_ldap_entries?>)</span>";
356
									}
354
									}
357
								}
355
								}
358
							}
356
							}
359
						}
357
						}
360
					}
358
					}
361
 
359
 
362
					if (data.result > 1) {
360
					if (data.result > 1) {
363
						formSubmit.style.display = null;
361
						formSubmit.style.display = null;
364
						btn_checkConf.style.display = 'none';
362
						btn_checkConf.style.display = 'none';
365
					} else {
363
					} else {
366
						formSubmit.style.display = 'none';
364
						formSubmit.style.display = 'none';
367
						btn_checkConf.style.display = null;
365
						btn_checkConf.style.display = null;
368
					}
366
					}
369
 
367
 
370
					if (typeof data.errors !== 'undefined') {
368
					if (typeof data.errors !== 'undefined') {
371
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
369
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
372
					}
370
					}
373
 
371
 
374
					messagesElem.innerHTML = messages;
372
					messagesElem.innerHTML = messages;
375
				} else {
373
				} else {
376
					messagesElem.innerHTML = 'server error';
374
					messagesElem.innerHTML = 'server error';
377
				}
375
				}
378
			}
376
			}
379
		};
377
		};
380
		xhr.open('POST', 'ldap.php?conf_check', true);
378
		xhr.open('POST', 'ldap.php?conf_check', true);
381
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
379
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
382
		xhr.send(params);
380
		xhr.send(params);
383
	}
381
	}
384
	</script>
382
	</script>
385
</head>
383
</head>
386
<body onLoad="onPageLoad();">
384
<body onLoad="onPageLoad();">
387
	<div class="panel">
385
	<div class="panel">
388
		<div class="panel-header"><?= $l_ldap_legend ?></div>
386
		<div class="panel-header"><?= $l_ldap_legend ?></div>
389
		<div class="panel-body">
387
		<div class="panel-body">
390
			<form name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
388
			<form name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
391
				<fieldset>
389
				<fieldset>
392
					<legend>
390
					<legend>
393
						<br>
391
						<br>
394
						<div style="text-align: center">
392
						<div style="text-align: center">
395
							<?php if ($messages): ?>
393
							<?php if ($messages): ?>
396
								<?= $messages ?>
394
								<?= $messages ?>
397
							<?php endif; ?>
395
							<?php endif; ?>
398
						</div>
396
						</div>
399
						<div style="text-align: center"></div>
397
						<div style="text-align: center"></div>
400
					</legend>
398
					</legend>
401
					<dl>
399
					<dl>
402
						<dt>
400
						<dt>
403
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
401
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
404
						</dt>
402
						</dt>
405
						<dd>
403
						<dd>
406
							<select id="auth_enable" name="auth_enable" onchange="onLdapStatusChange();">
404
							<select id="auth_enable" name="auth_enable" onchange="onLdapStatusChange();">
407
								<option value="1"<?= ($ldap_status)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
405
								<option value="1"<?= ($ldap_status)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
408
								<option value="0"<?= (!$ldap_status) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
406
								<option value="0"<?= (!$ldap_status) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
409
							</select>
407
							</select>
410
						</dd>
408
						</dd>
411
					</dl>
409
					</dl>
412
					<dl>
410
					<dl>
413
						<dt>
411
						<dt>
414
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
412
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
415
							<?= $l_ldap_server_text ?>
413
							<?= $l_ldap_server_text ?>
416
						</dt>
414
						</dt>
417
						<dd>
415
						<dd>
418
							<input id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>" oninput="onLdapStatusChange();">
416
							<input id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>" oninput="onLdapStatusChange();">
419
						</dd>
417
						</dd>
420
					</dl>
418
					</dl>
421
					<dl>
419
					<dl>
422
						<dt>
420
						<dt>
423
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
421
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
424
							<?= $l_ldap_base_dn_text ?>
422
							<?= $l_ldap_base_dn_text ?>
425
						</dt>
423
						</dt>
426
						<dd>
424
						<dd>
427
							<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>" oninput="onLdapStatusChange();">
425
							<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>" oninput="onLdapStatusChange();">
428
						</dd>
426
						</dd>
429
					</dl>
427
					</dl>
430
					<dl>
428
					<dl>
431
						<dt>
429
						<dt>
432
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
430
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
433
							<?= $l_ldap_uid_text ?>
431
							<?= $l_ldap_uid_text ?>
434
						</dt>
432
						</dt>
435
						<dd>
433
						<dd>
436
							<input id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>" oninput="onLdapStatusChange();">
434
							<input id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>" oninput="onLdapStatusChange();">
437
						</dd>
435
						</dd>
438
					</dl>
436
					</dl>
439
					<dl>
437
					<dl>
440
						<dt>
438
						<dt>
441
							<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
439
							<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
442
							<?= $l_ldap_base_filter_text ?>
440
							<?= $l_ldap_base_filter_text ?>
443
						</dt>
441
						</dt>
444
						<dd>
442
						<dd>
445
							<input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>" oninput="onLdapStatusChange();">
443
							<input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>" oninput="onLdapStatusChange();">
446
						</dd>
444
						</dd>
447
					</dl>
445
					</dl>
448
					<dl>
446
					<dl>
449
						<dt>
447
						<dt>
450
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
448
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
451
							<?= $l_ldap_user_text ?>
449
							<?= $l_ldap_user_text ?>
452
						</dt>
450
						</dt>
453
						<dd>
451
						<dd>
454
							<input id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>" oninput="onLdapStatusChange();">
452
							<input id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>" oninput="onLdapStatusChange();">
455
						</dd>
453
						</dd>
456
					</dl>
454
					</dl>
457
					<dl>
455
					<dl>
458
						<dt>
456
						<dt>
459
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
457
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
460
							<?= $l_ldap_password_text ?>
458
							<?= $l_ldap_password_text ?>
461
						</dt>
459
						</dt>
462
						<dd>
460
						<dd>
463
							<input id="ldap_password" type="password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>" oninput="onLdapStatusChange();">
461
							<input id="ldap_password" type="password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>" oninput="onLdapStatusChange();">
464
						</dd>
462
						</dd>
465
					</dl>
463
					</dl>
466
					<p>
464
					<p>
467
						<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= 'Check' /* TODO: need to translate */ ?></button>
465
						<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>
468
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit" title="<?= 'You need to check before submit'  /* TODO: need to translate */ ?>">
466
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit" title="<?= 'You need to check before submit'  /* TODO: need to translate */ ?>">
469
					</p>
467
					</p>
470
				</fieldset>
468
				</fieldset>
471
			</form>
469
			</form>
472
		</div>
470
		</div>
473
	</div>
471
	</div>
474
</body>
472
</body>
475
</html>
473
</html>
476
 
474