Subversion Repositories ALCASAR

Rev

Rev 2853 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2853 Rev 3108
1
<?php
1
<?php
2
# $Id: ldap.php 2853 2020-07-19 21:50:07Z rexy $
2
# $Id: ldap.php 3108 2023-01-08 21:46:19Z 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
*****************************************************************/
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') {
47
if ($Language === 'fr') {
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_ssl_label		= "Connexion chiffré";
66
	$l_ldap_ssl_label		= "Connexion chiffrée";
67
	$l_ldap_ssl_text		= "Utiliser une connexion chiffré avec SSL (LDAPS)";
67
	$l_ldap_ssl_text		= "Utiliser une connexion chiffré avec SSL (LDAPS)";
68
	$l_ldap_cert_required_label	= "Vérifier le certificat SSL";
68
	$l_ldap_cert_required_label	= "Vérifier le certificat SSL";
69
	$l_ldap_cert_required_text	= "Vérifier que le serveur LDAP utilise un certificat connu";
69
	$l_ldap_cert_required_text	= "Vérifier que le serveur LDAP utilise un certificat connu";
70
	$l_ldap_cert_label		= "Certificat SSL (CA)";
70
	$l_ldap_cert_label		= "Certificat SSL (CA)";
71
	$l_ldap_cert_text		= "Certificat de l'authorité de certification signant celui du serveur LDAP";
71
	$l_ldap_cert_text		= "Certificat de l'authorité de certification signant celui du serveur LDAP";
72
	$l_ad_dns_domain_label		= "Nom de domaine interne";
72
	$l_ad_dns_domain_label		= "Nom de domaine interne";
73
	$l_ad_dns_domain_text		= "Nom de domaine qui sera redirigé vers le serveur DNS de l'annuaire LDAP (vide pour désactivé)";
73
	$l_ad_dns_domain_text		= "Nom de domaine qui sera redirigé vers le serveur DNS de l'annuaire LDAP (vide pour désactivé)";
74
	$l_ldap_cert_status_cur		= "Certificat actuel : ";
74
	$l_ldap_cert_status_cur		= "Certificat actuel : ";
75
	$l_ldap_cert_status_no		= "Aucun certificat installé";
75
	$l_ldap_cert_status_no		= "Aucun certificat installé";
76
	$l_ldap_submit			= "Enregistrer";
76
	$l_ldap_submit			= "Enregistrer";
77
	$l_ldap_test_service_failed	= "Service LDAP injoignable sur ce serveur (vérifiez l'@IP).";
77
	$l_ldap_test_service_failed	= "Service LDAP injoignable sur ce serveur (vérifiez l'@IP).";
78
	$l_ldap_test_service_ok		= "Un port 389 (636 avec SSL) est actif sur ce serveur";
78
	$l_ldap_test_service_ok		= "Un port 389 (636 avec SSL) est actif sur ce serveur";
79
	$l_ldap_test_connection_failed	= "Connexion LDAP impossible (vérifiez le service LDAP sur ce serveur)";
79
	$l_ldap_test_connection_failed	= "Connexion LDAP impossible (vérifiez le service LDAP sur ce serveur)";
80
	$l_ldap_test_connection_ok	= "Une connexion LDAP a été établie";
80
	$l_ldap_test_connection_ok	= "Une connexion LDAP a été établie";
81
	$l_ldap_test_bind_failed	= "Echec d'authentification (vérifiez l'utilisateur et le mot de passe)";
81
	$l_ldap_test_bind_failed	= "Echec d'authentification (vérifiez l'utilisateur et le mot de passe)";
82
	$l_ldap_test_bind_ok		= "L'authentification a réussie";
82
	$l_ldap_test_bind_ok		= "L'authentification a réussie";
83
	$l_ldap_test_dn_failed		= "Le DN de la base semble incorrect (vérifiez le)";
83
	$l_ldap_test_dn_failed		= "Le DN de la base semble incorrect (vérifiez le)";
84
	$l_ldap_test_dn_ok		= "Le DN de la base semble correct";
84
	$l_ldap_test_dn_ok		= "Le DN de la base semble correct";
85
	$l_ldap_error			= "erreur LDAP";
85
	$l_ldap_error			= "erreur LDAP";
86
	$l_ldap_entries			= "entrées dans la base";
86
	$l_ldap_entries			= "entrées dans la base";
87
	$l_ldap_cert_cn_diff_dn		= "Le CommonName du certificat (§cert_domainName§) est différent du nom de domaine du serveur";
87
	$l_ldap_cert_cn_diff_dn		= "Le CommonName du certificat (§cert_domainName§) est différent du nom de domaine du serveur";
88
	$l_check			= "Vérifier cette configuration";
88
	$l_check			= "Vérifier cette configuration";
89
	$l_checkingConf			= "Vérification de cette configuration...";
89
	$l_checkingConf			= "Vérification de cette configuration...";
90
} else if ($Language === 'es') {
90
} else if ($Language === 'es') {
91
	$l_ldap_update			= "Configuración de LDAP actualizada";
91
	$l_ldap_update			= "Configuración de LDAP actualizada";
92
	$l_ldap_title			= "Autenticación externa : LDAP";
92
	$l_ldap_title			= "Autenticación externa : LDAP";
93
	$l_ldap_legend			= "LDAP autenticación";
93
	$l_ldap_legend			= "LDAP autenticación";
94
	$l_ldap_auth_enable_label	= "Editar la configuración LDAP:";
94
	$l_ldap_auth_enable_label	= "Editar la configuración LDAP:";
95
	$l_ldap_YES			= "SI";
95
	$l_ldap_YES			= "SI";
96
	$l_ldap_NO			= "NO";
96
	$l_ldap_NO			= "NO";
97
	$l_ldap_server_label		= "Servidor LDAP:";
97
	$l_ldap_server_label		= "Servidor LDAP:";
98
	$l_ldap_server_text		= "Dirección IP del servidor LDAP.";
98
	$l_ldap_server_text		= "Dirección IP del servidor LDAP.";
99
	$l_ldap_base_dn_label		= "DN de la base:";
99
	$l_ldap_base_dn_label		= "DN de la base:";
100
	$l_ldap_base_dn_text		= "El DN (Distinguished Name) se utiliza para ubicar la información de los usuarios en el directorio.<br> e.g. LDAP : 'o=MiEmpresa,c=AR'.<br> e.g. AD : 'cn=Users,dc=nombre_servidor,dc=localdomain'";
100
	$l_ldap_base_dn_text		= "El DN (Distinguished Name) se utiliza para ubicar la información de los usuarios en el directorio.<br> e.g. LDAP : 'o=MiEmpresa,c=AR'.<br> e.g. AD : 'cn=Users,dc=nombre_servidor,dc=localdomain'";
101
	$l_ldap_uid_label		= "Identificador de usuario (UID):";
101
	$l_ldap_uid_label		= "Identificador de usuario (UID):";
102
	$l_ldap_uid_text		= "Clave utilizada para buscar una identidad de inicio de sesión determinada.<br>Ej. 'uid', 'sn', etc.. Para AD usar 'sAMAccountName'.";
102
	$l_ldap_uid_text		= "Clave utilizada para buscar una identidad de inicio de sesión determinada.<br>Ej. 'uid', 'sn', etc.. Para AD usar 'sAMAccountName'.";
103
	$l_ldap_base_filter_label	= "Filtro de búsqueda de usuario (opcional):";
103
	$l_ldap_base_filter_label	= "Filtro de búsqueda de usuario (opcional):";
104
	$l_ldap_base_filter_text	= "Puede limitar aún más los objetos buscados con filtros adicionales.<br> Por ejemplo'objectClass=posixGroup' daría como resultado el uso de '(&amp;(uid=username)(objectClass=posixGroup))'";
104
	$l_ldap_base_filter_text	= "Puede limitar aún más los objetos buscados con filtros adicionales.<br> Por ejemplo'objectClass=posixGroup' daría como resultado el uso de '(&amp;(uid=username)(objectClass=posixGroup))'";
105
	$l_ldap_user_label		= "CN del usuario operador ALCASAR:";
105
	$l_ldap_user_label		= "CN del usuario operador ALCASAR:";
106
	$l_ldap_user_text		= "CN=Common Name. Déjelo en blanco para enlace anónimo. Obligatorio para AD.<br> Ej. LDAP :'uid=Usuario,ou=mi_Red,o=miEmpresa,c=AR'.<br> Ej. AD : 'username' or 'cn=username,cn=Users,dc=server_name,dc=localdomain'";
106
	$l_ldap_user_text		= "CN=Common Name. Déjelo en blanco para enlace anónimo. Obligatorio para AD.<br> Ej. LDAP :'uid=Usuario,ou=mi_Red,o=miEmpresa,c=AR'.<br> Ej. AD : 'username' or 'cn=username,cn=Users,dc=server_name,dc=localdomain'";
107
	$l_ldap_password_label		= "Contraseña:";
107
	$l_ldap_password_label		= "Contraseña:";
108
	$l_ldap_password_text		= "Déjelo en blanco para usar un enlace anónimo. Obligatorio para AD.";
108
	$l_ldap_password_text		= "Déjelo en blanco para usar un enlace anónimo. Obligatorio para AD.";
109
	$l_ldap_ssl_label		= "Conexión segura";
109
	$l_ldap_ssl_label		= "Conexión segura";
110
	$l_ldap_ssl_text		= "Use una conexión encriptada con SSL (LDAPS)";
110
	$l_ldap_ssl_text		= "Use una conexión encriptada con SSL (LDAPS)";
111
	$l_ldap_cert_required_label	= "Comprueba el certificado SSL";
111
	$l_ldap_cert_required_label	= "Comprueba el certificado SSL";
112
	$l_ldap_cert_required_text	= "Verifique que el servidor LDAP use un certificado confiable";
112
	$l_ldap_cert_required_text	= "Verifique que el servidor LDAP use un certificado confiable";
113
	$l_ldap_cert_label		= "Certificado (CA) SSL";
113
	$l_ldap_cert_label		= "Certificado (CA) SSL";
114
	$l_ldap_cert_text		= "Certificado de la autoridad de certificación que firmó el certificado del servidor LDAP";
114
	$l_ldap_cert_text		= "Certificado de la autoridad de certificación que firmó el certificado del servidor LDAP";
115
	$l_ad_dns_domain_label		= "Nombre de dominio interno";
115
	$l_ad_dns_domain_label		= "Nombre de dominio interno";
116
	$l_ad_dns_domain_text		= "Nombre de dominio que se reenviará al servidor DNS del directorio LDAP (vacío para desactivar)";
116
	$l_ad_dns_domain_text		= "Nombre de dominio que se reenviará al servidor DNS del directorio LDAP (vacío para desactivar)";
117
	$l_ldap_cert_status_cur		= "Certificado actual:";
117
	$l_ldap_cert_status_cur		= "Certificado actual:";
118
	$l_ldap_cert_status_no		= "Ningún certificado importado";
118
	$l_ldap_cert_status_no		= "Ningún certificado importado";
119
	$l_ldap_submit			= "Guardar";
119
	$l_ldap_submit			= "Guardar";
120
	$l_ldap_test_service_failed	= "El servicio LDAP no es accesible en ese servidor (verifique la IP)";
120
	$l_ldap_test_service_failed	= "El servicio LDAP no es accesible en ese servidor (verifique la IP)";
121
	$l_ldap_test_service_ok		= "El puerto 389 (636 con SSL) está abierto en este servidor";
121
	$l_ldap_test_service_ok		= "El puerto 389 (636 con SSL) está abierto en este servidor";
122
	$l_ldap_test_connection_failed	= "La conexión LDAP falló (verifique el servicio LDAP en este servidor)";
122
	$l_ldap_test_connection_failed	= "La conexión LDAP falló (verifique el servicio LDAP en este servidor)";
123
	$l_ldap_test_connection_ok	= "Se establece una conexión LDAP";
123
	$l_ldap_test_connection_ok	= "Se establece una conexión LDAP";
124
	$l_ldap_test_bind_failed	= "La autenticación LDAP falló (verifique el usuario LDAP y la contraseña)";
124
	$l_ldap_test_bind_failed	= "La autenticación LDAP falló (verifique el usuario LDAP y la contraseña)";
125
	$l_ldap_test_bind_ok		= "Autenticación exitosa";
125
	$l_ldap_test_bind_ok		= "Autenticación exitosa";
126
	$l_ldap_test_dn_failed		= "DN de la base parece ser erróneo (verifíquelo)";
126
	$l_ldap_test_dn_failed		= "DN de la base parece ser erróneo (verifíquelo)";
127
	$l_ldap_test_dn_ok		= "DN de la base parece estar bien";
127
	$l_ldap_test_dn_ok		= "DN de la base parece estar bien";
128
	$l_ldap_error			= "error LDAP";
128
	$l_ldap_error			= "error LDAP";
129
	$l_ldap_entries			= "entradas en la base";
129
	$l_ldap_entries			= "entradas en la base";
130
	$l_ldap_cert_cn_diff_dn		= "El CommonName del certificado (§cert_domainName§) es diferente del nombre de dominio del servidor";
130
	$l_ldap_cert_cn_diff_dn		= "El CommonName del certificado (§cert_domainName§) es diferente del nombre de dominio del servidor";
131
	$l_check			= "Verifique éste paramétro";
131
	$l_check			= "Verifique éste paramétro";
132
	$l_checkingConf			= "Verificando ésta configuración...";
132
	$l_checkingConf			= "Verificando ésta configuración...";
133
} else {
133
} else {
134
	$l_ldap_update			= "LDAP settings updated";
134
	$l_ldap_update			= "LDAP settings updated";
135
	$l_ldap_title			= "External authentication : LDAP";
135
	$l_ldap_title			= "External authentication : LDAP";
136
	$l_ldap_legend			= "LDAP authentication";
136
	$l_ldap_legend			= "LDAP authentication";
137
	$l_ldap_auth_enable_label	= "Edit the LDAP configuration :";
137
	$l_ldap_auth_enable_label	= "Edit the LDAP configuration :";
138
	$l_ldap_YES			= "YES";
138
	$l_ldap_YES			= "YES";
139
	$l_ldap_NO			= "NO";
139
	$l_ldap_NO			= "NO";
140
	$l_ldap_server_label		= "LDAP server :";
140
	$l_ldap_server_label		= "LDAP server :";
141
	$l_ldap_server_text		= "IP address of the LDAP server.";
141
	$l_ldap_server_text		= "IP address of the LDAP server.";
142
	$l_ldap_base_dn_label		= "DN of the base:";
142
	$l_ldap_base_dn_label		= "DN of the base:";
143
	$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'";
143
	$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'";
144
	$l_ldap_uid_label		= "User IDentifier (UID):";
144
	$l_ldap_uid_label		= "User IDentifier (UID):";
145
	$l_ldap_uid_text		= "Key used to search for a given login identity.<br>e.g. 'uid', 'sn', etc.. For AD use 'sAMAccountName'.";
145
	$l_ldap_uid_text		= "Key used to search for a given login identity.<br>e.g. 'uid', 'sn', etc.. For AD use 'sAMAccountName'.";
146
	$l_ldap_base_filter_label	= "User search filter (optional):";
146
	$l_ldap_base_filter_label	= "User search filter (optional):";
147
	$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))'";
147
	$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))'";
148
	$l_ldap_user_label		= "CN of the user operated by ALCASAR:";
148
	$l_ldap_user_label		= "CN of the user operated by ALCASAR:";
149
	$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'";
149
	$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'";
150
	$l_ldap_password_label		= "Password:";
150
	$l_ldap_password_label		= "Password:";
151
	$l_ldap_password_text		= "Leave blank to use anonymous binding. Mandatory for AD.";
151
	$l_ldap_password_text		= "Leave blank to use anonymous binding. Mandatory for AD.";
152
	$l_ldap_ssl_label		= "Secure connection";
152
	$l_ldap_ssl_label		= "Secure connection";
153
	$l_ldap_ssl_text		= "Use an encrypted connection with SSL (LDAPS)";
153
	$l_ldap_ssl_text		= "Use an encrypted connection with SSL (LDAPS)";
154
	$l_ldap_cert_required_label	= "Check the SSL certificate";
154
	$l_ldap_cert_required_label	= "Check the SSL certificate";
155
	$l_ldap_cert_required_text	= "Verify that the LDAP server uses a trusted certificate";
155
	$l_ldap_cert_required_text	= "Verify that the LDAP server uses a trusted certificate";
156
	$l_ldap_cert_label		= "SSL certificate (CA)";
156
	$l_ldap_cert_label		= "SSL certificate (CA)";
157
	$l_ldap_cert_text		= "Certificate of the certification authority that signed the LDAP server certificate";
157
	$l_ldap_cert_text		= "Certificate of the certification authority that signed the LDAP server certificate";
158
	$l_ad_dns_domain_label		= "Internal domain name";
158
	$l_ad_dns_domain_label		= "Internal domain name";
159
	$l_ad_dns_domain_text		= "Domain name that will be forwarded to the DNS server of the LDAP directory (empty for disabled)";
159
	$l_ad_dns_domain_text		= "Domain name that will be forwarded to the DNS server of the LDAP directory (empty for disabled)";
160
	$l_ldap_cert_status_cur		= "Current certificate:";
160
	$l_ldap_cert_status_cur		= "Current certificate:";
161
	$l_ldap_cert_status_no		= "No certificate imported";
161
	$l_ldap_cert_status_no		= "No certificate imported";
162
	$l_ldap_submit			= "Save";
162
	$l_ldap_submit			= "Save";
163
	$l_ldap_test_service_failed	= "LDAP service is not reachable on that server (check IP)";
163
	$l_ldap_test_service_failed	= "LDAP service is not reachable on that server (check IP)";
164
	$l_ldap_test_service_ok		= "A port 389 (636 with SSL) is open on this server";
164
	$l_ldap_test_service_ok		= "A port 389 (636 with SSL) is open on this server";
165
	$l_ldap_test_connection_failed	= "LDAP connexion failed (check the LDAP service on this server)";
165
	$l_ldap_test_connection_failed	= "LDAP connexion failed (check the LDAP service on this server)";
166
	$l_ldap_test_connection_ok	= "A LDAP connexion is established";
166
	$l_ldap_test_connection_ok	= "A LDAP connexion is established";
167
	$l_ldap_test_bind_failed	= "LDAP authentication failed (check the LDAP user and password)";
167
	$l_ldap_test_bind_failed	= "LDAP authentication failed (check the LDAP user and password)";
168
	$l_ldap_test_bind_ok		= "Successful authentication";
168
	$l_ldap_test_bind_ok		= "Successful authentication";
169
	$l_ldap_test_dn_failed		= "DN of the base seems to be wrong (check it)";
169
	$l_ldap_test_dn_failed		= "DN of the base seems to be wrong (check it)";
170
	$l_ldap_test_dn_ok		= "DN of the base seems to be ok";
170
	$l_ldap_test_dn_ok		= "DN of the base seems to be ok";
171
	$l_ldap_error			= "LDAP error";
171
	$l_ldap_error			= "LDAP error";
172
	$l_ldap_entries			= "entries in the base";
172
	$l_ldap_entries			= "entries in the base";
173
	$l_ldap_cert_cn_diff_dn		= "Certificate CommonName (§cert_domainName§) is different from the server domain name";
173
	$l_ldap_cert_cn_diff_dn		= "Certificate CommonName (§cert_domainName§) is different from the server domain name";
174
	$l_check			= "Check this config";
174
	$l_check			= "Check this config";
175
	$l_checkingConf			= "Checking this configuration...";
175
	$l_checkingConf			= "Checking this configuration...";
176
}
176
}
177
 
177
 
178
// AJAX LDAP assitant
178
// AJAX LDAP assitant
179
if (isset($_GET['assistant'])) {
179
if (isset($_GET['assistant'])) {
180
	$response = [
180
	$response = [
181
		'values' => []
181
		'values' => []
182
	];
182
	];
183
	if (!isset($_POST['ldap_server'])) exit();
183
	if (!isset($_POST['ldap_server'])) exit();
184
	$ldap_server = $_POST['ldap_server'];
184
	$ldap_server = $_POST['ldap_server'];
185
 
185
 
186
	// Check port 389 & 636
186
	// Check port 389 & 636
187
	if (!$sock = @fsockopen($ldap_server, 389, $num, $error, 2)) {
187
	if (!$sock = @fsockopen($ldap_server, 389, $num, $error, 2)) {
188
		$ldap_port_389 = false;
188
		$ldap_port_389 = false;
189
		$ldap_srv_389  = false;
189
		$ldap_srv_389  = false;
190
	} else {
190
	} else {
191
		$ldap_port_389 = true;
191
		$ldap_port_389 = true;
192
		fclose($sock);
192
		fclose($sock);
193
	}
193
	}
194
	if (!$sock = @fsockopen($ldap_server, 636, $num, $error, 2)) {
194
	if (!$sock = @fsockopen($ldap_server, 636, $num, $error, 2)) {
195
		$ldap_port_636 = false;
195
		$ldap_port_636 = false;
196
		$ldap_srv_636  = false;
196
		$ldap_srv_636  = false;
197
		$ldap_ssl      = false;
197
		$ldap_ssl      = false;
198
	} else {
198
	} else {
199
		$ldap_port_636 = true;
199
		$ldap_port_636 = true;
200
		$ldap_ssl      = true;
200
		$ldap_ssl      = true;
201
		fclose($sock);
201
		fclose($sock);
202
	}
202
	}
203
 
203
 
204
	if (!$ldap_port_389 && !$ldap_port_636) {
204
	if (!$ldap_port_389 && !$ldap_port_636) {
205
		$response['result'] = -2;
205
		$response['result'] = -2;
206
 
206
 
207
		header('Content-Type: application/json');
207
		header('Content-Type: application/json');
208
		echo json_encode($response);
208
		echo json_encode($response);
209
		exit();
209
		exit();
210
	}
210
	}
211
 
211
 
212
	// Check LDAP service
212
	// Check LDAP service
213
	if ($ldap_port_636) {
213
	if ($ldap_port_636) {
214
	// Set LDAP SSL options
214
	// Set LDAP SSL options
215
		ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
215
		ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
216
		$ldapconn = @ldap_connect('ldaps://'.$ldap_server);
216
		$ldapconn = @ldap_connect('ldaps://'.$ldap_server);
217
		if (!$ldapconn) {
217
		if (!$ldapconn) {
218
			$ldap_srv_636 = false;
218
			$ldap_srv_636 = false;
219
		} else {
219
		} else {
220
			ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
220
			ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
221
 
221
 
222
			// Bind anonymous
222
			// Bind anonymous
223
			$ldap_srv_636 = true;
223
			$ldap_srv_636 = true;
224
			if (!@ldap_bind($ldapconn)) {
224
			if (!@ldap_bind($ldapconn)) {
225
				ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
225
				ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
226
				if (!@ldap_bind($ldapconn)) {
226
				if (!@ldap_bind($ldapconn)) {
227
					$ldap_srv_636 = false;
227
					$ldap_srv_636 = false;
228
				}
228
				}
229
			}
229
			}
230
		}
230
		}
231
 
231
 
232
		if ($ldap_srv_636) {
232
		if ($ldap_srv_636) {
233
			$ldap_data    = @ldap_read($ldapconn, '', 'objectClass=*', ['dnsHostName','rootDomainNamingContext','supportedCapabilities']);
233
			$ldap_data    = @ldap_read($ldapconn, '', 'objectClass=*', ['dnsHostName','rootDomainNamingContext','supportedCapabilities']);
234
			$ldap_rootDSE = @ldap_get_entries($ldapconn, $ldap_data);
234
			$ldap_rootDSE = @ldap_get_entries($ldapconn, $ldap_data);
235
 
235
 
236
			try {
236
			try {
237
				$response['values']['isAD'] = in_array('1.2.840.113556.1.4.800', $ldap_rootDSE[0]['supportedcapabilities']);
237
				$response['values']['isAD'] = in_array('1.2.840.113556.1.4.800', $ldap_rootDSE[0]['supportedcapabilities']);
238
			} catch (Exception $e) {
238
			} catch (Exception $e) {
239
				$response['values']['isAD'] = false;
239
				$response['values']['isAD'] = false;
240
			}
240
			}
241
 
241
 
242
			if ($response['values']['isAD']) {
242
			if ($response['values']['isAD']) {
243
				try {
243
				try {
244
					$response['values']['ldap_base_dn'] = $ldap_rootDSE[0]['rootdomainnamingcontext'][0];
244
					$response['values']['ldap_base_dn'] = $ldap_rootDSE[0]['rootdomainnamingcontext'][0];
245
 
245
 
246
					if ($response['values']['ldap_base_dn']) {
246
					if ($response['values']['ldap_base_dn']) {
247
						$response['values']['int_dns_domain'] = str_replace('DC=', '', str_replace(',DC=', '.', $response['values']['ldap_base_dn']));
247
						$response['values']['int_dns_domain'] = str_replace('DC=', '', str_replace(',DC=', '.', $response['values']['ldap_base_dn']));
248
					}
248
					}
249
 
249
 
250
					$response['values']['ldap_base_dn'] = 'CN=Users,'.$response['values']['ldap_base_dn'];
250
					$response['values']['ldap_base_dn'] = 'CN=Users,'.$response['values']['ldap_base_dn'];
251
				} catch (Exception $e) { }
251
				} catch (Exception $e) { }
252
 
252
 
253
				try {
253
				try {
254
					$response['values']['ldap_server_domain'] = $ldap_rootDSE[0]['dnshostname'][0];
254
					$response['values']['ldap_server_domain'] = $ldap_rootDSE[0]['dnshostname'][0];
255
				} catch (Exception $e) { }
255
				} catch (Exception $e) { }
256
			}
256
			}
257
		}
257
		}
258
	}
258
	}
259
	$response['values']['ldap_srv_636'] = $ldap_srv_636;
259
	$response['values']['ldap_srv_636'] = $ldap_srv_636;
260
 
260
 
261
	if (!$ldap_srv_636) {
261
	if (!$ldap_srv_636) {
262
		$ldapconn = @ldap_connect('ldap://'.$ldap_server);
262
		$ldapconn = @ldap_connect('ldap://'.$ldap_server);
263
		if (!$ldapconn) {
263
		if (!$ldapconn) {
264
			$ldap_srv_389 = false;
264
			$ldap_srv_389 = false;
265
		} else {
265
		} else {
266
			ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
266
			ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
267
 
267
 
268
			// Bind anonymous
268
			// Bind anonymous
269
			$ldap_srv_389 = true;
269
			$ldap_srv_389 = true;
270
			if (!@ldap_bind($ldapconn)) {
270
			if (!@ldap_bind($ldapconn)) {
271
				ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
271
				ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
272
				if (!@ldap_bind($ldapconn)) {
272
				if (!@ldap_bind($ldapconn)) {
273
					$ldap_srv_389 = false;
273
					$ldap_srv_389 = false;
274
				}
274
				}
275
			}
275
			}
276
		}
276
		}
277
 
277
 
278
		if ($ldap_srv_389) {
278
		if ($ldap_srv_389) {
279
			$ldap_data    = @ldap_read($ldapconn, '', 'objectClass=*', ['dnsHostName','rootDomainNamingContext','supportedCapabilities']);
279
			$ldap_data    = @ldap_read($ldapconn, '', 'objectClass=*', ['dnsHostName','rootDomainNamingContext','supportedCapabilities']);
280
			$ldap_rootDSE = @ldap_get_entries($ldapconn, $ldap_data);
280
			$ldap_rootDSE = @ldap_get_entries($ldapconn, $ldap_data);
281
 
281
 
282
			try {
282
			try {
283
				$response['values']['isAD'] = in_array('1.2.840.113556.1.4.800', $ldap_rootDSE[0]['supportedcapabilities']);
283
				$response['values']['isAD'] = in_array('1.2.840.113556.1.4.800', $ldap_rootDSE[0]['supportedcapabilities']);
284
			} catch (Exception $e) {
284
			} catch (Exception $e) {
285
				$response['values']['isAD'] = false;
285
				$response['values']['isAD'] = false;
286
			}
286
			}
287
 
287
 
288
			if ($response['values']['isAD']) {
288
			if ($response['values']['isAD']) {
289
				try {
289
				try {
290
					$response['values']['ldap_base_dn'] = $ldap_rootDSE[0]['rootdomainnamingcontext'][0];
290
					$response['values']['ldap_base_dn'] = $ldap_rootDSE[0]['rootdomainnamingcontext'][0];
291
 
291
 
292
					if ($response['values']['ldap_base_dn']) {
292
					if ($response['values']['ldap_base_dn']) {
293
						$response['values']['int_dns_domain'] = str_replace('DC=', '', str_replace(',DC=', '.', $response['values']['ldap_base_dn']));
293
						$response['values']['int_dns_domain'] = str_replace('DC=', '', str_replace(',DC=', '.', $response['values']['ldap_base_dn']));
294
					}
294
					}
295
 
295
 
296
					$response['values']['ldap_base_dn'] = 'CN=Users,'.$response['values']['ldap_base_dn'];
296
					$response['values']['ldap_base_dn'] = 'CN=Users,'.$response['values']['ldap_base_dn'];
297
				} catch (Exception $e) { }
297
				} catch (Exception $e) { }
298
 
298
 
299
				try {
299
				try {
300
					$response['values']['ldap_server_domain'] = $ldap_rootDSE[0]['dnshostname'][0];
300
					$response['values']['ldap_server_domain'] = $ldap_rootDSE[0]['dnshostname'][0];
301
				} catch (Exception $e) { }
301
				} catch (Exception $e) { }
302
			}
302
			}
303
		}
303
		}
304
		$response['values']['ldap_srv_389'] = $ldap_srv_389;
304
		$response['values']['ldap_srv_389'] = $ldap_srv_389;
305
	}
305
	}
306
 
306
 
307
	if (!$ldap_srv_636 && !$ldap_srv_389) {
307
	if (!$ldap_srv_636 && !$ldap_srv_389) {
308
		$response['result'] = -1;
308
		$response['result'] = -1;
309
 
309
 
310
		header('Content-Type: application/json');
310
		header('Content-Type: application/json');
311
		echo json_encode($response);
311
		echo json_encode($response);
312
		exit();
312
		exit();
313
	}
313
	}
314
 
314
 
315
	$response['result'] = 0;
315
	$response['result'] = 0;
316
	header('Content-Type: application/json');
316
	header('Content-Type: application/json');
317
	echo json_encode($response);
317
	echo json_encode($response);
318
	exit();
318
	exit();
319
}
319
}
320
 
320
 
321
function ldap_checkServerConfig($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_basedn, $f_ldap_base_filter, $f_ldap_uid, $f_ldap_ssl, $f_ldap_cert, $f_ldap_cert_required) {
321
function ldap_checkServerConfig($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_basedn, $f_ldap_base_filter, $f_ldap_uid, $f_ldap_ssl, $f_ldap_cert, $f_ldap_cert_required) {
322
	// Socket to the LDAP port of the server
322
	// Socket to the LDAP port of the server
323
	if (!$sock = @fsockopen($f_ldap_server, (($f_ldap_ssl) ? 636 : 389), $num, $error, 2)) {
323
	if (!$sock = @fsockopen($f_ldap_server, (($f_ldap_ssl) ? 636 : 389), $num, $error, 2)) {
324
		// no network connection
324
		// no network connection
325
		return -2;
325
		return -2;
326
	}
326
	}
327
	fclose($sock);
327
	fclose($sock);
328
 
328
 
329
	// Set LDAP SSL options
329
	// Set LDAP SSL options
330
	if ($f_ldap_ssl) {
330
	if ($f_ldap_ssl) {
331
		if ($f_ldap_cert_required) {
331
		if ($f_ldap_cert_required) {
332
			if ($f_ldap_cert) {
332
			if ($f_ldap_cert) {
333
				ldap_set_option(null, LDAP_OPT_X_TLS_CACERTFILE, $f_ldap_cert);
333
				ldap_set_option(null, LDAP_OPT_X_TLS_CACERTFILE, $f_ldap_cert);
334
			}
334
			}
335
			ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_DEMAND);
335
			ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_DEMAND);
336
 
336
 
337
		} else {
337
		} else {
338
			ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
338
			ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
339
		}
339
		}
340
	}
340
	}
341
 
341
 
342
	// if ok, Test LDAP connection
342
	// if ok, Test LDAP connection
343
	$ldapconn = @ldap_connect((($f_ldap_ssl)?'ldaps':'ldap').'://'.$f_ldap_server);
343
	$ldapconn = @ldap_connect((($f_ldap_ssl)?'ldaps':'ldap').'://'.$f_ldap_server);
344
	if (!$ldapconn) {
344
	if (!$ldapconn) {
345
		// LDAP connection failed
345
		// LDAP connection failed
346
		return -1;
346
		return -1;
347
	}
347
	}
348
 
348
 
349
	ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
349
	ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
350
 
350
 
351
	// if ok, test a ldap-bind with the user used by ALCASAR
351
	// if ok, test a ldap-bind with the user used by ALCASAR
352
	$ldapbind = @ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
352
	$ldapbind = @ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
353
	if (!$ldapbind) {
353
	if (!$ldapbind) {
354
		// Test LDAP Version 3
354
		// Test LDAP Version 3
355
		ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
355
		ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
356
		$ldapbind = @ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
356
		$ldapbind = @ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
357
		if (!$ldapbind) {
357
		if (!$ldapbind) {
358
			// LDAP Bind failed
358
			// LDAP Bind failed
359
			return 0;
359
			return 0;
360
		}
360
		}
361
	}
361
	}
362
 
362
 
363
	// if ok, try to query the directory of users
363
	// if ok, try to query the directory of users
364
	$filter = ((!empty($f_ldap_base_filter)) ? $f_ldap_base_filter : '&');
364
	$filter = ((!empty($f_ldap_base_filter)) ? $f_ldap_base_filter : '&');
365
	$query = "(&($f_ldap_uid=*)($filter))";
365
	$query = "(&($f_ldap_uid=*)($filter))";
366
	$ldap_result = @ldap_search($ldapconn, $f_ldap_basedn, $query);
366
	$ldap_result = @ldap_search($ldapconn, $f_ldap_basedn, $query);
367
	if ($ldap_result) {
367
	if ($ldap_result) {
368
		$ldap_users_count = ldap_count_entries($ldapconn, $ldap_result);
368
		$ldap_users_count = ldap_count_entries($ldapconn, $ldap_result);
369
		return ($ldap_users_count + 2);
369
		return ($ldap_users_count + 2);
370
	} else {
370
	} else {
371
		return 1;
371
		return 1;
372
	}
372
	}
373
	ldap_unbind($ldapconn);
373
	ldap_unbind($ldapconn);
374
}
374
}
375
 
375
 
376
$messages = '';
376
$messages = '';
377
$LDAPS_CERT_LOC = '/etc/raddb/certs/alcasar-ldaps.crt';
377
$LDAPS_CERT_LOC = '/etc/raddb/certs/alcasar-ldaps.crt';
378
 
378
 
379
if (isset($_POST['auth_enable'])) {
379
if (isset($_POST['auth_enable'])) {
380
	if ($_POST['auth_enable'] === '1') {
380
	if ($_POST['auth_enable'] === '1') {
381
		// TODO : need to translate messages
381
		// TODO : need to translate messages
382
		$varErrors = [];
382
		$varErrors = [];
383
		if (isset($_POST['ldap_server']))        $ldap_server        = $_POST['ldap_server'];        else array_push($varErrors, 'Variable error "ldap_server"');
383
		if (isset($_POST['ldap_server']))        $ldap_server        = $_POST['ldap_server'];        else array_push($varErrors, 'Variable error "ldap_server"');
384
		if (isset($_POST['ldap_base_dn']))       $ldap_base_dn       = $_POST['ldap_base_dn'];       else array_push($varErrors, 'Variable error "ldap_base_dn"');
384
		if (isset($_POST['ldap_base_dn']))       $ldap_base_dn       = $_POST['ldap_base_dn'];       else array_push($varErrors, 'Variable error "ldap_base_dn"');
385
		if (isset($_POST['ldap_uid']))           $ldap_uid           = $_POST['ldap_uid'];           else array_push($varErrors, 'Variable error "ldap_uid"');
385
		if (isset($_POST['ldap_uid']))           $ldap_uid           = $_POST['ldap_uid'];           else array_push($varErrors, 'Variable error "ldap_uid"');
386
		if (isset($_POST['ldap_base_filter']))   $ldap_base_filter   = $_POST['ldap_base_filter'];   else array_push($varErrors, 'Variable error "ldap_base_filter"');
386
		if (isset($_POST['ldap_base_filter']))   $ldap_base_filter   = $_POST['ldap_base_filter'];   else array_push($varErrors, 'Variable error "ldap_base_filter"');
387
		if (isset($_POST['ldap_user']))          $ldap_user          = $_POST['ldap_user'];          else array_push($varErrors, 'Variable error "ldap_user"');
387
		if (isset($_POST['ldap_user']))          $ldap_user          = $_POST['ldap_user'];          else array_push($varErrors, 'Variable error "ldap_user"');
388
		if (isset($_POST['ldap_password']))      $ldap_password      = $_POST['ldap_password'];      else array_push($varErrors, 'Variable error "ldap_password"');
388
		if (isset($_POST['ldap_password']))      $ldap_password      = $_POST['ldap_password'];      else array_push($varErrors, 'Variable error "ldap_password"');
389
		if (isset($_POST['ldap_ssl']))           $ldap_ssl           = $_POST['ldap_ssl'];           //else array_push($varErrors, 'Variable error "ldap_ssl"');
389
		if (isset($_POST['ldap_ssl']))           $ldap_ssl           = $_POST['ldap_ssl'];           //else array_push($varErrors, 'Variable error "ldap_ssl"');
390
		if (isset($_FILES['ldap_cert']))         $ldap_cert          = $_FILES['ldap_cert'];         //else array_push($varErrors, 'Variable error "ldap_cert"');
390
		if (isset($_FILES['ldap_cert']))         $ldap_cert          = $_FILES['ldap_cert'];         //else array_push($varErrors, 'Variable error "ldap_cert"');
391
		if (isset($_POST['ldap_cert_required'])) $ldap_cert_required = $_POST['ldap_cert_required']; //else array_push($varErrors, 'Variable error "ldap_cert_required"');
391
		if (isset($_POST['ldap_cert_required'])) $ldap_cert_required = $_POST['ldap_cert_required']; //else array_push($varErrors, 'Variable error "ldap_cert_required"');
392
 
392
 
393
		if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
393
		if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
394
			if ($ldap_cert_required === 'on') {
394
			if ($ldap_cert_required === 'on') {
395
				$certificateInfos = openssl_x509_parse(file_get_contents($ldap_cert['tmp_name']));
395
				$certificateInfos = openssl_x509_parse(file_get_contents($ldap_cert['tmp_name']));
396
				if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
396
				if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
397
					$cert_domainName = implode('.', array_reverse($matches[1]));
397
					$cert_domainName = implode('.', array_reverse($matches[1]));
398
					if ($cert_domainName !== $ldap_server) {
398
					if ($cert_domainName !== $ldap_server) {
399
						array_push($varErrors, str_replace("§cert_domainName§", $cert_domainName, $l_ldap_cert_cn_diff_dn));
399
						array_push($varErrors, str_replace("§cert_domainName§", $cert_domainName, $l_ldap_cert_cn_diff_dn));
400
					}
400
					}
401
				}
401
				}
402
			}
402
			}
403
		}
403
		}
404
 
404
 
405
		if (!empty($varErrors)) { 
405
		if (!empty($varErrors)) { 
406
			foreach ($varErrors as $error) {
406
			foreach ($varErrors as $error) {
407
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
407
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
408
			}
408
			}
409
		} else {
409
		} else {
410
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
410
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
411
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
411
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
412
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
412
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
413
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
413
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
414
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
414
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
415
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
415
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
416
			exec('sed -i '.escapeshellarg("s/^LDAP_SSL=.*/LDAP_SSL=$ldap_ssl/g").' '.CONF_FILE);
416
			exec('sed -i '.escapeshellarg("s/^LDAP_SSL=.*/LDAP_SSL=$ldap_ssl/g").' '.CONF_FILE);
417
			if (isset($ldap_cert_required)) {
417
			if (isset($ldap_cert_required)) {
418
				exec('sed -i '.escapeshellarg("s/^LDAP_CERT_REQUIRED=.*/LDAP_CERT_REQUIRED=$ldap_cert_required/g").' '.CONF_FILE);
418
				exec('sed -i '.escapeshellarg("s/^LDAP_CERT_REQUIRED=.*/LDAP_CERT_REQUIRED=$ldap_cert_required/g").' '.CONF_FILE);
419
			}
419
			}
420
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
420
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
421
			if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
421
			if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
422
				exec('sudo /usr/local/bin/alcasar-ldap.sh --import-cert '.escapeshellarg($ldap_cert['tmp_name']));
422
				exec('sudo /usr/local/bin/alcasar-ldap.sh --import-cert '.escapeshellarg($ldap_cert['tmp_name']));
423
			}
423
			}
424
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
424
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
425
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
425
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
426
 
426
 
427
			if ((isset($_POST['ad_dns_domain'])) && ($_POST['ad_dns_domain'] !== $conf['INT_DNS_DOMAIN'])) {
427
			if ((isset($_POST['ad_dns_domain'])) && ($_POST['ad_dns_domain'] !== $conf['INT_DNS_DOMAIN'])) {
428
				if (filter_var($ldap_server, FILTER_VALIDATE_IP) !== false) {
428
				if (filter_var($ldap_server, FILTER_VALIDATE_IP) !== false) {
429
					$ldap_server_ip = $ldap_server;
429
					$ldap_server_ip = $ldap_server;
430
				} else {
430
				} else {
431
					$ldap_server_ip = gethostbyname($ldap_server);
431
					$ldap_server_ip = gethostbyname($ldap_server);
432
				}
432
				}
433
				if (filter_var($ldap_server_ip, FILTER_VALIDATE_IP) !== false) {
433
				if (filter_var($ldap_server_ip, FILTER_VALIDATE_IP) !== false) {
434
					file_put_contents(CONF_FILE, str_replace('INT_DNS_IP='.$conf['INT_DNS_IP'],         'INT_DNS_IP='.$ldap_server_ip,             file_get_contents(CONF_FILE)));
434
					file_put_contents(CONF_FILE, str_replace('INT_DNS_IP='.$conf['INT_DNS_IP'],         'INT_DNS_IP='.$ldap_server_ip,             file_get_contents(CONF_FILE)));
435
					file_put_contents(CONF_FILE, str_replace('INT_DNS_DOMAIN='.$conf['INT_DNS_DOMAIN'], 'INT_DNS_DOMAIN='.$_POST['ad_dns_domain'], file_get_contents(CONF_FILE)));
435
					file_put_contents(CONF_FILE, str_replace('INT_DNS_DOMAIN='.$conf['INT_DNS_DOMAIN'], 'INT_DNS_DOMAIN='.$_POST['ad_dns_domain'], file_get_contents(CONF_FILE)));
436
					if (!empty($_POST['ad_dns_domain'])) {
436
					if (!empty($_POST['ad_dns_domain'])) {
437
						exec('sudo /usr/local/bin/alcasar-dns-local.sh --on');
437
						exec('sudo /usr/local/bin/alcasar-dns-local.sh --on');
438
					} else {
438
					} else {
439
						exec('sudo /usr/local/bin/alcasar-dns-local.sh --off');
439
						exec('sudo /usr/local/bin/alcasar-dns-local.sh --off');
440
					}
440
					}
441
				}
441
				}
442
			}
442
			}
443
		}
443
		}
444
	} else {
444
	} else {
445
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
445
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
446
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
446
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
447
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
447
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
448
 
448
 
449
		if ((isset($_POST['ad_dns_domain'])) && (empty($_POST['ad_dns_domain']))) {
449
		if ((isset($_POST['ad_dns_domain'])) && (empty($_POST['ad_dns_domain']))) {
450
			exec('sudo /usr/local/bin/alcasar-dns-local.sh --off');
450
			exec('sudo /usr/local/bin/alcasar-dns-local.sh --off');
451
		}
451
		}
452
	}
452
	}
453
 
453
 
454
	// Reload configuration
454
	// Reload configuration
455
	$file_conf = fopen(CONF_FILE, 'r');
455
	$file_conf = fopen(CONF_FILE, 'r');
456
	if (!$file_conf) {
456
	if (!$file_conf) {
457
		exit('Error opening the file '.CONF_FILE);
457
		exit('Error opening the file '.CONF_FILE);
458
	}
458
	}
459
	while (!feof($file_conf)) {
459
	while (!feof($file_conf)) {
460
		$buffer = fgets($file_conf, 4096);
460
		$buffer = fgets($file_conf, 4096);
461
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
461
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
462
			$tmp = explode('=', $buffer, 2);
462
			$tmp = explode('=', $buffer, 2);
463
			$conf[trim($tmp[0])] = trim($tmp[1]);
463
			$conf[trim($tmp[0])] = trim($tmp[1]);
464
		}
464
		}
465
	}
465
	}
466
	fclose($file_conf);
466
	fclose($file_conf);
467
}
467
}
468
 
468
 
469
// LDAP configuration params
469
// LDAP configuration params
470
$ldap_status        = ($conf['LDAP'] === 'on');
470
$ldap_status        = ($conf['LDAP'] === 'on');
471
$ldap_server        = $conf['LDAP_SERVER'];
471
$ldap_server        = $conf['LDAP_SERVER'];
472
$ldap_user          = $conf['LDAP_USER'];
472
$ldap_user          = $conf['LDAP_USER'];
473
$ldap_password      = $conf['LDAP_PASSWORD'];
473
$ldap_password      = $conf['LDAP_PASSWORD'];
474
$ldap_base_dn       = $conf['LDAP_BASE'];
474
$ldap_base_dn       = $conf['LDAP_BASE'];
475
$ldap_uid	    = $conf['LDAP_UID'];
475
$ldap_uid	    = $conf['LDAP_UID'];
476
$ldap_base_filter   = $conf['LDAP_FILTER'];
476
$ldap_base_filter   = $conf['LDAP_FILTER'];
477
$ldap_ssl           = ($conf['LDAP_SSL'] === 'on');
477
$ldap_ssl           = ($conf['LDAP_SSL'] === 'on');
478
$ldap_cert_required = ($conf['LDAP_CERT_REQUIRED'] === 'on');
478
$ldap_cert_required = ($conf['LDAP_CERT_REQUIRED'] === 'on');
479
 
479
 
480
$ldap_cert_subject = null;
480
$ldap_cert_subject = null;
481
if (file_exists($LDAPS_CERT_LOC)) {
481
if (file_exists($LDAPS_CERT_LOC)) {
482
	$certificateInfos = openssl_x509_parse(file_get_contents($LDAPS_CERT_LOC));
482
	$certificateInfos = openssl_x509_parse(file_get_contents($LDAPS_CERT_LOC));
483
	if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
483
	if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
484
		$ldap_cert_subject = implode('.', array_reverse($matches[1]));
484
		$ldap_cert_subject = implode('.', array_reverse($matches[1]));
485
	}
485
	}
486
}
486
}
487
 
487
 
488
// AJAX LDAP configuration checker
488
// AJAX LDAP configuration checker
489
if (isset($_GET['conf_check'])) {
489
if (isset($_GET['conf_check'])) {
490
	$response = [
490
	$response = [
491
		'enable' => $ldap_status
491
		'enable' => $ldap_status
492
	];
492
	];
493
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
493
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
494
		$varErrors = [];
494
		$varErrors = [];
495
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
495
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
496
			// TODO : need to translate messages
496
			// TODO : need to translate messages
497
			if (isset($_POST['ldap_server']))        $ldap_server        = $_POST['ldap_server'];                   else array_push($varErrors, 'Variable error "ldap_server"');
497
			if (isset($_POST['ldap_server']))        $ldap_server        = $_POST['ldap_server'];                   else array_push($varErrors, 'Variable error "ldap_server"');
498
			if (isset($_POST['ldap_base_dn']))       $ldap_base_dn       = $_POST['ldap_base_dn'];                  else array_push($varErrors, 'Variable error "ldap_base_dn"');
498
			if (isset($_POST['ldap_base_dn']))       $ldap_base_dn       = $_POST['ldap_base_dn'];                  else array_push($varErrors, 'Variable error "ldap_base_dn"');
499
			if (isset($_POST['ldap_uid']))           $ldap_uid           = $_POST['ldap_uid'];                      else array_push($varErrors, 'Variable error "ldap_uid"');
499
			if (isset($_POST['ldap_uid']))           $ldap_uid           = $_POST['ldap_uid'];                      else array_push($varErrors, 'Variable error "ldap_uid"');
500
			if (isset($_POST['ldap_base_filter']))   $ldap_base_filter   = $_POST['ldap_base_filter'];              else array_push($varErrors, 'Variable error "ldap_base_filter"');
500
			if (isset($_POST['ldap_base_filter']))   $ldap_base_filter   = $_POST['ldap_base_filter'];              else array_push($varErrors, 'Variable error "ldap_base_filter"');
501
			if (isset($_POST['ldap_user']))          $ldap_user          = $_POST['ldap_user'];                     else array_push($varErrors, 'Variable error "ldap_user"');
501
			if (isset($_POST['ldap_user']))          $ldap_user          = $_POST['ldap_user'];                     else array_push($varErrors, 'Variable error "ldap_user"');
502
			if (isset($_POST['ldap_password']))      $ldap_password      = $_POST['ldap_password'];                 else array_push($varErrors, 'Variable error "ldap_password"');
502
			if (isset($_POST['ldap_password']))      $ldap_password      = $_POST['ldap_password'];                 else array_push($varErrors, 'Variable error "ldap_password"');
503
			if (isset($_POST['ldap_ssl']))           $ldap_ssl           = ($_POST['ldap_ssl'] === 'on');           //else array_push($varErrors, 'Variable error "ldap_ssl"');
503
			if (isset($_POST['ldap_ssl']))           $ldap_ssl           = ($_POST['ldap_ssl'] === 'on');           //else array_push($varErrors, 'Variable error "ldap_ssl"');
504
			if (isset($_FILES['ldap_cert']))         $ldap_cert          = $_FILES['ldap_cert'];                    //else array_push($varErrors, 'Variable error "ldap_cert"');
504
			if (isset($_FILES['ldap_cert']))         $ldap_cert          = $_FILES['ldap_cert'];                    //else array_push($varErrors, 'Variable error "ldap_cert"');
505
			if (isset($_POST['ldap_cert_required'])) $ldap_cert_required = ($_POST['ldap_cert_required'] === 'on'); //else array_push($varErrors, 'Variable error "ldap_cert_required"');
505
			if (isset($_POST['ldap_cert_required'])) $ldap_cert_required = ($_POST['ldap_cert_required'] === 'on'); //else array_push($varErrors, 'Variable error "ldap_cert_required"');
506
		}
506
		}
507
 
507
 
508
		if (($ldap_cert_required) && isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
508
		if (($ldap_cert_required) && isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
509
			$ldap_cert_tmpFilename = $ldap_cert['tmp_name'];
509
			$ldap_cert_tmpFilename = $ldap_cert['tmp_name'];
510
		} else {
510
		} else {
511
			$ldap_cert_tmpFilename = null;
511
			$ldap_cert_tmpFilename = null;
512
		}
512
		}
513
 
513
 
514
		if (!empty($varErrors)) {
514
		if (!empty($varErrors)) {
515
			$response['errors'] = $varErrors;
515
			$response['errors'] = $varErrors;
516
		} else {
516
		} else {
517
			$result = ldap_checkServerConfig($ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_base_filter, $ldap_uid, $ldap_ssl, $ldap_cert_tmpFilename, $ldap_cert_required);
517
			$result = ldap_checkServerConfig($ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_base_filter, $ldap_uid, $ldap_ssl, $ldap_cert_tmpFilename, $ldap_cert_required);
518
 
518
 
519
			if (($result === 0) && ($ldap_ssl && $ldap_cert_required && ((isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) || (file_exists($LDAPS_CERT_LOC))))) {
519
			if (($result === 0) && ($ldap_ssl && $ldap_cert_required && ((isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) || (file_exists($LDAPS_CERT_LOC))))) {
520
				if (filter_var($ldap_server, FILTER_VALIDATE_IP) !== false) {
520
				if (filter_var($ldap_server, FILTER_VALIDATE_IP) !== false) {
521
					if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
521
					if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
522
						$certificateInfos = openssl_x509_parse(file_get_contents($ldap_cert['tmp_name']));
522
						$certificateInfos = openssl_x509_parse(file_get_contents($ldap_cert['tmp_name']));
523
					} else {
523
					} else {
524
						$certificateInfos = openssl_x509_parse(file_get_contents($LDAPS_CERT_LOC));
524
						$certificateInfos = openssl_x509_parse(file_get_contents($LDAPS_CERT_LOC));
525
					}
525
					}
526
					if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
526
					if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
527
						$cert_domainName = implode('.', array_reverse($matches[1]));
527
						$cert_domainName = implode('.', array_reverse($matches[1]));
528
						if ($cert_domainName !== $ldap_server) {
528
						if ($cert_domainName !== $ldap_server) {
529
							$response['warnings'][] = str_replace("§cert_domainName§", $cert_domainName, $l_ldap_cert_cn_diff_dn);
529
							$response['warnings'][] = str_replace("§cert_domainName§", $cert_domainName, $l_ldap_cert_cn_diff_dn);
530
						}
530
						}
531
					}
531
					}
532
					$res = ldap_checkServerConfig($cert_domainName, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_base_filter, $ldap_uid, $ldap_ssl, $ldap_cert_tmpFilename, $ldap_cert_required);
532
					$res = ldap_checkServerConfig($cert_domainName, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_base_filter, $ldap_uid, $ldap_ssl, $ldap_cert_tmpFilename, $ldap_cert_required);
533
					if ($res > 1) {
533
					if ($res > 1) {
534
						$result = $res;
534
						$result = $res;
535
					}
535
					}
536
					$result = max($result, $res);
536
					$result = max($result, $res);
537
				}
537
				}
538
			}
538
			}
539
 
539
 
540
			$response['result'] = $result;
540
			$response['result'] = $result;
541
		}
541
		}
542
	}
542
	}
543
 
543
 
544
	header('Content-Type: application/json');
544
	header('Content-Type: application/json');
545
	echo json_encode($response);
545
	echo json_encode($response);
546
	exit();
546
	exit();
547
}
547
}
548
 
548
 
549
?>
549
?>
550
<!DOCTYPE html>
550
<!DOCTYPE html>
551
<html>
551
<html>
552
<head>
552
<head>
553
	<meta charset="UTF-8">
553
	<meta charset="UTF-8">
554
	<title><?= $l_ldap_title ?></title>
554
	<title><?= $l_ldap_title ?></title>
555
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
555
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
556
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
556
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
557
	<script>
557
	<script>
558
	function onLdapStatusChange() {
558
	function onLdapStatusChange() {
559
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password', 'ldap_ssl', 'ldap_cert_required', 'ldap_cert'];
559
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password', 'ldap_ssl', 'ldap_cert_required', 'ldap_cert'];
560
		var formSubmit = document.querySelector('form input[type="submit"]');
560
		var formSubmit = document.querySelector('form input[type="submit"]');
561
		var btn_checkConf = document.getElementById('btn-checkconf');
561
		var btn_checkConf = document.getElementById('btn-checkconf');
562
		var isChecked = false;
562
		var isChecked = false;
563
 
563
 
564
		if (document.getElementById('auth_enable').value === '1') {
564
		if (document.getElementById('auth_enable').value === '1') {
565
			for (var i=0; i<listToDisables.length; i++) {
565
			for (var i=0; i<listToDisables.length; i++) {
566
				document.getElementById(listToDisables[i]).style.backgroundColor = null;
566
				document.getElementById(listToDisables[i]).style.backgroundColor = null;
567
				document.getElementById(listToDisables[i]).disabled = false;
567
				document.getElementById(listToDisables[i]).disabled = false;
568
			}
568
			}
569
			if (document.getElementById('ldap_ssl').value === 'off') {
569
			if (document.getElementById('ldap_ssl').value === 'off') {
570
				document.getElementById('ldap_cert_required').style.backgroundColor = '#c0c0c0';
570
				document.getElementById('ldap_cert_required').style.backgroundColor = '#c0c0c0';
571
				document.getElementById('ldap_cert_required').disabled = true;
571
				document.getElementById('ldap_cert_required').disabled = true;
572
				document.getElementById('ldap_cert').style.backgroundColor = '#c0c0c0';
572
				document.getElementById('ldap_cert').style.backgroundColor = '#c0c0c0';
573
				document.getElementById('ldap_cert').disabled = true;
573
				document.getElementById('ldap_cert').disabled = true;
574
			}
574
			}
575
			else if (document.getElementById('ldap_cert_required').value === 'off') {
575
			else if (document.getElementById('ldap_cert_required').value === 'off') {
576
				document.getElementById('ldap_cert').style.backgroundColor = '#c0c0c0';
576
				document.getElementById('ldap_cert').style.backgroundColor = '#c0c0c0';
577
				document.getElementById('ldap_cert').disabled = true;
577
				document.getElementById('ldap_cert').disabled = true;
578
			}
578
			}
579
			formSubmit.style.display = 'none';
579
			formSubmit.style.display = 'none';
580
			btn_checkConf.style.display = null;
580
			btn_checkConf.style.display = null;
581
		} else {
581
		} else {
582
			for (var i=0; i<listToDisables.length; i++) {
582
			for (var i=0; i<listToDisables.length; i++) {
583
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
583
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
584
				document.getElementById(listToDisables[i]).disabled = true;
584
				document.getElementById(listToDisables[i]).disabled = true;
585
			}
585
			}
586
			formSubmit.style.display = null;
586
			formSubmit.style.display = null;
587
			btn_checkConf.style.display = 'none';
587
			btn_checkConf.style.display = 'none';
588
		}
588
		}
589
	}
589
	}
590
 
590
 
591
	function checkConfig() {
591
	function checkConfig() {
592
		var messagesElem = document.querySelector('fieldset > legend > div');
592
		var messagesElem = document.querySelector('fieldset > legend > div');
593
		var formSubmit   = document.querySelector('form input[type="submit"]');
593
		var formSubmit   = document.querySelector('form input[type="submit"]');
594
		var btn_checkConf = document.getElementById('btn-checkconf');
594
		var btn_checkConf = document.getElementById('btn-checkconf');
595
		var form = document.getElementById('form-config_ldap');
595
		var form = document.getElementById('form-config_ldap');
596
		var post_data = new FormData(form);
596
		var post_data = new FormData(form);
597
		post_data.delete('auth_enable');
597
		post_data.delete('auth_enable');
598
 
598
 
599
		messagesElem.innerHTML = '<?= $l_checkingConf ?>';
599
		messagesElem.innerHTML = '<?= $l_checkingConf ?>';
600
 
600
 
601
		var xhr = new XMLHttpRequest();
601
		var xhr = new XMLHttpRequest();
602
		xhr.onreadystatechange = function() {
602
		xhr.onreadystatechange = function() {
603
			if (this.readyState == 4) {
603
			if (this.readyState == 4) {
604
				if (this.status == 200) {
604
				if (this.status == 200) {
605
					var data = JSON.parse(this.responseText);
605
					var data = JSON.parse(this.responseText);
606
 
606
 
607
					var messages = '';
607
					var messages = '';
608
 
608
 
609
					if (typeof data.result !== 'undefined') {
609
					if (typeof data.result !== 'undefined') {
610
						if (data.result === -2) {
610
						if (data.result === -2) {
611
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
611
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
612
						} else {
612
						} else {
613
							messages += "<span style=\"color: green\"><?= $l_ldap_test_service_ok ?></span>";
613
							messages += "<span style=\"color: green\"><?= $l_ldap_test_service_ok ?></span>";
614
							if (data.result === -1) {
614
							if (data.result === -1) {
615
								messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
615
								messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
616
							} else {
616
							} else {
617
								messages += "<br><span style=\"color: green\"><?= $l_ldap_test_connection_ok ?></span>";
617
								messages += "<br><span style=\"color: green\"><?= $l_ldap_test_connection_ok ?></span>";
618
								if (data.result === 0) {
618
								if (data.result === 0) {
619
									messages += "<br><span style=\"color: red\"><?= $l_ldap_test_bind_failed ?></span>";
619
									messages += "<br><span style=\"color: red\"><?= $l_ldap_test_bind_failed ?></span>";
620
								} else {
620
								} else {
621
									messages += "<br><span style=\"color: green\"><?= $l_ldap_test_bind_ok ?></span>";
621
									messages += "<br><span style=\"color: green\"><?= $l_ldap_test_bind_ok ?></span>";
622
									if (data.result === 1) {
622
									if (data.result === 1) {
623
										messages += "<br><span style=\"color: red\"><?= $l_ldap_test_dn_failed ?></span>";
623
										messages += "<br><span style=\"color: red\"><?= $l_ldap_test_dn_failed ?></span>";
624
									} else {
624
									} else {
625
										messages += "<br><span style=\"color: green\"><?= $l_ldap_test_dn_ok ?> (" + (data.result - 2) + " <?= $l_ldap_entries?>)</span>";
625
										messages += "<br><span style=\"color: green\"><?= $l_ldap_test_dn_ok ?> (" + (data.result - 2) + " <?= $l_ldap_entries?>)</span>";
626
									}
626
									}
627
								}
627
								}
628
							}
628
							}
629
						}
629
						}
630
					}
630
					}
631
 
631
 
632
					if (data.result > 1) {
632
					if (data.result > 1) {
633
						formSubmit.style.display = null;
633
						formSubmit.style.display = null;
634
						btn_checkConf.style.display = 'none';
634
						btn_checkConf.style.display = 'none';
635
					} else {
635
					} else {
636
						formSubmit.style.display = 'none';
636
						formSubmit.style.display = 'none';
637
						btn_checkConf.style.display = null;
637
						btn_checkConf.style.display = null;
638
					}
638
					}
639
 
639
 
640
					if (typeof data.errors !== 'undefined') {
640
					if (typeof data.errors !== 'undefined') {
641
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
641
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
642
					}
642
					}
643
					if (typeof data.warnings !== 'undefined') {
643
					if (typeof data.warnings !== 'undefined') {
644
						messages += '<br><span style=\"color: orange\">' + data.warnings.join('</span><br><span style=\"color: orange\">') + '</span><br>';
644
						messages += '<br><span style=\"color: orange\">' + data.warnings.join('</span><br><span style=\"color: orange\">') + '</span><br>';
645
					}
645
					}
646
 
646
 
647
					messagesElem.innerHTML = messages;
647
					messagesElem.innerHTML = messages;
648
				} else {
648
				} else {
649
					messagesElem.innerHTML = 'server error';
649
					messagesElem.innerHTML = 'server error';
650
				}
650
				}
651
			}
651
			}
652
		};
652
		};
653
		xhr.open('POST', 'ldap.php?conf_check', true);
653
		xhr.open('POST', 'ldap.php?conf_check', true);
654
		xhr.send(post_data);
654
		xhr.send(post_data);
655
	}
655
	}
656
 
656
 
657
	function launchAssistant() {
657
	function launchAssistant() {
658
		var messagesElem = document.querySelector('fieldset > legend > div');
658
		var messagesElem = document.querySelector('fieldset > legend > div');
659
		var dom_ldap_server        = document.getElementById('ldap_server');
659
		var dom_ldap_server        = document.getElementById('ldap_server');
660
		var dom_ldap_ssl           = document.getElementById('ldap_ssl');
660
		var dom_ldap_ssl           = document.getElementById('ldap_ssl');
661
		var dom_ldap_cert_required = document.getElementById('ldap_cert_required');
661
		var dom_ldap_cert_required = document.getElementById('ldap_cert_required');
662
		var dom_ldap_dn            = document.getElementById('ldap_dn');
662
		var dom_ldap_dn            = document.getElementById('ldap_dn');
663
		var dom_ldap_uid           = document.getElementById('ldap_uid');
663
		var dom_ldap_uid           = document.getElementById('ldap_uid');
664
		var dom_ad_dns_domain      = document.getElementById('ad_dns_domain');
664
		var dom_ad_dns_domain      = document.getElementById('ad_dns_domain');
665
		post_data = 'ldap_server='+dom_ldap_server.value;
665
		post_data = 'ldap_server='+dom_ldap_server.value;
666
 
666
 
667
		messagesElem.innerHTML = '';
667
		messagesElem.innerHTML = '';
668
 
668
 
669
		var xhr = new XMLHttpRequest();
669
		var xhr = new XMLHttpRequest();
670
		xhr.onreadystatechange = function() {
670
		xhr.onreadystatechange = function() {
671
			if (this.readyState == 4) {
671
			if (this.readyState == 4) {
672
				if (this.status == 200) {
672
				if (this.status == 200) {
673
					var data = JSON.parse(this.responseText);
673
					var data = JSON.parse(this.responseText);
674
					var messages = '';
674
					var messages = '';
675
 
675
 
676
					if (typeof data.result !== 'undefined') {
676
					if (typeof data.result !== 'undefined') {
677
						if (data.result === -2) {
677
						if (data.result === -2) {
678
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
678
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
679
						} else if (data.result === -1) {
679
						} else if (data.result === -1) {
680
							messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
680
							messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
681
						} else if (data.result === 0) {
681
						} else if (data.result === 0) {
682
							if ((typeof data.values.int_dns_domain !== 'undefined') && (dom_ad_dns_domain.value === '')) {
682
							if ((typeof data.values.int_dns_domain !== 'undefined') && (dom_ad_dns_domain.value === '')) {
683
								dom_ad_dns_domain.value = data.values.int_dns_domain
683
								dom_ad_dns_domain.value = data.values.int_dns_domain
684
							}
684
							}
685
							if ((typeof data.values.ldap_base_dn !== 'undefined') && (dom_ldap_dn.value === '')) {
685
							if ((typeof data.values.ldap_base_dn !== 'undefined') && (dom_ldap_dn.value === '')) {
686
								dom_ldap_dn.value = data.values.ldap_base_dn
686
								dom_ldap_dn.value = data.values.ldap_base_dn
687
							}
687
							}
688
							if (dom_ldap_uid.value === '') {
688
							if (dom_ldap_uid.value === '') {
689
								if (data.values.isAD === true) {
689
								if (data.values.isAD === true) {
690
									dom_ldap_uid.value = 'sAMAccountName';
690
									dom_ldap_uid.value = 'sAMAccountName';
691
								} else {
691
								} else {
692
									dom_ldap_uid.value = 'uid';
692
									dom_ldap_uid.value = 'uid';
693
								}
693
								}
694
							}
694
							}
695
							if (data.values.ldap_srv_636 === true) {
695
							if (data.values.ldap_srv_636 === true) {
696
								dom_ldap_ssl.value = 'on'
696
								dom_ldap_ssl.value = 'on'
697
								if ((typeof data.values.ldap_server_domain !== 'undefined') && (dom_ldap_cert_required.value === 'on')) {
697
								if ((typeof data.values.ldap_server_domain !== 'undefined') && (dom_ldap_cert_required.value === 'on')) {
698
									dom_ldap_server.value = data.values.ldap_server_domain
698
									dom_ldap_server.value = data.values.ldap_server_domain
699
								}
699
								}
700
							} else {
700
							} else {
701
								if (dom_ldap_ssl.value === 'on') {
701
								if (dom_ldap_ssl.value === 'on') {
702
									dom_ldap_ssl.value = 'off';
702
									dom_ldap_ssl.value = 'off';
703
								}
703
								}
704
							}
704
							}
705
							onLdapStatusChange();
705
							onLdapStatusChange();
706
						}
706
						}
707
					}
707
					}
708
 
708
 
709
					messagesElem.innerHTML = messages;
709
					messagesElem.innerHTML = messages;
710
				} else {
710
				} else {
711
					messagesElem.innerHTML = 'server error';
711
					messagesElem.innerHTML = 'server error';
712
				}
712
				}
713
			}
713
			}
714
		};
714
		};
715
		xhr.open('POST', 'ldap.php?assistant', true);
715
		xhr.open('POST', 'ldap.php?assistant', true);
716
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
716
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
717
		xhr.send(post_data);
717
		xhr.send(post_data);
718
	}
718
	}
719
	</script>
719
	</script>
720
</head>
720
</head>
721
<body onLoad="onLdapStatusChange();">
721
<body onLoad="onLdapStatusChange();">
722
	<div class="panel">
722
	<div class="panel">
723
		<div class="panel-header"><?= $l_ldap_legend ?></div>
723
		<div class="panel-header"><?= $l_ldap_legend ?></div>
724
		<div class="panel-body">
724
		<div class="panel-body">
725
			<form id="form-config_ldap" name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
725
			<form id="form-config_ldap" name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
726
				<fieldset>
726
				<fieldset>
727
					<legend>
727
					<legend>
728
						<br>
728
						<br>
729
						<div style="text-align: center">
729
						<div style="text-align: center">
730
							<?php if ($messages): ?>
730
							<?php if ($messages): ?>
731
								<?= $messages ?>
731
								<?= $messages ?>
732
							<?php endif; ?>
732
							<?php endif; ?>
733
						</div>
733
						</div>
734
					</legend>
734
					</legend>
735
					<dl>
735
					<dl>
736
						<dt>
736
						<dt>
737
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
737
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
738
						</dt>
738
						</dt>
739
						<dd>
739
						<dd>
740
							<select id="auth_enable" name="auth_enable" onchange="onLdapStatusChange();">
740
							<select id="auth_enable" name="auth_enable" onchange="onLdapStatusChange();">
741
								<option value="1"<?= ($ldap_status)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
741
								<option value="1"<?= ($ldap_status)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
742
								<option value="0"<?= (!$ldap_status) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
742
								<option value="0"<?= (!$ldap_status) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
743
							</select>
743
							</select>
744
						</dd>
744
						</dd>
745
					</dl>
745
					</dl>
746
					<dl>
746
					<dl>
747
						<dt>
747
						<dt>
748
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
748
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
749
							<?= $l_ldap_server_text ?>
749
							<?= $l_ldap_server_text ?>
750
						</dt>
750
						</dt>
751
						<dd>
751
						<dd>
752
							<input type="text" id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>" oninput="onLdapStatusChange();"> <button onclick="launchAssistant(); return false;"><?= 'Assistant' ?></button>
752
							<input type="text" id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>" oninput="onLdapStatusChange();"> <button onclick="launchAssistant(); return false;"><?= 'Assistant' ?></button>
753
						</dd>
753
						</dd>
754
					</dl>
754
					</dl>
755
					<dl>
755
					<dl>
756
						<dt>
756
						<dt>
757
							<label for="ldap_ssl"><?= $l_ldap_ssl_label ?></label><br>
757
							<label for="ldap_ssl"><?= $l_ldap_ssl_label ?></label><br>
758
							<?= $l_ldap_ssl_text ?><br>
758
							<?= $l_ldap_ssl_text ?><br>
759
						</dt>
759
						</dt>
760
						<dd>
760
						<dd>
761
							<select id="ldap_ssl" name="ldap_ssl" onchange="onLdapStatusChange();">
761
							<select id="ldap_ssl" name="ldap_ssl" onchange="onLdapStatusChange();">
762
								<option value="on"<?= ($ldap_ssl)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
762
								<option value="on"<?= ($ldap_ssl)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
763
								<option value="off"<?= (!$ldap_ssl) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
763
								<option value="off"<?= (!$ldap_ssl) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
764
							</select>
764
							</select>
765
						</dd>
765
						</dd>
766
					</dl>
766
					</dl>
767
					<dl>
767
					<dl>
768
						<dt>
768
						<dt>
769
							<label for="ldap_cert_required"><?= $l_ldap_cert_required_label ?></label><br>
769
							<label for="ldap_cert_required"><?= $l_ldap_cert_required_label ?></label><br>
770
							<?= $l_ldap_cert_required_text ?><br>
770
							<?= $l_ldap_cert_required_text ?><br>
771
						</dt>
771
						</dt>
772
						<dd>
772
						<dd>
773
							<select id="ldap_cert_required" name="ldap_cert_required" onchange="onLdapStatusChange();">
773
							<select id="ldap_cert_required" name="ldap_cert_required" onchange="onLdapStatusChange();">
774
								<option value="on"<?= ($ldap_cert_required)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
774
								<option value="on"<?= ($ldap_cert_required)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
775
								<option value="off"<?= (!$ldap_cert_required) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
775
								<option value="off"<?= (!$ldap_cert_required) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
776
							</select>
776
							</select>
777
						</dd>
777
						</dd>
778
					</dl>
778
					</dl>
779
					<dl>
779
					<dl>
780
						<dt>
780
						<dt>
781
							<label for="ldap_cert"><?= $l_ldap_cert_label ?></label><br>
781
							<label for="ldap_cert"><?= $l_ldap_cert_label ?></label><br>
782
							<?= $l_ldap_cert_text ?><br>
782
							<?= $l_ldap_cert_text ?><br>
783
							<?= (($ldap_cert_subject) ? "$l_ldap_cert_status_cur $ldap_cert_subject" : $l_ldap_cert_status_no ) ?>
783
							<?= (($ldap_cert_subject) ? "$l_ldap_cert_status_cur $ldap_cert_subject" : $l_ldap_cert_status_no ) ?>
784
						</dt>
784
						</dt>
785
						<dd>
785
						<dd>
786
							<input type="file" id="ldap_cert" name="ldap_cert" oninput="onLdapStatusChange();">
786
							<input type="file" id="ldap_cert" name="ldap_cert" oninput="onLdapStatusChange();">
787
						</dd>
787
						</dd>
788
					</dl>
788
					</dl>
789
					<dl>
789
					<dl>
790
						<dt>
790
						<dt>
791
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
791
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
792
							<?= $l_ldap_user_text ?>
792
							<?= $l_ldap_user_text ?>
793
						</dt>
793
						</dt>
794
						<dd>
794
						<dd>
795
							<input type="text" id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>" oninput="onLdapStatusChange();">
795
							<input type="text" id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>" oninput="onLdapStatusChange();">
796
						</dd>
796
						</dd>
797
					</dl>
797
					</dl>
798
					<dl>
798
					<dl>
799
						<dt>
799
						<dt>
800
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
800
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
801
							<?= $l_ldap_password_text ?>
801
							<?= $l_ldap_password_text ?>
802
						</dt>
802
						</dt>
803
						<dd>
803
						<dd>
804
							<input type="password" id="ldap_password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>" oninput="onLdapStatusChange();">
804
							<input type="password" id="ldap_password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>" oninput="onLdapStatusChange();">
805
						</dd>
805
						</dd>
806
					</dl>
806
					</dl>
807
					<dl>
807
					<dl>
808
						<dt>
808
						<dt>
809
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
809
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
810
							<?= $l_ldap_base_dn_text ?>
810
							<?= $l_ldap_base_dn_text ?>
811
						</dt>
811
						</dt>
812
						<dd>
812
						<dd>
813
							<input type="text" id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>" oninput="onLdapStatusChange();">
813
							<input type="text" id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>" oninput="onLdapStatusChange();">
814
						</dd>
814
						</dd>
815
					</dl>
815
					</dl>
816
					<dl>
816
					<dl>
817
						<dt>
817
						<dt>
818
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
818
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
819
							<?= $l_ldap_uid_text ?>
819
							<?= $l_ldap_uid_text ?>
820
						</dt>
820
						</dt>
821
						<dd>
821
						<dd>
822
							<input type="text" id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>" oninput="onLdapStatusChange();">
822
							<input type="text" id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>" oninput="onLdapStatusChange();">
823
						</dd>
823
						</dd>
824
					</dl>
824
					</dl>
825
					<dl>
825
					<dl>
826
						<dt>
826
						<dt>
827
							<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
827
							<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
828
							<?= $l_ldap_base_filter_text ?>
828
							<?= $l_ldap_base_filter_text ?>
829
						</dt>
829
						</dt>
830
						<dd>
830
						<dd>
831
							<input type="text" id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>" oninput="onLdapStatusChange();">
831
							<input type="text" id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>" oninput="onLdapStatusChange();">
832
						</dd>
832
						</dd>
833
					</dl>
833
					</dl>
834
					<dl>
834
					<dl>
835
						<dt>
835
						<dt>
836
							<label for="ad_dns_domain"><?= $l_ad_dns_domain_label ?></label><br>
836
							<label for="ad_dns_domain"><?= $l_ad_dns_domain_label ?></label><br>
837
							<?= $l_ad_dns_domain_text ?>
837
							<?= $l_ad_dns_domain_text ?>
838
						</dt>
838
						</dt>
839
						<dd>
839
						<dd>
840
							<input type="text" id="ad_dns_domain" size="40" name="ad_dns_domain" value="<?= htmlspecialchars($conf['INT_DNS_DOMAIN']) ?>" oninput="onLdapStatusChange();">
840
							<input type="text" id="ad_dns_domain" size="40" name="ad_dns_domain" value="<?= htmlspecialchars($conf['INT_DNS_DOMAIN']) ?>" oninput="onLdapStatusChange();">
841
						</dd>
841
						</dd>
842
					</dl>
842
					</dl>
843
					<p>
843
					<p>
844
						<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>
844
						<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>
845
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit">
845
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit">
846
					</p>
846
					</p>
847
				</fieldset>
847
				</fieldset>
848
			</form>
848
			</form>
849
		</div>
849
		</div>
850
	</div>
850
	</div>
851
</body>
851
</body>
852
</html>
852
</html>
853
 
853