Subversion Repositories ALCASAR

Rev

Rev 2809 | Rev 2853 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
318 richard 1
<?php
2449 tom.houday 2
# $Id: ldap.php 2817 2020-05-09 09:35:56Z rexy $
3
 
2453 tom.houday 4
/* written by steweb57, Rexy & Tom HOUDAYER */
318 richard 5
/****************************************************************
2449 tom.houday 6
*			GLOBAL FILE PATHS			*
318 richard 7
*****************************************************************/
2449 tom.houday 8
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
318 richard 9
 
2449 tom.houday 10
/****************************************************************
11
*			FILE reading test			*
12
*****************************************************************/
13
$conf_files = array(CONF_FILE);
14
foreach ($conf_files as $file) {
15
	if (!file_exists($file)) {
16
		exit("Fichier $file non présent");
17
	}
18
	if (!is_readable($file)) {
19
		exit("Vous n'avez pas les droits de lecture sur le fichier $file");
20
	}
21
}
318 richard 22
 
1160 stephane 23
/****************************************************************
2449 tom.houday 24
*			Read CONF_FILE				*
25
*****************************************************************/
26
$file_conf = fopen(CONF_FILE, 'r');
27
if (!$file_conf) {
28
	exit('Error opening the file '.CONF_FILE);
29
}
30
while (!feof($file_conf)) {
31
	$buffer = fgets($file_conf, 4096);
32
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
33
		$tmp = explode('=', $buffer, 2);
34
		$conf[trim($tmp[0])] = trim($tmp[1]);
35
	}
36
}
37
fclose($file_conf);
38
 
39
/****************************************************************
1672 richard 40
*			Choice of language			*
1160 stephane 41
*****************************************************************/
42
$Language = 'en';
2449 tom.houday 43
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
44
	$Langue	  = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
45
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
46
}
47
if ($Language === 'fr') {		// French
2459 richard 48
	$l_ldap_update			= "Mise à jour des paramètres LDAP effectuée";
1672 richard 49
	$l_ldap_title			= "Authentification externe : LDAP";
50
	$l_ldap_legend			= "Authentification LDAP";
2459 richard 51
	$l_ldap_auth_enable_label	= "Éditer la configuration LDAP:";
1672 richard 52
	$l_ldap_YES			= "OUI";
53
	$l_ldap_NO			= "NON";
1677 richard 54
	$l_ldap_server_label		= "Serveur LDAP:";
2459 richard 55
	$l_ldap_server_text		= "Adresse IP du serveur";
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'";
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'.";
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))'";
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'";
64
	$l_ldap_password_label		= "Mot de passe:";
1673 richard 65
	$l_ldap_password_text		= "Laissez vide pour un accès invité (ou anonyme). Obligatoire sur un AD.";
2705 tom.houday 66
	$l_ldap_ssl_label		= "Connexion chiffré";
67
	$l_ldap_ssl_text		= "Utiliser une connexion chiffré avec SSL (LDAPS)";
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";
70
	$l_ldap_cert_label		= "Certificat SSL (CA)";
71
	$l_ldap_cert_text		= "Certificat de l'authorité de certification signant celui du serveur LDAP";
2718 tom.houday 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é)";
2705 tom.houday 74
	$l_ldap_cert_status_cur		= "Certificat actuel : ";
75
	$l_ldap_cert_status_no		= "Aucun certificat installé";
2461 richard 76
	$l_ldap_submit			= "Enregistrer";
2459 richard 77
	$l_ldap_test_service_failed	= "Service LDAP injoignable sur ce serveur (vérifiez l'@IP).";
2705 tom.houday 78
	$l_ldap_test_service_ok		= "Un port 389 (636 avec SSL) est actif sur ce serveur";
2459 richard 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";
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";
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";
2449 tom.houday 85
	$l_ldap_error			= "erreur LDAP";
2459 richard 86
	$l_ldap_entries			= "entrées dans la base";
2705 tom.houday 87
	$l_ldap_cert_cn_diff_dn		= "Le CommonName du certificat (§cert_domainName§) est différent du nom de domaine du serveur";
2475 tom.houday 88
	$l_check			= "Vérifier cette configuration";
89
	$l_checkingConf			= "Vérification de cette configuration...";
2449 tom.houday 90
} else {				// English
2459 richard 91
	$l_ldap_update			= "LDAP settings updated";
1672 richard 92
	$l_ldap_title			= "External authentication : LDAP";
93
	$l_ldap_legend			= "LDAP authentication";
2459 richard 94
	$l_ldap_auth_enable_label	= "Edit the LDAP configuration :";
1672 richard 95
	$l_ldap_YES			= "YES";
96
	$l_ldap_NO			= "NO";
1677 richard 97
	$l_ldap_server_label		= "LDAP server :";
2459 richard 98
	$l_ldap_server_text		= "IP address of the LDAP server.";
99
	$l_ldap_base_dn_label		= "DN of the base:";
100
	$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'";
101
	$l_ldap_uid_label		= "User IDentifier (UID):";
102
	$l_ldap_uid_text		= "Key used to search for a given login identity.<br>e.g. 'uid', 'sn', etc.. For AD use 'sAMAccountName'.";
103
	$l_ldap_base_filter_label	= "User search filter (optional):";
104
	$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))'";
105
	$l_ldap_user_label		= "CN of the user operated by ALCASAR:";
106
	$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'";
107
	$l_ldap_password_label		= "Password:";
108
	$l_ldap_password_text		= "Leave blank to use anonymous binding. Mandatory for AD.";
2705 tom.houday 109
	$l_ldap_ssl_label		= "Secure connection";
110
	$l_ldap_ssl_text		= "Use an encrypted connection with SSL (LDAPS)";
111
	$l_ldap_cert_required_label	= "Check the SSL certificate";
112
	$l_ldap_cert_required_text	= "Verify that the LDAP server uses a trusted certificate";
113
	$l_ldap_cert_label		= "SSL certificate (CA)";
114
	$l_ldap_cert_text		= "Certificate of the certification authority that signed the LDAP server certificate";
2718 tom.houday 115
	$l_ad_dns_domain_label		= "Internal domain name";
116
	$l_ad_dns_domain_text		= "Domain name that will be forwarded to the DNS server of the LDAP directory (empty for disabled)";
2705 tom.houday 117
	$l_ldap_cert_status_cur		= "Current certificate:";
118
	$l_ldap_cert_status_no		= "No certificate imported";
2461 richard 119
	$l_ldap_submit			= "Save";
2459 richard 120
	$l_ldap_test_service_failed	= "LDAP service is not reachable on that server (check IP)";
2705 tom.houday 121
	$l_ldap_test_service_ok		= "A port 389 (636 with SSL) is open on this server";
2459 richard 122
	$l_ldap_test_connection_failed	= "LDAP connexion failed (check the LDAP service on this server)";
123
	$l_ldap_test_connection_ok	= "A LDAP connexion is established";
124
	$l_ldap_test_bind_failed	= "LDAP authentication failed (check the LDAP user and password)";
125
	$l_ldap_test_bind_ok		= "Successful authentication";
2475 tom.houday 126
	$l_ldap_test_dn_failed		= "DN of the base seems to be wrong (check it)";
127
	$l_ldap_test_dn_ok		= "DN of the base seems to be ok";
2705 tom.houday 128
	$l_ldap_cert_cn_diff_dn		= "Certificate CommonName (§cert_domainName§) is different from the server domain name";
2449 tom.houday 129
	$l_ldap_error			= "LDAP error";
2459 richard 130
	$l_ldap_entries			= "entries in the base";
2475 tom.houday 131
	$l_check			= "Check this config";
132
	$l_checkingConf			= "Checking this configuration...";
1160 stephane 133
}
318 richard 134
 
2718 tom.houday 135
// AJAX LDAP assitant
136
if (isset($_GET['assistant'])) {
137
	$response = [
138
		'values' => []
139
	];
140
	if (!isset($_POST['ldap_server'])) exit();
141
	$ldap_server = $_POST['ldap_server'];
142
 
143
	// Check port 389 & 636
144
	if (!$sock = @fsockopen($ldap_server, 389, $num, $error, 2)) {
145
		$ldap_port_389 = false;
146
		$ldap_srv_389  = false;
147
	} else {
148
		$ldap_port_389 = true;
149
		fclose($sock);
150
	}
151
	if (!$sock = @fsockopen($ldap_server, 636, $num, $error, 2)) {
152
		$ldap_port_636 = false;
153
		$ldap_srv_636  = false;
154
		$ldap_ssl      = false;
155
	} else {
156
		$ldap_port_636 = true;
157
		$ldap_ssl      = true;
158
		fclose($sock);
159
	}
160
 
161
	if (!$ldap_port_389 && !$ldap_port_636) {
162
		$response['result'] = -2;
163
 
164
		header('Content-Type: application/json');
165
		echo json_encode($response);
166
		exit();
167
	}
168
 
169
	// Check LDAP service
170
	if ($ldap_port_636) {
2809 rexy 171
	// Set LDAP SSL options
2718 tom.houday 172
		ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
173
		$ldapconn = @ldap_connect('ldaps://'.$ldap_server);
174
		if (!$ldapconn) {
175
			$ldap_srv_636 = false;
176
		} else {
177
			ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
178
 
179
			// Bind anonymous
180
			$ldap_srv_636 = true;
2731 tom.houday 181
			if (!@ldap_bind($ldapconn)) {
2718 tom.houday 182
				ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
2731 tom.houday 183
				if (!@ldap_bind($ldapconn)) {
2718 tom.houday 184
					$ldap_srv_636 = false;
185
				}
186
			}
187
		}
188
 
189
		if ($ldap_srv_636) {
190
			$ldap_data    = @ldap_read($ldapconn, '', 'objectClass=*', ['dnsHostName','rootDomainNamingContext','supportedCapabilities']);
191
			$ldap_rootDSE = @ldap_get_entries($ldapconn, $ldap_data);
192
 
193
			try {
194
				$response['values']['isAD'] = in_array('1.2.840.113556.1.4.800', $ldap_rootDSE[0]['supportedcapabilities']);
195
			} catch (Exception $e) {
196
				$response['values']['isAD'] = false;
197
			}
198
 
199
			if ($response['values']['isAD']) {
200
				try {
201
					$response['values']['ldap_base_dn'] = $ldap_rootDSE[0]['rootdomainnamingcontext'][0];
202
 
203
					if ($response['values']['ldap_base_dn']) {
204
						$response['values']['int_dns_domain'] = str_replace('DC=', '', str_replace(',DC=', '.', $response['values']['ldap_base_dn']));
205
					}
206
 
207
					$response['values']['ldap_base_dn'] = 'CN=Users,'.$response['values']['ldap_base_dn'];
208
				} catch (Exception $e) { }
209
 
210
				try {
211
					$response['values']['ldap_server_domain'] = $ldap_rootDSE[0]['dnshostname'][0];
212
				} catch (Exception $e) { }
213
			}
214
		}
215
	}
216
	$response['values']['ldap_srv_636'] = $ldap_srv_636;
217
 
218
	if (!$ldap_srv_636) {
219
		$ldapconn = @ldap_connect('ldap://'.$ldap_server);
220
		if (!$ldapconn) {
221
			$ldap_srv_389 = false;
222
		} else {
223
			ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
224
 
225
			// Bind anonymous
226
			$ldap_srv_389 = true;
2731 tom.houday 227
			if (!@ldap_bind($ldapconn)) {
2718 tom.houday 228
				ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
2731 tom.houday 229
				if (!@ldap_bind($ldapconn)) {
2718 tom.houday 230
					$ldap_srv_389 = false;
231
				}
232
			}
233
		}
234
 
235
		if ($ldap_srv_389) {
236
			$ldap_data    = @ldap_read($ldapconn, '', 'objectClass=*', ['dnsHostName','rootDomainNamingContext','supportedCapabilities']);
237
			$ldap_rootDSE = @ldap_get_entries($ldapconn, $ldap_data);
238
 
239
			try {
240
				$response['values']['isAD'] = in_array('1.2.840.113556.1.4.800', $ldap_rootDSE[0]['supportedcapabilities']);
241
			} catch (Exception $e) {
242
				$response['values']['isAD'] = false;
243
			}
244
 
245
			if ($response['values']['isAD']) {
246
				try {
247
					$response['values']['ldap_base_dn'] = $ldap_rootDSE[0]['rootdomainnamingcontext'][0];
248
 
249
					if ($response['values']['ldap_base_dn']) {
250
						$response['values']['int_dns_domain'] = str_replace('DC=', '', str_replace(',DC=', '.', $response['values']['ldap_base_dn']));
251
					}
252
 
253
					$response['values']['ldap_base_dn'] = 'CN=Users,'.$response['values']['ldap_base_dn'];
254
				} catch (Exception $e) { }
255
 
256
				try {
257
					$response['values']['ldap_server_domain'] = $ldap_rootDSE[0]['dnshostname'][0];
258
				} catch (Exception $e) { }
259
			}
260
		}
261
		$response['values']['ldap_srv_389'] = $ldap_srv_389;
262
	}
263
 
264
	if (!$ldap_srv_636 && !$ldap_srv_389) {
265
		$response['result'] = -1;
266
 
267
		header('Content-Type: application/json');
268
		echo json_encode($response);
269
		exit();
270
	}
271
 
272
	$response['result'] = 0;
273
	header('Content-Type: application/json');
274
	echo json_encode($response);
275
	exit();
276
}
277
 
2714 tom.houday 278
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) {
2459 richard 279
	// Socket to the LDAP port of the server
2705 tom.houday 280
	if (!$sock = @fsockopen($f_ldap_server, (($f_ldap_ssl) ? 636 : 389), $num, $error, 2)) {
658 stephane 281
		// no network connection
2459 richard 282
		return -2;
2449 tom.houday 283
	}
284
	fclose($sock);
1395 richard 285
 
2705 tom.houday 286
	// Set LDAP SSL options
287
	if ($f_ldap_ssl) {
288
		if ($f_ldap_cert_required) {
289
			if ($f_ldap_cert) {
2718 tom.houday 290
				ldap_set_option(null, LDAP_OPT_X_TLS_CACERTFILE, $f_ldap_cert);
2705 tom.houday 291
			}
2718 tom.houday 292
			ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_DEMAND);
2705 tom.houday 293
 
294
		} else {
2718 tom.houday 295
			ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
2705 tom.houday 296
		}
297
	}
298
 
2459 richard 299
	// if ok, Test LDAP connection
2705 tom.houday 300
	$ldapconn = @ldap_connect((($f_ldap_ssl)?'ldaps':'ldap').'://'.$f_ldap_server);
2449 tom.houday 301
	if (!$ldapconn) {
302
		// LDAP connection failed
2459 richard 303
		return -1;
620 stephane 304
	}
305
 
2705 tom.houday 306
	ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
307
 
2459 richard 308
	// if ok, test a ldap-bind with the user used by ALCASAR
2705 tom.houday 309
	$ldapbind = @ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
2449 tom.houday 310
	if (!$ldapbind) {
311
		// Test LDAP Version 3
312
		ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
2705 tom.houday 313
		$ldapbind = @ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
2449 tom.houday 314
		if (!$ldapbind) {
315
			// LDAP Bind failed
316
			return 0;
318 richard 317
		}
2449 tom.houday 318
	}
319
 
2459 richard 320
	// if ok, try to query the directory of users
2714 tom.houday 321
	$filter = ((!empty($f_ldap_base_filter)) ? $f_ldap_base_filter : '&');
322
	$query = "(&($f_ldap_uid=*)($filter))";
2705 tom.houday 323
	$ldap_result = @ldap_search($ldapconn, $f_ldap_basedn, $query);
2532 tom.houday 324
	if ($ldap_result) {
2460 tom.houday 325
		$ldap_users_count = ldap_count_entries($ldapconn, $ldap_result);
326
		return ($ldap_users_count + 2);
318 richard 327
	} else {
2449 tom.houday 328
		return 1;
318 richard 329
	}
2459 richard 330
	ldap_unbind($ldapconn);
318 richard 331
}
2449 tom.houday 332
 
2451 tom.houday 333
$messages = '';
2705 tom.houday 334
$LDAPS_CERT_LOC = '/etc/raddb/certs/alcasar-ldaps.crt';
2451 tom.houday 335
 
336
if (isset($_POST['auth_enable'])) {
337
	if ($_POST['auth_enable'] === '1') {
2705 tom.houday 338
		// TODO : need to translate messages
2451 tom.houday 339
		$varErrors = [];
2705 tom.houday 340
		if (isset($_POST['ldap_server']))        $ldap_server        = $_POST['ldap_server'];        else array_push($varErrors, 'Variable error "ldap_server"');
341
		if (isset($_POST['ldap_base_dn']))       $ldap_base_dn       = $_POST['ldap_base_dn'];       else array_push($varErrors, 'Variable error "ldap_base_dn"');
342
		if (isset($_POST['ldap_uid']))           $ldap_uid           = $_POST['ldap_uid'];           else array_push($varErrors, 'Variable error "ldap_uid"');
343
		if (isset($_POST['ldap_base_filter']))   $ldap_base_filter   = $_POST['ldap_base_filter'];   else array_push($varErrors, 'Variable error "ldap_base_filter"');
344
		if (isset($_POST['ldap_user']))          $ldap_user          = $_POST['ldap_user'];          else array_push($varErrors, 'Variable error "ldap_user"');
345
		if (isset($_POST['ldap_password']))      $ldap_password      = $_POST['ldap_password'];      else array_push($varErrors, 'Variable error "ldap_password"');
346
		if (isset($_POST['ldap_ssl']))           $ldap_ssl           = $_POST['ldap_ssl'];           //else array_push($varErrors, 'Variable error "ldap_ssl"');
347
		if (isset($_FILES['ldap_cert']))         $ldap_cert          = $_FILES['ldap_cert'];         //else array_push($varErrors, 'Variable error "ldap_cert"');
348
		if (isset($_POST['ldap_cert_required'])) $ldap_cert_required = $_POST['ldap_cert_required']; //else array_push($varErrors, 'Variable error "ldap_cert_required"');
2451 tom.houday 349
 
2705 tom.houday 350
		if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
351
			if ($ldap_cert_required === 'on') {
352
				$certificateInfos = openssl_x509_parse(file_get_contents($ldap_cert['tmp_name']));
353
				if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
354
					$cert_domainName = implode('.', array_reverse($matches[1]));
355
					if ($cert_domainName !== $ldap_server) {
356
						array_push($varErrors, str_replace("§cert_domainName§", $cert_domainName, $l_ldap_cert_cn_diff_dn));
357
					}
358
				}
2451 tom.houday 359
			}
360
		}
361
 
362
		if (!empty($varErrors)) { 
363
			foreach ($varErrors as $error) {
364
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
365
			}
366
		} else {
367
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
368
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
2459 richard 369
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
2452 tom.houday 370
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
2451 tom.houday 371
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
372
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
2705 tom.houday 373
			exec('sed -i '.escapeshellarg("s/^LDAP_SSL=.*/LDAP_SSL=$ldap_ssl/g").' '.CONF_FILE);
2718 tom.houday 374
			if (isset($ldap_cert_required)) {
375
				exec('sed -i '.escapeshellarg("s/^LDAP_CERT_REQUIRED=.*/LDAP_CERT_REQUIRED=$ldap_cert_required/g").' '.CONF_FILE);
376
			}
2465 richard 377
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
2705 tom.houday 378
			if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
379
				exec('sudo /usr/local/bin/alcasar-ldap.sh --import-cert '.escapeshellarg($ldap_cert['tmp_name']));
380
			}
2451 tom.houday 381
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
2459 richard 382
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
2718 tom.houday 383
 
384
			if ((isset($_POST['ad_dns_domain'])) && ($_POST['ad_dns_domain'] !== $conf['INT_DNS_DOMAIN'])) {
385
				if (filter_var($ldap_server, FILTER_VALIDATE_IP) !== false) {
386
					$ldap_server_ip = $ldap_server;
387
				} else {
388
					$ldap_server_ip = gethostbyname($ldap_server);
389
				}
390
				if (filter_var($ldap_server_ip, FILTER_VALIDATE_IP) !== false) {
391
					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)));
392
					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)));
393
					if (!empty($_POST['ad_dns_domain'])) {
394
						exec('sudo /usr/local/bin/alcasar-dns-local.sh --on');
395
					} else {
396
						exec('sudo /usr/local/bin/alcasar-dns-local.sh --off');
397
					}
398
				}
399
			}
2451 tom.houday 400
		}
401
	} else {
402
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
403
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
2459 richard 404
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
2718 tom.houday 405
 
406
		if ((isset($_POST['ad_dns_domain'])) && (empty($_POST['ad_dns_domain']))) {
407
			exec('sudo /usr/local/bin/alcasar-dns-local.sh --off');
408
		}
2451 tom.houday 409
	}
410
 
411
	// Reload configuration
412
	$file_conf = fopen(CONF_FILE, 'r');
413
	if (!$file_conf) {
414
		exit('Error opening the file '.CONF_FILE);
415
	}
416
	while (!feof($file_conf)) {
417
		$buffer = fgets($file_conf, 4096);
418
		if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
419
			$tmp = explode('=', $buffer, 2);
420
			$conf[trim($tmp[0])] = trim($tmp[1]);
421
		}
422
	}
423
	fclose($file_conf);
424
}
425
 
426
// LDAP configuration params
2705 tom.houday 427
$ldap_status        = ($conf['LDAP'] === 'on');
428
$ldap_server        = $conf['LDAP_SERVER'];
429
$ldap_user          = $conf['LDAP_USER'];
430
$ldap_password      = $conf['LDAP_PASSWORD'];
431
$ldap_base_dn       = $conf['LDAP_BASE'];
432
$ldap_uid	    = $conf['LDAP_UID'];
433
$ldap_base_filter   = $conf['LDAP_FILTER'];
434
$ldap_ssl           = ($conf['LDAP_SSL'] === 'on');
435
$ldap_cert_required = ($conf['LDAP_CERT_REQUIRED'] === 'on');
2451 tom.houday 436
 
2718 tom.houday 437
$ldap_cert_subject = null;
2705 tom.houday 438
if (file_exists($LDAPS_CERT_LOC)) {
439
	$certificateInfos = openssl_x509_parse(file_get_contents($LDAPS_CERT_LOC));
440
	if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
441
		$ldap_cert_subject = implode('.', array_reverse($matches[1]));
442
	}
443
}
444
 
2453 tom.houday 445
// AJAX LDAP configuration checker
446
if (isset($_GET['conf_check'])) {
447
	$response = [
448
		'enable' => $ldap_status
449
	];
450
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
451
		$varErrors = [];
452
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
2705 tom.houday 453
			// TODO : need to translate messages
454
			if (isset($_POST['ldap_server']))        $ldap_server        = $_POST['ldap_server'];                   else array_push($varErrors, 'Variable error "ldap_server"');
455
			if (isset($_POST['ldap_base_dn']))       $ldap_base_dn       = $_POST['ldap_base_dn'];                  else array_push($varErrors, 'Variable error "ldap_base_dn"');
456
			if (isset($_POST['ldap_uid']))           $ldap_uid           = $_POST['ldap_uid'];                      else array_push($varErrors, 'Variable error "ldap_uid"');
457
			if (isset($_POST['ldap_base_filter']))   $ldap_base_filter   = $_POST['ldap_base_filter'];              else array_push($varErrors, 'Variable error "ldap_base_filter"');
458
			if (isset($_POST['ldap_user']))          $ldap_user          = $_POST['ldap_user'];                     else array_push($varErrors, 'Variable error "ldap_user"');
459
			if (isset($_POST['ldap_password']))      $ldap_password      = $_POST['ldap_password'];                 else array_push($varErrors, 'Variable error "ldap_password"');
460
			if (isset($_POST['ldap_ssl']))           $ldap_ssl           = ($_POST['ldap_ssl'] === 'on');           //else array_push($varErrors, 'Variable error "ldap_ssl"');
461
			if (isset($_FILES['ldap_cert']))         $ldap_cert          = $_FILES['ldap_cert'];                    //else array_push($varErrors, 'Variable error "ldap_cert"');
462
			if (isset($_POST['ldap_cert_required'])) $ldap_cert_required = ($_POST['ldap_cert_required'] === 'on'); //else array_push($varErrors, 'Variable error "ldap_cert_required"');
2453 tom.houday 463
		}
464
 
2705 tom.houday 465
		if (($ldap_cert_required) && isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
466
			$ldap_cert_tmpFilename = $ldap_cert['tmp_name'];
467
		} else {
2718 tom.houday 468
			$ldap_cert_tmpFilename = null;
2453 tom.houday 469
		}
470
 
471
		if (!empty($varErrors)) {
472
			$response['errors'] = $varErrors;
2460 tom.houday 473
		} else {
2714 tom.houday 474
			$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);
2705 tom.houday 475
 
476
			if (($result === 0) && ($ldap_ssl && $ldap_cert_required && ((isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) || (file_exists($LDAPS_CERT_LOC))))) {
477
				if (filter_var($ldap_server, FILTER_VALIDATE_IP) !== false) {
478
					if (isset($ldap_cert) && ($ldap_cert['error'] === UPLOAD_ERR_OK)) {
479
						$certificateInfos = openssl_x509_parse(file_get_contents($ldap_cert['tmp_name']));
480
					} else {
481
						$certificateInfos = openssl_x509_parse(file_get_contents($LDAPS_CERT_LOC));
482
					}
483
					if (preg_match_all('@/[a-zA-Z]+=([^/]+)@', $certificateInfos['name'], $matches)) {
484
						$cert_domainName = implode('.', array_reverse($matches[1]));
485
						if ($cert_domainName !== $ldap_server) {
486
							$response['warnings'][] = str_replace("§cert_domainName§", $cert_domainName, $l_ldap_cert_cn_diff_dn);
487
						}
488
					}
2714 tom.houday 489
					$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);
2705 tom.houday 490
					if ($res > 1) {
491
						$result = $res;
492
					}
493
					$result = max($result, $res);
494
				}
495
			}
496
 
497
			$response['result'] = $result;
2453 tom.houday 498
		}
499
	}
500
 
501
	header('Content-Type: application/json');
502
	echo json_encode($response);
503
	exit();
504
}
505
 
620 stephane 506
?>
2449 tom.houday 507
<!DOCTYPE html>
508
<html>
509
<head>
510
	<meta charset="UTF-8">
511
	<title><?= $l_ldap_title ?></title>
2817 rexy 512
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
2449 tom.houday 513
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
514
	<script>
515
	function onLdapStatusChange() {
2705 tom.houday 516
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password', 'ldap_ssl', 'ldap_cert_required', 'ldap_cert'];
2460 tom.houday 517
		var formSubmit = document.querySelector('form input[type="submit"]');
518
		var btn_checkConf = document.getElementById('btn-checkconf');
519
		var isChecked = false;
318 richard 520
 
2453 tom.houday 521
		if (document.getElementById('auth_enable').value === '1') {
2449 tom.houday 522
			for (var i=0; i<listToDisables.length; i++) {
2705 tom.houday 523
				document.getElementById(listToDisables[i]).style.backgroundColor = null;
2449 tom.houday 524
				document.getElementById(listToDisables[i]).disabled = false;
525
			}
2705 tom.houday 526
			if (document.getElementById('ldap_ssl').value === 'off') {
527
				document.getElementById('ldap_cert_required').style.backgroundColor = '#c0c0c0';
528
				document.getElementById('ldap_cert_required').disabled = true;
529
				document.getElementById('ldap_cert').style.backgroundColor = '#c0c0c0';
530
				document.getElementById('ldap_cert').disabled = true;
531
			}
532
			else if (document.getElementById('ldap_cert_required').value === 'off') {
533
				document.getElementById('ldap_cert').style.backgroundColor = '#c0c0c0';
534
				document.getElementById('ldap_cert').disabled = true;
535
			}
2460 tom.houday 536
			formSubmit.style.display = 'none';
537
			btn_checkConf.style.display = null;
2449 tom.houday 538
		} else {
539
			for (var i=0; i<listToDisables.length; i++) {
540
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
541
				document.getElementById(listToDisables[i]).disabled = true;
542
			}
2460 tom.houday 543
			formSubmit.style.display = null;
544
			btn_checkConf.style.display = 'none';
2449 tom.houday 545
		}
546
	}
2453 tom.houday 547
 
548
	function checkConfig() {
2462 tom.houday 549
		var messagesElem = document.querySelector('fieldset > legend > div');
2460 tom.houday 550
		var formSubmit   = document.querySelector('form input[type="submit"]');
551
		var btn_checkConf = document.getElementById('btn-checkconf');
2705 tom.houday 552
		var form = document.getElementById('form-config_ldap');
553
		var post_data = new FormData(form);
554
		post_data.delete('auth_enable');
2460 tom.houday 555
 
2475 tom.houday 556
		messagesElem.innerHTML = '<?= $l_checkingConf ?>';
2460 tom.houday 557
 
2453 tom.houday 558
		var xhr = new XMLHttpRequest();
559
		xhr.onreadystatechange = function() {
560
			if (this.readyState == 4) {
561
				if (this.status == 200) {
562
					var data = JSON.parse(this.responseText);
563
 
2460 tom.houday 564
					var messages = '';
565
 
566
					if (typeof data.result !== 'undefined') {
567
						if (data.result === -2) {
568
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
569
						} else {
570
							messages += "<span style=\"color: green\"><?= $l_ldap_test_service_ok ?></span>";
571
							if (data.result === -1) {
572
								messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
573
							} else {
574
								messages += "<br><span style=\"color: green\"><?= $l_ldap_test_connection_ok ?></span>";
575
								if (data.result === 0) {
576
									messages += "<br><span style=\"color: red\"><?= $l_ldap_test_bind_failed ?></span>";
577
								} else {
578
									messages += "<br><span style=\"color: green\"><?= $l_ldap_test_bind_ok ?></span>";
579
									if (data.result === 1) {
580
										messages += "<br><span style=\"color: red\"><?= $l_ldap_test_dn_failed ?></span>";
581
									} else {
582
										messages += "<br><span style=\"color: green\"><?= $l_ldap_test_dn_ok ?> (" + (data.result - 2) + " <?= $l_ldap_entries?>)</span>";
583
									}
584
								}
585
							}
586
						}
587
					}
588
 
589
					if (data.result > 1) {
590
						formSubmit.style.display = null;
591
						btn_checkConf.style.display = 'none';
2453 tom.houday 592
					} else {
2460 tom.houday 593
						formSubmit.style.display = 'none';
594
						btn_checkConf.style.display = null;
2453 tom.houday 595
					}
596
 
597
					if (typeof data.errors !== 'undefined') {
2460 tom.houday 598
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
2453 tom.houday 599
					}
2705 tom.houday 600
					if (typeof data.warnings !== 'undefined') {
601
						messages += '<br><span style=\"color: orange\">' + data.warnings.join('</span><br><span style=\"color: orange\">') + '</span><br>';
602
					}
2453 tom.houday 603
 
2460 tom.houday 604
					messagesElem.innerHTML = messages;
2453 tom.houday 605
				} else {
2460 tom.houday 606
					messagesElem.innerHTML = 'server error';
2453 tom.houday 607
				}
608
			}
609
		};
610
		xhr.open('POST', 'ldap.php?conf_check', true);
2462 tom.houday 611
		xhr.send(post_data);
2453 tom.houday 612
	}
2718 tom.houday 613
 
614
	function launchAssistant() {
615
		var messagesElem = document.querySelector('fieldset > legend > div');
616
		var dom_ldap_server        = document.getElementById('ldap_server');
617
		var dom_ldap_ssl           = document.getElementById('ldap_ssl');
618
		var dom_ldap_cert_required = document.getElementById('ldap_cert_required');
619
		var dom_ldap_dn            = document.getElementById('ldap_dn');
620
		var dom_ldap_uid           = document.getElementById('ldap_uid');
621
		var dom_ad_dns_domain      = document.getElementById('ad_dns_domain');
622
		post_data = 'ldap_server='+dom_ldap_server.value;
623
 
2731 tom.houday 624
		messagesElem.innerHTML = '';
625
 
2718 tom.houday 626
		var xhr = new XMLHttpRequest();
627
		xhr.onreadystatechange = function() {
628
			if (this.readyState == 4) {
629
				if (this.status == 200) {
630
					var data = JSON.parse(this.responseText);
631
					var messages = '';
632
 
633
					if (typeof data.result !== 'undefined') {
634
						if (data.result === -2) {
635
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
636
						} else if (data.result === -1) {
637
							messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
638
						} else if (data.result === 0) {
639
							if ((typeof data.values.int_dns_domain !== 'undefined') && (dom_ad_dns_domain.value === '')) {
640
								dom_ad_dns_domain.value = data.values.int_dns_domain
641
							}
642
							if ((typeof data.values.ldap_base_dn !== 'undefined') && (dom_ldap_dn.value === '')) {
643
								dom_ldap_dn.value = data.values.ldap_base_dn
644
							}
645
							if (dom_ldap_uid.value === '') {
646
								if (data.values.isAD === true) {
647
									dom_ldap_uid.value = 'sAMAccountName';
648
								} else {
649
									dom_ldap_uid.value = 'uid';
650
								}
651
							}
652
							if (data.values.ldap_srv_636 === true) {
653
								dom_ldap_ssl.value = 'on'
654
								if ((typeof data.values.ldap_server_domain !== 'undefined') && (dom_ldap_cert_required.value === 'on')) {
655
									dom_ldap_server.value = data.values.ldap_server_domain
656
								}
657
							} else {
658
								if (dom_ldap_ssl.value === 'on') {
659
									dom_ldap_ssl.value = 'off';
660
								}
661
							}
662
							onLdapStatusChange();
663
						}
664
					}
665
 
666
					messagesElem.innerHTML = messages;
667
				} else {
668
					messagesElem.innerHTML = 'server error';
669
				}
670
			}
671
		};
672
		xhr.open('POST', 'ldap.php?assistant', true);
673
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
674
		xhr.send(post_data);
675
	}
2449 tom.houday 676
	</script>
677
</head>
2462 tom.houday 678
<body onLoad="onLdapStatusChange();">
2449 tom.houday 679
	<div class="panel">
680
		<div class="panel-header"><?= $l_ldap_legend ?></div>
681
		<div class="panel-body">
2705 tom.houday 682
			<form id="form-config_ldap" name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" enctype="multipart/form-data">
2449 tom.houday 683
				<fieldset>
684
					<legend>
2460 tom.houday 685
						<br>
686
						<div style="text-align: center">
687
							<?php if ($messages): ?>
688
								<?= $messages ?>
689
							<?php endif; ?>
690
						</div>
2449 tom.houday 691
					</legend>
692
					<dl>
693
						<dt>
694
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
695
						</dt>
696
						<dd>
697
							<select id="auth_enable" name="auth_enable" onchange="onLdapStatusChange();">
698
								<option value="1"<?= ($ldap_status)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
699
								<option value="0"<?= (!$ldap_status) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
700
							</select>
701
						</dd>
702
					</dl>
703
					<dl>
704
						<dt>
705
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
706
							<?= $l_ldap_server_text ?>
707
						</dt>
708
						<dd>
2718 tom.houday 709
							<input type="text" id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>" oninput="onLdapStatusChange();"> <button onclick="launchAssistant(); return false;"><?= 'Assistant' ?></button>
2449 tom.houday 710
						</dd>
711
					</dl>
712
					<dl>
713
						<dt>
2718 tom.houday 714
							<label for="ldap_ssl"><?= $l_ldap_ssl_label ?></label><br>
715
							<?= $l_ldap_ssl_text ?><br>
2449 tom.houday 716
						</dt>
717
						<dd>
2718 tom.houday 718
							<select id="ldap_ssl" name="ldap_ssl" onchange="onLdapStatusChange();">
719
								<option value="on"<?= ($ldap_ssl)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
720
								<option value="off"<?= (!$ldap_ssl) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
721
							</select>
2449 tom.houday 722
						</dd>
723
					</dl>
724
					<dl>
725
						<dt>
2718 tom.houday 726
							<label for="ldap_cert_required"><?= $l_ldap_cert_required_label ?></label><br>
727
							<?= $l_ldap_cert_required_text ?><br>
2449 tom.houday 728
						</dt>
729
						<dd>
2718 tom.houday 730
							<select id="ldap_cert_required" name="ldap_cert_required" onchange="onLdapStatusChange();">
731
								<option value="on"<?= ($ldap_cert_required)  ? ' selected="selected"' : '' ?>><?= $l_ldap_YES ?></option>
732
								<option value="off"<?= (!$ldap_cert_required) ? ' selected="selected"' : '' ?>><?= $l_ldap_NO ?></option>
733
							</select>
2449 tom.houday 734
						</dd>
735
					</dl>
736
					<dl>
737
						<dt>
2718 tom.houday 738
							<label for="ldap_cert"><?= $l_ldap_cert_label ?></label><br>
739
							<?= $l_ldap_cert_text ?><br>
740
							<?= (($ldap_cert_subject) ? "$l_ldap_cert_status_cur $ldap_cert_subject" : $l_ldap_cert_status_no ) ?>
2449 tom.houday 741
						</dt>
742
						<dd>
2718 tom.houday 743
							<input type="file" id="ldap_cert" name="ldap_cert" oninput="onLdapStatusChange();">
2449 tom.houday 744
						</dd>
745
					</dl>
746
					<dl>
747
						<dt>
748
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
749
							<?= $l_ldap_user_text ?>
750
						</dt>
751
						<dd>
2475 tom.houday 752
							<input type="text" id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>" oninput="onLdapStatusChange();">
2449 tom.houday 753
						</dd>
754
					</dl>
755
					<dl>
756
						<dt>
757
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
758
							<?= $l_ldap_password_text ?>
759
						</dt>
760
						<dd>
2705 tom.houday 761
							<input type="password" id="ldap_password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>" oninput="onLdapStatusChange();">
2449 tom.houday 762
						</dd>
763
					</dl>
2705 tom.houday 764
					<dl>
765
						<dt>
2718 tom.houday 766
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
767
							<?= $l_ldap_base_dn_text ?>
2705 tom.houday 768
						</dt>
769
						<dd>
2718 tom.houday 770
							<input type="text" id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>" oninput="onLdapStatusChange();">
2705 tom.houday 771
						</dd>
772
					</dl>
773
					<dl>
774
						<dt>
2718 tom.houday 775
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
776
							<?= $l_ldap_uid_text ?>
2705 tom.houday 777
						</dt>
778
						<dd>
2718 tom.houday 779
							<input type="text" id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>" oninput="onLdapStatusChange();">
2705 tom.houday 780
						</dd>
781
					</dl>
782
					<dl>
783
						<dt>
2718 tom.houday 784
							<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
785
							<?= $l_ldap_base_filter_text ?>
2705 tom.houday 786
						</dt>
787
						<dd>
2718 tom.houday 788
							<input type="text" id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>" oninput="onLdapStatusChange();">
2705 tom.houday 789
						</dd>
790
					</dl>
2718 tom.houday 791
					<dl>
792
						<dt>
793
							<label for="ad_dns_domain"><?= $l_ad_dns_domain_label ?></label><br>
794
							<?= $l_ad_dns_domain_text ?>
795
						</dt>
796
						<dd>
797
							<input type="text" id="ad_dns_domain" size="40" name="ad_dns_domain" value="<?= htmlspecialchars($conf['INT_DNS_DOMAIN']) ?>" oninput="onLdapStatusChange();">
798
						</dd>
799
					</dl>
2449 tom.houday 800
					<p>
2461 richard 801
						<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= $l_check ?></button>
2475 tom.houday 802
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit">
2449 tom.houday 803
					</p>
804
				</fieldset>
805
			</form>
806
		</div>
807
	</div>
318 richard 808
</body>
809
</html>