Subversion Repositories ALCASAR

Rev

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

Rev 2459 Rev 2460
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: ldap.php 2459 2017-12-10 22:17:52Z richard $
2
# $Id: ldap.php 2460 2017-12-13 17:53:06Z tom.houdayer $
3
 
3
 
4
/* written by steweb57, Rexy & Tom HOUDAYER */
4
/* written by steweb57, Rexy & Tom HOUDAYER */
5
/****************************************************************
5
/****************************************************************
6
*			GLOBAL FILE PATHS			*
6
*			GLOBAL FILE PATHS			*
7
*****************************************************************/
7
*****************************************************************/
Line 139... Line 139...
139
 
139
 
140
	// if ok, try to query the directory of users
140
	// if ok, try to query the directory of users
141
	$query = $f_ldap_uid."=*";
141
	$query = $f_ldap_uid."=*";
142
	$ldap_result = ldap_search($ldapconn, $f_ldap_basedn, $query);
142
	$ldap_result = ldap_search($ldapconn, $f_ldap_basedn, $query);
143
	if (ldap_search($ldapconn, $f_ldap_basedn, $query)) {
143
	if (ldap_search($ldapconn, $f_ldap_basedn, $query)) {
144
		$ldap_users_number = ldap_count_entries($ldapconn, $ldap_result);
144
		$ldap_users_count = ldap_count_entries($ldapconn, $ldap_result);
145
		return $ldap_users_number;
145
		return ($ldap_users_count + 2);
146
	} else {
146
	} else {
147
		return 1;
147
		return 1;
148
	}
148
	}
149
	ldap_unbind($ldapconn);
149
	ldap_unbind($ldapconn);
150
}
150
}
151
 
151
 
152
$messages = '';
152
$messages = '';
153
$ldap_can_be_enabled = False;
-
 
154
 
153
 
155
if (isset($_POST['auth_enable'])) {
154
if (isset($_POST['auth_enable'])) {
156
	if ($_POST['auth_enable'] === '1') {
155
	if ($_POST['auth_enable'] === '1') {
157
		$varErrors = [];
156
		$varErrors = [];
158
		if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');
157
		if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');
159
		if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');
158
		if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');
160
		if (isset($_POST['ldap_uid']))      $ldap_uid      = $_POST['ldap_uid'];      else array_push($varErrors, 'Variable error "ldap_uid"');
159
		if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');
161
		if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');
160
		if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');
162
		if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');
161
		if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');
163
		if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');
162
		if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');
164
 
163
 
165
		// Validation
164
		// Validation
Line 171... Line 170...
171
				array_push($varErrors, 'Invalid LDAP server IP');
170
				array_push($varErrors, 'Invalid LDAP server IP');
172
			}
171
			}
173
		}
172
		}
174
 
173
 
175
		if (!empty($varErrors)) { 
174
		if (!empty($varErrors)) { 
176
			$messages .= '<div style="text-align: center"><br>';
-
 
177
			foreach ($varErrors as $error) {
175
			foreach ($varErrors as $error) {
178
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
176
				$messages .= '<span style="font-weight: bold; color: red;">'.$error.'</span><br>';
179
			}
177
			}
180
			$messages .= '<br></div>';
-
 
181
		} else {
178
		} else {
182
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
179
			exec('sed -i \'s/^LDAP=.*/LDAP=on/g\' '.CONF_FILE);
183
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
180
			exec('sed -i '.escapeshellarg("s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g").' '.CONF_FILE);
184
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
181
			exec('sed -i '.escapeshellarg("s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g").' '.CONF_FILE);
185
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
182
			exec('sed -i '.escapeshellarg("s/^LDAP_UID=.*/LDAP_UID=$ldap_uid/g").' '.CONF_FILE);
186
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
183
			exec('sed -i '.escapeshellarg("s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_base_filter/g").' '.CONF_FILE);
187
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
184
			exec('sed -i '.escapeshellarg("s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g").' '.CONF_FILE);
188
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
185
			exec('sed -i '.escapeshellarg("s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g").' '.CONF_FILE);
189
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
186
			exec('sudo /usr/local/bin/alcasar-ldap.sh --on');
190
 
187
 
191
			$messages .= '<div style="text-align: center"><br>';
-
 
192
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
188
			$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
193
			$messages .= '<br></div>';
-
 
194
		}
189
		}
195
	} else {
190
	} else {
196
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
191
		exec('sed -i "s/^LDAP=.*/LDAP=off/g" '.CONF_FILE);
197
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
192
		exec('sudo /usr/local/bin/alcasar-ldap.sh --off');
198
 
193
 
199
		$messages .= '<div style="text-align: center"><br>';
-
 
200
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
194
		$messages .= '<span style="font-weight: bold; color: green;">'.$l_ldap_update.'</span><br>';
201
		$messages .= '<br></div>';
-
 
202
	}
195
	}
203
 
196
 
204
	// Reload configuration
197
	// Reload configuration
205
	$file_conf = fopen(CONF_FILE, 'r');
198
	$file_conf = fopen(CONF_FILE, 'r');
206
	if (!$file_conf) {
199
	if (!$file_conf) {
Line 235... Line 228...
235
	// TODO : useless?
228
	// TODO : useless?
236
	$new_ldap_server = explode('//', $ldap_server); // pour discriminer le host et le protocole dans la notation "ldap://192.168.182.10" ou "ldaps://monldap.monentreperise.com"
229
	$new_ldap_server = explode('//', $ldap_server); // pour discriminer le host et le protocole dans la notation "ldap://192.168.182.10" ou "ldaps://monldap.monentreperise.com"
237
} else {
230
} else {
238
	$new_ldap_server = $ldap_server;
231
	$new_ldap_server = $ldap_server;
239
}
232
}
240
if ($ldap_status) {
-
 
241
	$serverCheckResult = ldap_checkServerConfig($new_ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_uid);
-
 
242
}
-
 
243
 
233
 
244
// AJAX LDAP configuration checker
234
// AJAX LDAP configuration checker
245
if (isset($_GET['conf_check'])) {
235
if (isset($_GET['conf_check'])) {
246
	$response = [
236
	$response = [
247
		'enable' => $ldap_status
237
		'enable' => $ldap_status
248
	];
238
	];
249
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
239
	if ($ldap_status || ($_SERVER['REQUEST_METHOD'] === 'POST')) {
250
		$varErrors = [];
240
		$varErrors = [];
251
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
241
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
252
			if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');
242
			if (isset($_POST['ldap_server']))      $ldap_server      = $_POST['ldap_server'];      else array_push($varErrors, 'Variable error "ldap_server"');		// TODO: need to translate
253
			if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');
243
			if (isset($_POST['ldap_base_dn']))     $ldap_base_dn     = $_POST['ldap_base_dn'];     else array_push($varErrors, 'Variable error "ldap_base_dn"');		// TODO: need to translate
254
			if (isset($_POST['ldap_uid']))      $ldap_uid      = $_POST['ldap_uid'];      else array_push($varErrors, 'Variable error "ldap_uid"');
244
			if (isset($_POST['ldap_uid']))         $ldap_uid         = $_POST['ldap_uid'];         else array_push($varErrors, 'Variable error "ldap_uid"');		// TODO: need to translate
255
			if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');
245
			if (isset($_POST['ldap_base_filter'])) $ldap_base_filter = $_POST['ldap_base_filter']; else array_push($varErrors, 'Variable error "ldap_base_filter"');	// TODO: need to translate
256
			if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');
246
			if (isset($_POST['ldap_user']))        $ldap_user        = $_POST['ldap_user'];        else array_push($varErrors, 'Variable error "ldap_user"');		// TODO: need to translate
257
			if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');
247
			if (isset($_POST['ldap_password']))    $ldap_password    = $_POST['ldap_password'];    else array_push($varErrors, 'Variable error "ldap_password"');		// TODO: need to translate
258
		}
248
		}
259
 
249
 
260
		// Validation
250
		// Validation
261
		if (isset($ldap_server)) {
251
		if (isset($ldap_server)) {
262
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
252
			if ((!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) && (preg_match('/^[a-zA-Z0-9-_.]+$/', $ldap_server))) {
263
				$ldap_server = gethostbyname($ldap_server);
253
				$ldap_server = gethostbyname($ldap_server);
264
			}
254
			}
265
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
255
			if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ldap_server)) {
266
				array_push($varErrors, 'Invalid LDAP server IP');
256
				array_push($varErrors, 'Invalid LDAP server IP');	// TODO: need to translate
267
			}
257
			}
268
		}
258
		}
269
 
259
 
270
		$response['result'] = (ldap_checkServerConfig($ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_uid) > 0);
-
 
271
 
-
 
272
		if (!empty($varErrors)) {
260
		if (!empty($varErrors)) {
273
			$response['errors'] = $varErrors;
261
			$response['errors'] = $varErrors;
-
 
262
		} else {
-
 
263
			$response['result'] = ldap_checkServerConfig($ldap_server, $ldap_user, $ldap_password, $ldap_base_dn, $ldap_uid);
274
		}
264
		}
275
	}
265
	}
276
 
266
 
277
	header('Content-Type: application/json');
267
	header('Content-Type: application/json');
278
	echo json_encode($response);
268
	echo json_encode($response);
Line 287... Line 277...
287
	<title><?= $l_ldap_title ?></title>
277
	<title><?= $l_ldap_title ?></title>
288
	<link type="text/css" href="/css/style.css" rel="stylesheet">
278
	<link type="text/css" href="/css/style.css" rel="stylesheet">
289
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
279
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
290
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
280
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
291
	<script>
281
	<script>
-
 
282
	function onPageLoad() {
-
 
283
		onLdapStatusChange();
-
 
284
		if (document.getElementById('auth_enable').value === '1') {
-
 
285
			checkConfig();
-
 
286
		}
-
 
287
	}
-
 
288
 
292
	function onLdapStatusChange() {
289
	function onLdapStatusChange() {
293
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password'];
290
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password'];
-
 
291
		var formSubmit = document.querySelector('form input[type="submit"]');
-
 
292
		var btn_checkConf = document.getElementById('btn-checkconf');
-
 
293
		var isChecked = false;
294
 
294
 
295
		if (document.getElementById('auth_enable').value === '1') {
295
		if (document.getElementById('auth_enable').value === '1') {
296
			for (var i=0; i<listToDisables.length; i++) {
296
			for (var i=0; i<listToDisables.length; i++) {
297
				document.getElementById(listToDisables[i]).style.backgroundColor = '#ffffff';
297
				document.getElementById(listToDisables[i]).style.backgroundColor = '#ffffff';
298
				document.getElementById(listToDisables[i]).disabled = false;
298
				document.getElementById(listToDisables[i]).disabled = false;
299
			}
299
			}
-
 
300
			formSubmit.style.display = 'none';
-
 
301
			btn_checkConf.style.display = null;
300
		} else {
302
		} else {
301
			for (var i=0; i<listToDisables.length; i++) {
303
			for (var i=0; i<listToDisables.length; i++) {
302
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
304
				document.getElementById(listToDisables[i]).style.backgroundColor = '#c0c0c0';
303
				document.getElementById(listToDisables[i]).disabled = true;
305
				document.getElementById(listToDisables[i]).disabled = true;
304
			}
306
			}
-
 
307
			formSubmit.style.display = null;
-
 
308
			btn_checkConf.style.display = 'none';
305
		}
309
		}
306
	}
310
	}
307
 
311
 
308
	function checkConfig() {
312
	function checkConfig() {
-
 
313
		var messagesElem = document.querySelector('fieldset > legend > div:last-child');
-
 
314
		var formSubmit   = document.querySelector('form input[type="submit"]');
-
 
315
		var btn_checkConf = document.getElementById('btn-checkconf');
-
 
316
 
309
		var ldap_config = {
317
		var ldap_config = {
310
			ldap_status:     (document.getElementById('auth_enable').value === '1'),
318
			ldap_status:     (document.getElementById('auth_enable').value === '1'),
311
			ldap_server:      document.getElementById('ldap_server').value,
319
			ldap_server:      document.getElementById('ldap_server').value,
312
			ldap_user:        document.getElementById('ldap_user').value,
320
			ldap_user:        document.getElementById('ldap_user').value,
313
			ldap_password:    document.getElementById('ldap_password').value,
321
			ldap_password:    document.getElementById('ldap_password').value,
314
			ldap_base_dn:     document.getElementById('ldap_dn').value,
322
			ldap_base_dn:     document.getElementById('ldap_dn').value,
315
			ldap_uid:      document.getElementById('ldap_uid').value,
323
			ldap_uid:         document.getElementById('ldap_uid').value,
316
			ldap_base_filter: document.getElementById('ldap_base_filter').value
324
			ldap_base_filter: document.getElementById('ldap_base_filter').value
317
		};
325
		};
318
 
326
 
319
		console.log(ldap_config);
-
 
320
 
-
 
321
		var params = Object.keys(ldap_config).map( function (k) { return encodeURIComponent(k) + '=' + encodeURIComponent(ldap_config[k]) } ).join('&');
327
		var params = Object.keys(ldap_config).map( function (k) { return encodeURIComponent(k) + '=' + encodeURIComponent(ldap_config[k]) } ).join('&');
322
 
328
 
-
 
329
		messagesElem.innerHTML = '<?= 'Checking configuration...' /* TODO: need to translate */ ?>';
-
 
330
 
323
		var xhr = new XMLHttpRequest();
331
		var xhr = new XMLHttpRequest();
324
		xhr.onreadystatechange = function() {
332
		xhr.onreadystatechange = function() {
325
			if (this.readyState == 4) {
333
			if (this.readyState == 4) {
326
				if (this.status == 200) {
334
				if (this.status == 200) {
327
					var data = JSON.parse(this.responseText);
335
					var data = JSON.parse(this.responseText);
328
 
336
 
-
 
337
					var messages = '';
-
 
338
 
-
 
339
					if (typeof data.result !== 'undefined') {
329
					if (data.result === true) {
340
						if (data.result === -2) {
-
 
341
							messages += "<span style=\"color: red\"><?= $l_ldap_test_service_failed ?></span>";
-
 
342
						} else {
-
 
343
							messages += "<span style=\"color: green\"><?= $l_ldap_test_service_ok ?></span>";
-
 
344
							if (data.result === -1) {
-
 
345
								messages += "<br><span style=\"color: red\"><?= $l_ldap_test_connection_failed ?></span>";
-
 
346
							} else {
-
 
347
								messages += "<br><span style=\"color: green\"><?= $l_ldap_test_connection_ok ?></span>";
-
 
348
								if (data.result === 0) {
-
 
349
									messages += "<br><span style=\"color: red\"><?= $l_ldap_test_bind_failed ?></span>";
-
 
350
								} else {
-
 
351
									messages += "<br><span style=\"color: green\"><?= $l_ldap_test_bind_ok ?></span>";
-
 
352
									if (data.result === 1) {
-
 
353
										messages += "<br><span style=\"color: red\"><?= $l_ldap_test_dn_failed ?></span>";
-
 
354
									} else {
-
 
355
										messages += "<br><span style=\"color: green\"><?= $l_ldap_test_dn_ok ?> (" + (data.result - 2) + " <?= $l_ldap_entries?>)</span>";
-
 
356
									}
-
 
357
								}
-
 
358
							}
-
 
359
						}
-
 
360
					}
-
 
361
 
-
 
362
					if (data.result > 1) {
-
 
363
						formSubmit.style.display = null;
330
						alert('Configuration valide');
364
						btn_checkConf.style.display = 'none';
331
					} else {
365
					} else {
-
 
366
						formSubmit.style.display = 'none';
332
						alert('Configuration non valide');
367
						btn_checkConf.style.display = null;
333
					}
368
					}
334
 
369
 
335
					if (typeof data.errors !== 'undefined') {
370
					if (typeof data.errors !== 'undefined') {
336
						alert(data.errors.join("\n"));
371
						messages = '<span style=\"color: red\">' + data.errors.join('</span><br><span style=\"color: red\">') + '</span><br>';
337
					}
372
					}
338
 
373
 
339
					console.log(data)
374
					messagesElem.innerHTML = messages;
340
				} else {
375
				} else {
341
					console.log(this.responseText)
376
					messagesElem.innerHTML = 'server error';
342
				}
377
				}
343
			}
378
			}
344
		};
379
		};
345
		xhr.open('POST', 'ldap.php?conf_check', true);
380
		xhr.open('POST', 'ldap.php?conf_check', true);
346
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
381
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
347
		xhr.send(params);
382
		xhr.send(params);
348
	}
383
	}
349
	</script>
384
	</script>
350
</head>
385
</head>
351
<body onLoad="onLdapStatusChange();">
386
<body onLoad="onPageLoad();">
352
	<div class="panel">
387
	<div class="panel">
353
		<div class="panel-header"><?= $l_ldap_legend ?></div>
388
		<div class="panel-header"><?= $l_ldap_legend ?></div>
354
		<div class="panel-body">
389
		<div class="panel-body">
355
			<form name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
390
			<form name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
356
				<fieldset>
391
				<fieldset>
357
					<legend>
392
					<legend>
358
						<?= $messages ?>
393
						<br>
359
						<?php if ($ldap_status): ?>
-
 
360
							<div style="text-align: center"><br>
394
						<div style="text-align: center">
361
								<?php if ($serverCheckResult === -2): ?>
395
							<?php if ($messages): ?>
362
									<span style="color: red"><?= $l_ldap_test_service_failed ?></span>
-
 
363
								<?php elseif ($serverCheckResult === -1): ?>
-
 
364
									<span style="color: green"><?= $l_ldap_test_service_ok ?></span><br>
-
 
365
									<span style="color: red"><?= $l_ldap_test_connection_failed ?></span>
-
 
366
								<?php elseif ($serverCheckResult === 0): ?>
-
 
367
									<span style="color: green"><?= $l_ldap_test_service_ok ?></span><br>
-
 
368
									<span style="color: green"><?= $l_ldap_test_connection_ok ?></span><br>
-
 
369
									<span style="color: red"><?= $l_ldap_test_bind_failed ?></span>
-
 
370
								<?php elseif ($serverCheckResult === 1): ?>
-
 
371
									<span style="color: green"><?= $l_ldap_test_service_ok ?></span><br>
-
 
372
									<span style="color: green"><?= $l_ldap_test_connection_ok ?></span><br>
-
 
373
									<span style="color: green"><?= $l_ldap_test_bind_ok ?></span><br>
-
 
374
									<span style="color: red"><?= $l_ldap_test_dn_failed ?></span>
-
 
375
								<?php elseif ($serverCheckResult > 1): ?>
-
 
376
									<span style="color: green"><?= $l_ldap_test_service_ok ?></span><br>
-
 
377
									<span style="color: green"><?= $l_ldap_test_connection_ok ?></span><br>
-
 
378
									<span style="color: green"><?= $l_ldap_test_bind_ok ?></span><br>
-
 
379
									<span style="color: green"><?= $l_ldap_test_dn_ok." ($serverCheckResult $l_ldap_entries)"; $ldap_can_be_enabled = True;?></span>
-
 
380
								<?php else: ?>
396
								<?= $messages ?>
381
									<span><?= $l_ldap_error ?></span>
-
 
382
								<?php endif ?>
397
							<?php endif; ?>
383
								<br><br>
-
 
384
							</div>
398
						</div>
385
						<?php endif ?>
399
						<div style="text-align: center"></div>
386
					</legend>
400
					</legend>
387
					<dl>
401
					<dl>
388
						<dt>
402
						<dt>
389
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
403
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
390
						</dt>
404
						</dt>
Line 399... Line 413...
399
						<dt>
413
						<dt>
400
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
414
							<label for="ldap_server"><?= $l_ldap_server_label ?></label><br>
401
							<?= $l_ldap_server_text ?>
415
							<?= $l_ldap_server_text ?>
402
						</dt>
416
						</dt>
403
						<dd>
417
						<dd>
404
							<input id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>">
418
							<input id="ldap_server" size="40" name="ldap_server" value="<?= htmlspecialchars($ldap_server) ?>" oninput="onLdapStatusChange();">
405
						</dd>
419
						</dd>
406
					</dl>
420
					</dl>
407
					<dl>
421
					<dl>
408
						<dt>
422
						<dt>
409
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
423
							<label for="ldap_dn"><?= $l_ldap_base_dn_label ?></label><br>
410
							<?= $l_ldap_base_dn_text ?>
424
							<?= $l_ldap_base_dn_text ?>
411
						</dt>
425
						</dt>
412
						<dd>
426
						<dd>
413
							<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>">
427
							<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?= htmlspecialchars($ldap_base_dn) ?>" oninput="onLdapStatusChange();">
414
						</dd>
428
						</dd>
415
					</dl>
429
					</dl>
416
					<dl>
430
					<dl>
417
						<dt>
431
						<dt>
418
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
432
							<label for="ldap_uid"><?= $l_ldap_uid_label ?></label><br>
419
							<?= $l_ldap_uid_text ?>
433
							<?= $l_ldap_uid_text ?>
420
						</dt>
434
						</dt>
421
						<dd>
435
						<dd>
422
							<input id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>">
436
							<input id="ldap_uid" size="40" name="ldap_uid" value="<?= htmlspecialchars($ldap_uid) ?>" oninput="onLdapStatusChange();">
423
						</dd>
437
						</dd>
424
					</dl>
438
					</dl>
425
					<dl>
439
					<dl>
426
						<dt>
440
						<dt>
427
							<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
441
							<label for="ldap_base_filter"><?= $l_ldap_base_filter_label ?></label><br>
428
							<?= $l_ldap_base_filter_text ?>
442
							<?= $l_ldap_base_filter_text ?>
429
						</dt>
443
						</dt>
430
						<dd>
444
						<dd>
431
							<input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>">
445
							<input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?= htmlspecialchars($ldap_base_filter) ?>" oninput="onLdapStatusChange();">
432
						</dd>
446
						</dd>
433
					</dl>
447
					</dl>
434
					<dl>
448
					<dl>
435
						<dt>
449
						<dt>
436
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
450
							<label for="ldap_user"><?= $l_ldap_user_label ?></label><br>
437
							<?= $l_ldap_user_text ?>
451
							<?= $l_ldap_user_text ?>
438
						</dt>
452
						</dt>
439
						<dd>
453
						<dd>
440
							<input id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>">
454
							<input id="ldap_user" size="40" name="ldap_user" value="<?= htmlspecialchars($ldap_user) ?>" oninput="onLdapStatusChange();">
441
						</dd>
455
						</dd>
442
					</dl>
456
					</dl>
443
					<dl>
457
					<dl>
444
						<dt>
458
						<dt>
445
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
459
							<label for="ldap_password"><?= $l_ldap_password_label ?></label><br>
446
							<?= $l_ldap_password_text ?>
460
							<?= $l_ldap_password_text ?>
447
						</dt>
461
						</dt>
448
						<dd>
462
						<dd>
449
							<input id="ldap_password" type="password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>">
463
							<input id="ldap_password" type="password" size="40" name="ldap_password" value="<?= htmlspecialchars($ldap_password) ?>" oninput="onLdapStatusChange();">
450
						</dd>
464
						</dd>
451
					</dl>
465
					</dl>
452
					<p>
466
					<p>
453
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit">
467
						<button id="btn-checkconf" onclick="checkConfig(); return false;"><?= 'Check' /* TODO: need to translate */ ?></button>
454
						<? if ($ldap_can_be_enabled === True) {echo "<input id=\"push_config\" value=\"$l_ldap_push_config\" name=\"push_config_button\">";}?>
468
						<input id="submit" type="submit" value="<?= $l_ldap_submit ?>" name="submit" title="<?= 'You need to check before submit'  /* TODO: need to translate */ ?>">
455
					</p>
469
					</p>
456
				</fieldset>
470
				</fieldset>
457
			</form>
471
			</form>
458
		</div>
472
		</div>
459
	</div>
473
	</div>