Project

General

Profile

Download (26.5 KB) Statistics
| Branch: | Tag: | Revision:
1 fbf672cb Matthew Grooms
<?php
2
/*
3 c5d81585 Renato Botelho
 * system_authservers.php
4 ac9d8bed Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 b8f91b7c Luiz Souza
 * Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
7 c5d81585 Renato Botelho
 * Copyright (c) 2008 Shrew Soft Inc
8
 * All rights reserved.
9 ac9d8bed Stephen Beaver
 *
10 b12ea3fb Renato Botelho
 * Licensed under the Apache License, Version 2.0 (the "License");
11
 * you may not use this file except in compliance with the License.
12
 * You may obtain a copy of the License at
13 ac9d8bed Stephen Beaver
 *
14 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
15 ac9d8bed Stephen Beaver
 *
16 b12ea3fb Renato Botelho
 * Unless required by applicable law or agreed to in writing, software
17
 * distributed under the License is distributed on an "AS IS" BASIS,
18
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
 * See the License for the specific language governing permissions and
20
 * limitations under the License.
21 ac9d8bed Stephen Beaver
 */
22 fbf672cb Matthew Grooms
23
##|+PRIV
24
##|*IDENT=page-system-authservers
25
##|*NAME=System: Authentication Servers
26
##|*DESCR=Allow access to the 'System: Authentication Servers' page.
27 57188e47 Phil Davis
##|*WARN=standard-warning-root
28 fbf672cb Matthew Grooms
##|*MATCH=system_authservers.php*
29
##|-PRIV
30
31 c81ef6e2 Phil Davis
require_once("guiconfig.inc");
32 acee624f Ermal Lu?i
require_once("auth.inc");
33 b4097bca doktornotor
require_once("pfsense-utils.inc");
34 fbf672cb Matthew Grooms
35 098604d3 Stephen Beaver
// Have we been called to populate the "Select a container" modal?
36
if ($_REQUEST['ajax']) {
37
38
	$ous = array();
39
	$authcfg = array();
40
41
	$authcfg['ldap_port'] = $_REQUEST['port'];
42
	$authcfg['ldap_basedn'] = $_REQUEST['basedn'];
43
	$authcfg['host'] = $_REQUEST['host'];
44
	$authcfg['ldap_scope'] = $_REQUEST['scope'];
45
	$authcfg['ldap_binddn'] = $_REQUEST['binddn'];
46
	$authcfg['ldap_bindpw'] = $_REQUEST['bindpw'];
47
	$authcfg['ldap_urltype'] = $_REQUEST['urltype'];
48
	$authcfg['ldap_protver'] = $_REQUEST['proto'];
49
	$authcfg['ldap_authcn'] = explode(";", $_REQUEST['authcn']);
50
	$authcfg['ldap_caref'] = $_REQUEST['cert'];
51
52
	$ous = ldap_get_user_ous(true, $authcfg);
53
54
	if (empty($ous)) {
55 89140b63 NOYB
		print('<span class="text-danger">Could not connect to the LDAP server. Please check the LDAP configuration.</span>');
56 098604d3 Stephen Beaver
	} else {
57 697b1e07 Stephen Beaver
		$modal = new Modal("Select LDAP containers for authentication", "containers", true);
58 098604d3 Stephen Beaver
		$group = new Form_MultiCheckboxGroup('Containers');
59
60
		if (is_array($ous)) {
61
			$idx = 0;
62
63
			foreach ($ous as $ou) {
64
				$group->add(new Form_MultiCheckbox(
65
					'ou' . $idx,
66
					'',
67
					$ou,
68
					in_array($ou, $authcfg['ldap_authcn']),
69
					$ou
70
				));
71
72
				$idx++;
73
			}
74
		}
75
76 697b1e07 Stephen Beaver
		$modal->add($group);
77 098604d3 Stephen Beaver
78
		// Create a "Save button"
79 697b1e07 Stephen Beaver
80
		$btnsv = new Form_Button(
81 098604d3 Stephen Beaver
			'svcontbtn',
82
			'Save',
83
			null,
84
			'fa-save'
85
		);
86
87 697b1e07 Stephen Beaver
		$btnsv->removeClass("btn-default)")->addClass("btn-primary");
88 098604d3 Stephen Beaver
89 697b1e07 Stephen Beaver
		$modal->addInput(new Form_StaticText(
90 098604d3 Stephen Beaver
			'',
91 697b1e07 Stephen Beaver
			$btnsv
92 098604d3 Stephen Beaver
		));
93
94 697b1e07 Stephen Beaver
		print($modal);
95 098604d3 Stephen Beaver
	}
96
97
	exit;
98
}
99
100 4611e283 Steve Beaver
$id = $_REQUEST['id'];
101 fbf672cb Matthew Grooms
102 2ee8dea1 Phil Davis
if (!is_array($config['system']['authserver'])) {
103 fbf672cb Matthew Grooms
	$config['system']['authserver'] = array();
104 2ee8dea1 Phil Davis
}
105 fbf672cb Matthew Grooms
106 4e4cac0d jim-p
$a_server = array_values(auth_get_authserver_list());
107 59d06739 Steve Beaver
108 fbf672cb Matthew Grooms
109 2ee8dea1 Phil Davis
if (!is_array($config['ca'])) {
110 a0165602 Sjon Hortensius
	$config['ca'] = array();
111 2ee8dea1 Phil Davis
}
112 59d06739 Steve Beaver
113 fe2031ab Ermal
$a_ca =& $config['ca'];
114
115 4611e283 Steve Beaver
$act = $_REQUEST['act'];
116 fbf672cb Matthew Grooms
117 4611e283 Steve Beaver
if ($_POST['act'] == "del") {
118 fbf672cb Matthew Grooms
119 59d06739 Steve Beaver
	if (!$a_server[$_POST['id']]) {
120 fbf672cb Matthew Grooms
		pfSenseHeader("system_authservers.php");
121
		exit;
122
	}
123
124 9db6993f jim-p
	/* Remove server from main list. */
125 59d06739 Steve Beaver
	$serverdeleted = $a_server[$_POST['id']]['name'];
126 9db6993f jim-p
	foreach ($config['system']['authserver'] as $k => $as) {
127 2ee8dea1 Phil Davis
		if ($config['system']['authserver'][$k]['name'] == $serverdeleted) {
128 9db6993f jim-p
			unset($config['system']['authserver'][$k]);
129 2ee8dea1 Phil Davis
		}
130 9db6993f jim-p
	}
131
132
	/* Remove server from temp list used later on this page. */
133 59d06739 Steve Beaver
	unset($a_server[$_POST['id']]);
134 4e4cac0d jim-p
	$a_server = array_values($a_server);
135 9db6993f jim-p
136 8545adde k-paulius
	$savemsg = sprintf(gettext("Authentication Server %s deleted."), htmlspecialchars($serverdeleted));
137 9db6993f jim-p
	write_config($savemsg);
138 fbf672cb Matthew Grooms
}
139
140
if ($act == "edit") {
141
	if (isset($id) && $a_server[$id]) {
142
143
		$pconfig['type'] = $a_server[$id]['type'];
144
		$pconfig['name'] = $a_server[$id]['name'];
145
146
		if ($pconfig['type'] == "ldap") {
147 fe2031ab Ermal
			$pconfig['ldap_caref'] = $a_server[$id]['ldap_caref'];
148 fbf672cb Matthew Grooms
			$pconfig['ldap_host'] = $a_server[$id]['host'];
149
			$pconfig['ldap_port'] = $a_server[$id]['ldap_port'];
150 d6b4dfe3 jim-p
			$pconfig['ldap_timeout'] = $a_server[$id]['ldap_timeout'];
151 fbf672cb Matthew Grooms
			$pconfig['ldap_urltype'] = $a_server[$id]['ldap_urltype'];
152
			$pconfig['ldap_protver'] = $a_server[$id]['ldap_protver'];
153
			$pconfig['ldap_scope'] = $a_server[$id]['ldap_scope'];
154
			$pconfig['ldap_basedn'] = $a_server[$id]['ldap_basedn'];
155 c61e4626 Ermal Lu?i
			$pconfig['ldap_authcn'] = $a_server[$id]['ldap_authcn'];
156 c7073ebf namezero111111
			$pconfig['ldap_extended_enabled'] = $a_server[$id]['ldap_extended_enabled'];
157
			$pconfig['ldap_extended_query'] = $a_server[$id]['ldap_extended_query'];
158 fbf672cb Matthew Grooms
			$pconfig['ldap_binddn'] = $a_server[$id]['ldap_binddn'];
159
			$pconfig['ldap_bindpw'] = $a_server[$id]['ldap_bindpw'];
160
			$pconfig['ldap_attr_user'] = $a_server[$id]['ldap_attr_user'];
161
			$pconfig['ldap_attr_group'] = $a_server[$id]['ldap_attr_group'];
162
			$pconfig['ldap_attr_member'] = $a_server[$id]['ldap_attr_member'];
163 149efbea jim-p
			$pconfig['ldap_attr_groupobj'] = $a_server[$id]['ldap_attr_groupobj'];
164 a5cd1c5a jim-p
			$pconfig['ldap_utf8'] = isset($a_server[$id]['ldap_utf8']);
165
			$pconfig['ldap_nostrip_at'] = isset($a_server[$id]['ldap_nostrip_at']);
166 149efbea jim-p
			$pconfig['ldap_rfc2307'] = isset($a_server[$id]['ldap_rfc2307']);
167 fbf672cb Matthew Grooms
168 2ee8dea1 Phil Davis
			if (!$pconfig['ldap_binddn'] || !$pconfig['ldap_bindpw']) {
169 fbf672cb Matthew Grooms
				$pconfig['ldap_anon'] = true;
170 2ee8dea1 Phil Davis
			}
171 fbf672cb Matthew Grooms
		}
172
173
		if ($pconfig['type'] == "radius") {
174 9da4a575 Renato Botelho
			$pconfig['radius_protocol'] = $a_server[$id]['radius_protocol'];
175 fbf672cb Matthew Grooms
			$pconfig['radius_host'] = $a_server[$id]['host'];
176
			$pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port'];
177
			$pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port'];
178 e8a58de4 Ermal Lu?i
			$pconfig['radius_secret'] = $a_server[$id]['radius_secret'];
179 bddd2be8 jim-p
			$pconfig['radius_timeout'] = $a_server[$id]['radius_timeout'];
180 fbf672cb Matthew Grooms
181
			if ($pconfig['radius_auth_port'] &&
182 ac9d8bed Stephen Beaver
				$pconfig['radius_acct_port']) {
183 fbf672cb Matthew Grooms
				$pconfig['radius_srvcs'] = "both";
184
			}
185
186 2ee8dea1 Phil Davis
			if ($pconfig['radius_auth_port'] &&
187 ac9d8bed Stephen Beaver
				!$pconfig['radius_acct_port']) {
188 fbf672cb Matthew Grooms
				$pconfig['radius_srvcs'] = "auth";
189 acee624f Ermal Lu?i
				$pconfig['radius_acct_port'] = 1813;
190 fbf672cb Matthew Grooms
			}
191
192
			if (!$pconfig['radius_auth_port'] &&
193 ac9d8bed Stephen Beaver
				$pconfig['radius_acct_port']) {
194 fbf672cb Matthew Grooms
				$pconfig['radius_srvcs'] = "acct";
195 acee624f Ermal Lu?i
				$pconfig['radius_auth_port'] = 1812;
196 fbf672cb Matthew Grooms
			}
197
198
		}
199
	}
200
}
201
202
if ($act == "new") {
203
	$pconfig['ldap_protver'] = 3;
204
	$pconfig['ldap_anon'] = true;
205 9da4a575 Renato Botelho
	$pconfig['radius_protocol'] = "MSCHAPv2";
206 fbf672cb Matthew Grooms
	$pconfig['radius_srvcs'] = "both";
207 acee624f Ermal Lu?i
	$pconfig['radius_auth_port'] = "1812";
208
	$pconfig['radius_acct_port'] = "1813";
209 fbf672cb Matthew Grooms
}
210
211 59d06739 Steve Beaver
if ($_POST['save']) {
212 fbf672cb Matthew Grooms
	unset($input_errors);
213
	$pconfig = $_POST;
214
215
	/* input validation */
216
217
	if ($pconfig['type'] == "ldap") {
218 2ee8dea1 Phil Davis
		$reqdfields = explode(" ",
219
			"name type ldap_host ldap_port " .
220
			"ldap_urltype ldap_protver ldap_scope " .
221
			"ldap_attr_user ldap_attr_group ldap_attr_member ldapauthcontainers");
222 7b4b0ad3 Stephen Beaver
223 257705ca Renato Botelho
		$reqdfieldsn = array(
224
			gettext("Descriptive name"),
225
			gettext("Type"),
226
			gettext("Hostname or IP"),
227
			gettext("Port value"),
228
			gettext("Transport"),
229
			gettext("Protocol version"),
230
			gettext("Search level"),
231
			gettext("User naming Attribute"),
232
			gettext("Group naming Attribute"),
233
			gettext("Group member attribute"),
234
			gettext("Authentication container"));
235 fbf672cb Matthew Grooms
236
		if (!$pconfig['ldap_anon']) {
237
			$reqdfields[] = "ldap_binddn";
238
			$reqdfields[] = "ldap_bindpw";
239 257705ca Renato Botelho
			$reqdfieldsn[] = gettext("Bind user DN");
240
			$reqdfieldsn[] = gettext("Bind Password");
241 fbf672cb Matthew Grooms
		}
242
	}
243
244
	if ($pconfig['type'] == "radius") {
245 9da4a575 Renato Botelho
		$reqdfields = explode(" ", "name type radius_protocol radius_host radius_srvcs");
246 257705ca Renato Botelho
		$reqdfieldsn = array(
247
			gettext("Descriptive name"),
248
			gettext("Type"),
249 9da4a575 Renato Botelho
			gettext("Radius Protocol"),
250 257705ca Renato Botelho
			gettext("Hostname or IP"),
251
			gettext("Services"));
252 fbf672cb Matthew Grooms
253 0a6ab475 hamnur
		if ($pconfig['radius_srvcs'] == "both" ||
254
			$pconfig['radius_srvcs'] == "auth") {
255 fbf672cb Matthew Grooms
			$reqdfields[] = "radius_auth_port";
256 81ec3187 Chris Buechler
			$reqdfieldsn[] = gettext("Authentication port");
257 fbf672cb Matthew Grooms
		}
258
259 0a6ab475 hamnur
		if ($pconfig['radius_srvcs'] == "both" ||
260
			$pconfig['radius_srvcs'] == "acct") {
261 fbf672cb Matthew Grooms
			$reqdfields[] = "radius_acct_port";
262 81ec3187 Chris Buechler
			$reqdfieldsn[] = gettext("Accounting port");
263 fbf672cb Matthew Grooms
		}
264
265
		if (!isset($id)) {
266
			$reqdfields[] = "radius_secret";
267 257705ca Renato Botelho
			$reqdfieldsn[] = gettext("Shared Secret");
268 fbf672cb Matthew Grooms
		}
269
	}
270
271 1e9b4611 Renato Botelho
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
272 fbf672cb Matthew Grooms
273 2ee8dea1 Phil Davis
	if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['host'])) {
274 fbf672cb Matthew Grooms
		$input_errors[] = gettext("The host name contains invalid characters.");
275 2ee8dea1 Phil Davis
	}
276 fbf672cb Matthew Grooms
277 2ee8dea1 Phil Davis
	if (auth_get_authserver($pconfig['name']) && !isset($id)) {
278 257705ca Renato Botelho
		$input_errors[] = gettext("An authentication server with the same name already exists.");
279 2ee8dea1 Phil Davis
	}
280 acee624f Ermal Lu?i
281 d6b4dfe3 jim-p
	if (($pconfig['type'] == "ldap") || ($pconfig['type'] == "radius")) {
282
		$to_field = "{$pconfig['type']}_timeout";
283
		if (isset($_POST[$to_field]) && !empty($_POST[$to_field]) && (!is_numeric($_POST[$to_field]) || (is_numeric($_POST[$to_field]) && ($_POST[$to_field] <= 0)))) {
284
			$input_errors[] = sprintf(gettext("%s Timeout value must be numeric and positive."), strtoupper($pconfig['type']));
285
		}
286 2ee8dea1 Phil Davis
	}
287 bddd2be8 jim-p
288 c4a6015b doktornotor
	// https://redmine.pfsense.org/issues/4154
289 a6b610cb doktornotor
	if ($pconfig['type'] == "radius") {
290 c4a6015b doktornotor
		if (is_ipaddrv6($_POST['radius_host'])) {
291
			$input_errors[] = gettext("IPv6 does not work for RADIUS authentication, see Bug #4154.");
292
		}
293
	}
294
295 fbf672cb Matthew Grooms
	if (!$input_errors) {
296
		$server = array();
297
		$server['refid'] = uniqid();
298 2ee8dea1 Phil Davis
		if (isset($id) && $a_server[$id]) {
299 fbf672cb Matthew Grooms
			$server = $a_server[$id];
300 2ee8dea1 Phil Davis
		}
301 fbf672cb Matthew Grooms
302
		$server['type'] = $pconfig['type'];
303
		$server['name'] = $pconfig['name'];
304
305
		if ($server['type'] == "ldap") {
306
307 2ee8dea1 Phil Davis
			if (!empty($pconfig['ldap_caref'])) {
308 fe2031ab Ermal
				$server['ldap_caref'] = $pconfig['ldap_caref'];
309 2ee8dea1 Phil Davis
			}
310 fbf672cb Matthew Grooms
			$server['host'] = $pconfig['ldap_host'];
311
			$server['ldap_port'] = $pconfig['ldap_port'];
312
			$server['ldap_urltype'] = $pconfig['ldap_urltype'];
313
			$server['ldap_protver'] = $pconfig['ldap_protver'];
314
			$server['ldap_scope'] = $pconfig['ldap_scope'];
315
			$server['ldap_basedn'] = $pconfig['ldap_basedn'];
316 c61e4626 Ermal Lu?i
			$server['ldap_authcn'] = $pconfig['ldapauthcontainers'];
317 c7073ebf namezero111111
			$server['ldap_extended_enabled'] = $pconfig['ldap_extended_enabled'];
318
			$server['ldap_extended_query'] = $pconfig['ldap_extended_query'];
319 fbf672cb Matthew Grooms
			$server['ldap_attr_user'] = $pconfig['ldap_attr_user'];
320
			$server['ldap_attr_group'] = $pconfig['ldap_attr_group'];
321
			$server['ldap_attr_member'] = $pconfig['ldap_attr_member'];
322 149efbea jim-p
323
			$server['ldap_attr_groupobj'] = empty($pconfig['ldap_attr_groupobj']) ? "posixGroup" : $pconfig['ldap_attr_groupobj'];
324
325 2ee8dea1 Phil Davis
			if ($pconfig['ldap_utf8'] == "yes") {
326 a5cd1c5a jim-p
				$server['ldap_utf8'] = true;
327 2ee8dea1 Phil Davis
			} else {
328 a5cd1c5a jim-p
				unset($server['ldap_utf8']);
329 2ee8dea1 Phil Davis
			}
330
			if ($pconfig['ldap_nostrip_at'] == "yes") {
331 a5cd1c5a jim-p
				$server['ldap_nostrip_at'] = true;
332 2ee8dea1 Phil Davis
			} else {
333 a5cd1c5a jim-p
				unset($server['ldap_nostrip_at']);
334 2ee8dea1 Phil Davis
			}
335 149efbea jim-p
			if ($pconfig['ldap_rfc2307'] == "yes") {
336
				$server['ldap_rfc2307'] = true;
337
			} else {
338
				unset($server['ldap_rfc2307']);
339
			}
340 a5cd1c5a jim-p
341 fbf672cb Matthew Grooms
342
			if (!$pconfig['ldap_anon']) {
343
				$server['ldap_binddn'] = $pconfig['ldap_binddn'];
344
				$server['ldap_bindpw'] = $pconfig['ldap_bindpw'];
345
			} else {
346
				unset($server['ldap_binddn']);
347
				unset($server['ldap_bindpw']);
348
			}
349 d6b4dfe3 jim-p
350
			if ($pconfig['ldap_timeout']) {
351
				$server['ldap_timeout'] = $pconfig['ldap_timeout'];
352
			} else {
353
				$server['ldap_timeout'] = 25;
354
			}
355 fbf672cb Matthew Grooms
		}
356
357
		if ($server['type'] == "radius") {
358
359 9da4a575 Renato Botelho
			$server['radius_protocol'] = $pconfig['radius_protocol'];
360 fbf672cb Matthew Grooms
			$server['host'] = $pconfig['radius_host'];
361
362 2ee8dea1 Phil Davis
			if ($pconfig['radius_secret']) {
363 fbf672cb Matthew Grooms
				$server['radius_secret'] = $pconfig['radius_secret'];
364 2ee8dea1 Phil Davis
			}
365 fbf672cb Matthew Grooms
366 2ee8dea1 Phil Davis
			if ($pconfig['radius_timeout']) {
367 bddd2be8 jim-p
				$server['radius_timeout'] = $pconfig['radius_timeout'];
368 2ee8dea1 Phil Davis
			} else {
369 afdf29d3 jim-p
				$server['radius_timeout'] = 5;
370 2ee8dea1 Phil Davis
			}
371 bddd2be8 jim-p
372 fbf672cb Matthew Grooms
			if ($pconfig['radius_srvcs'] == "both") {
373
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
374
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
375
			}
376
377
			if ($pconfig['radius_srvcs'] == "auth") {
378
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
379
				unset($server['radius_acct_port']);
380
			}
381
382
			if ($pconfig['radius_srvcs'] == "acct") {
383
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
384
				unset($server['radius_auth_port']);
385
			}
386
		}
387
388 2ee8dea1 Phil Davis
		if (isset($id) && $config['system']['authserver'][$id]) {
389 6306b5dd Ermal Lu?i
			$config['system']['authserver'][$id] = $server;
390 2ee8dea1 Phil Davis
		} else {
391 6306b5dd Ermal Lu?i
			$config['system']['authserver'][] = $server;
392 2ee8dea1 Phil Davis
		}
393 fbf672cb Matthew Grooms
394
		write_config();
395
396
		pfSenseHeader("system_authservers.php");
397
	}
398
}
399
400 1d3259b5 Stephen Beaver
// On error, restore the form contents so the user doesn't have to re-enter too much
401 9d3e8723 Phil Davis
if ($_POST && $input_errors) {
402 504bd882 Stephen Beaver
	$pconfig = $_POST;
403
	$pconfig['ldap_authcn'] = $_POST['ldapauthcontainers'];
404 b1f0f7e1 Stephen Beaver
	$pconfig['ldap_template'] = $_POST['ldap_tmpltype'];
405 504bd882 Stephen Beaver
}
406
407 8f1ab2a4 k-paulius
$pgtitle = array(gettext("System"), gettext("User Manager"), gettext("Authentication Servers"));
408 edcd7535 Phil Davis
$pglinks = array("", "system_usermanager.php", "system_authservers.php");
409 8f1ab2a4 k-paulius
410
if ($act == "new" || $act == "edit" || $input_errors) {
411
	$pgtitle[] = gettext('Edit');
412 edcd7535 Phil Davis
	$pglinks[] = "@self";
413 8f1ab2a4 k-paulius
}
414
$shortcut_section = "authentication";
415 fbf672cb Matthew Grooms
include("head.inc");
416
417 762faef5 Phil Davis
if ($input_errors) {
418 a0165602 Sjon Hortensius
	print_input_errors($input_errors);
419 762faef5 Phil Davis
}
420 7b4b0ad3 Stephen Beaver
421 762faef5 Phil Davis
if ($savemsg) {
422 ea342b0f Stephen Beaver
	print_info_box($savemsg, 'success');
423 762faef5 Phil Davis
}
424 a0165602 Sjon Hortensius
425
$tab_array = array();
426
$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
427
$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
428
$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
429 2d1f33d9 k-paulius
$tab_array[] = array(gettext("Authentication Servers"), true, "system_authservers.php");
430 a0165602 Sjon Hortensius
display_top_tabs($tab_array);
431
432 762faef5 Phil Davis
if (!($act == "new" || $act == "edit" || $input_errors)) {
433 060ed238 Stephen Beaver
?>
434
<div class="panel panel-default">
435 70dc5cd6 Phil Davis
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('Authentication Servers')?></h2></div>
436 060ed238 Stephen Beaver
	<div class="panel-body">
437
		<div class="table-responsive">
438 1c10ce97 PiBa-NL
			<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
439 060ed238 Stephen Beaver
				<thead>
440
					<tr>
441
						<th><?=gettext("Server Name")?></th>
442
						<th><?=gettext("Type")?></th>
443
						<th><?=gettext("Host Name")?></th>
444
						<th><?=gettext("Actions")?></th>
445
					</tr>
446
				</thead>
447
				<tbody>
448 9d3e8723 Phil Davis
			<?php foreach ($a_server as $i => $server): ?>
449 060ed238 Stephen Beaver
					<tr>
450
						<td><?=htmlspecialchars($server['name'])?></td>
451
						<td><?=htmlspecialchars($auth_server_types[$server['type']])?></td>
452
						<td><?=htmlspecialchars($server['host'])?></td>
453
						<td>
454
						<?php if ($i < (count($a_server) - 1)): ?>
455 4611e283 Steve Beaver
							<a class="fa fa-pencil" title="<?=gettext("Edit server"); ?>" href="system_authservers.php?act=edit&amp;id=<?=$i?>"></a>
456 59d06739 Steve Beaver
							<a class="fa fa-trash"  title="<?=gettext("Delete server")?>" href="system_authservers.php?act=del&amp;id=<?=$i?>" usepost></a>
457 060ed238 Stephen Beaver
						<?php endif?>
458
						</td>
459
					</tr>
460
			<?php endforeach; ?>
461
				</tbody>
462
			</table>
463
		</div>
464 94404d94 Sander van Leeuwen
	</div>
465 060ed238 Stephen Beaver
</div>
466
467
<nav class="action-buttons">
468 4611e283 Steve Beaver
	<a href="?act=new" class="btn btn-success btn-sm">
469 060ed238 Stephen Beaver
		<i class="fa fa-plus icon-embed-btn"></i>
470
		<?=gettext("Add")?>
471
	</a>
472
</nav>
473 fbf672cb Matthew Grooms
<?php
474 a0165602 Sjon Hortensius
	include("foot.inc");
475
	exit;
476 fbf672cb Matthew Grooms
}
477
478 a0165602 Sjon Hortensius
$form = new Form;
479
$form->setAction('system_authservers.php?act=edit');
480 ea342b0f Stephen Beaver
481 a0165602 Sjon Hortensius
$form->addGlobal(new Form_Input(
482
	'userid',
483
	null,
484
	'hidden',
485
	$id
486
));
487
488 5f88f964 k-paulius
$section = new Form_Section('Server Settings');
489 a0165602 Sjon Hortensius
490
$section->addInput($input = new Form_Input(
491
	'name',
492 153c3aa6 Phil Davis
	'*Descriptive name',
493 a0165602 Sjon Hortensius
	'text',
494
	$pconfig['name']
495
));
496
497
$section->addInput($input = new Form_Select(
498
	'type',
499 153c3aa6 Phil Davis
	'*Type',
500 a0165602 Sjon Hortensius
	$pconfig['type'],
501
	$auth_server_types
502 44d906ca Sjon Hortensius
))->toggles();
503 a0165602 Sjon Hortensius
504
$form->add($section);
505 6157f724 Stephen Beaver
506
// ==== LDAP settings =========================================================
507 a0165602 Sjon Hortensius
$section = new Form_Section('LDAP Server Settings');
508 44d906ca Sjon Hortensius
$section->addClass('toggle-ldap collapse');
509 a0165602 Sjon Hortensius
510
if (!isset($pconfig['type']) || $pconfig['type'] == 'ldap')
511
	$section->addClass('in');
512
513
$section->addInput(new Form_Input(
514
	'ldap_host',
515 153c3aa6 Phil Davis
	'*Hostname or IP address',
516 a0165602 Sjon Hortensius
	'text',
517
	$pconfig['ldap_host']
518 d672403c derelict-pf
))->setHelp('NOTE: When using SSL or STARTTLS, this hostname MUST match the Common Name '.
519 5585e65d Chris Buechler
	'(CN) of the LDAP server\'s SSL Certificate.');
520 a0165602 Sjon Hortensius
521
$section->addInput(new Form_Input(
522
	'ldap_port',
523 153c3aa6 Phil Davis
	'*Port value',
524 a0165602 Sjon Hortensius
	'number',
525
	$pconfig['ldap_port']
526
));
527
528
$section->addInput(new Form_Select(
529
	'ldap_urltype',
530 153c3aa6 Phil Davis
	'*Transport',
531 a0165602 Sjon Hortensius
	$pconfig['ldap_urltype'],
532
	array_combine(array_keys($ldap_urltypes), array_keys($ldap_urltypes))
533
));
534
535
if (empty($a_ca))
536
{
537
	$section->addInput(new Form_StaticText(
538
		'Peer Certificate Authority',
539 d4a744b2 k-paulius
		'No Certificate Authorities defined.<br/>Create one under <a href="system_camanager.php">System &gt; Cert. Manager</a>.'
540 a0165602 Sjon Hortensius
	));
541 fbf672cb Matthew Grooms
}
542 a0165602 Sjon Hortensius
else
543
{
544 87c67243 jim-p
	$ldapCaRef = array( 'global' => 'Global Root CA List' );
545 a0165602 Sjon Hortensius
	foreach ($a_ca as $ca)
546
		$ldapCaRef[ $ca['refid'] ] = $ca['descr'];
547
548
	$section->addInput(new Form_Select(
549
		'ldap_caref',
550
		'Peer Certificate Authority',
551
		$pconfig['ldap_caref'],
552
		$ldapCaRef
553 d672403c derelict-pf
	))->setHelp('This option is used if \'SSL Encrypted\' '.
554
		'or \'TCP - STARTTLS\' options are chosen. '.
555 a0165602 Sjon Hortensius
		'It must match with the CA in the AD otherwise problems will arise.');
556 fbf672cb Matthew Grooms
}
557
558 a0165602 Sjon Hortensius
$section->addInput(new Form_Select(
559
	'ldap_protver',
560 153c3aa6 Phil Davis
	'*Protocol version',
561 a0165602 Sjon Hortensius
	$pconfig['ldap_protver'],
562
	array_combine($ldap_protvers, $ldap_protvers)
563
));
564
565 d6b4dfe3 jim-p
$section->addInput(new Form_Input(
566
	'ldap_timeout',
567
	'Server Timeout',
568
	'number',
569
	$pconfig['ldap_timeout'],
570
	['placeholder' => 25]
571
))->setHelp('Timeout for LDAP operations (seconds)');
572
573 905f6119 Stephen Beaver
$group = new Form_Group('Search scope');
574
575 c84db5bb Stephen Beaver
$SSF = new Form_Select(
576 a0165602 Sjon Hortensius
	'ldap_scope',
577 153c3aa6 Phil Davis
	'*Level',
578 a0165602 Sjon Hortensius
	$pconfig['ldap_scope'],
579
	$ldap_scopes
580 c84db5bb Stephen Beaver
);
581 df8fca9d Stephen Beaver
582 c84db5bb Stephen Beaver
$SSB = new Form_Input(
583 a0165602 Sjon Hortensius
	'ldap_basedn',
584
	'Base DN',
585
	'text',
586
	$pconfig['ldap_basedn']
587 c84db5bb Stephen Beaver
);
588 905f6119 Stephen Beaver
589 c84db5bb Stephen Beaver
590
$section->addInput(new Form_StaticText(
591
	'Search scope',
592
	'Level ' . $SSF . '<br />' . 'Base DN' . $SSB
593
));
594 a0165602 Sjon Hortensius
595 5520839e Phil Davis
$group = new Form_Group('*Authentication containers');
596 a0165602 Sjon Hortensius
$group->add(new Form_Input(
597
	'ldapauthcontainers',
598 5520839e Phil Davis
	'Containers',
599 a0165602 Sjon Hortensius
	'text',
600
	$pconfig['ldap_authcn']
601
))->setHelp('Note: Semi-Colon separated. This will be prepended to the search '.
602 89140b63 NOYB
	'base dn above or the full container path can be specified containing a dc= '.
603 781d9ce4 Phil Davis
	'component.%1$sExample: CN=Users;DC=example,DC=com or OU=Staff;OU=Freelancers', '<br/>');
604 504bd882 Stephen Beaver
605 a0165602 Sjon Hortensius
$group->add(new Form_Button(
606
	'Select',
607 faab522f Renato Botelho
	'Select a container',
608 2e7fa7ca jim-p
	null,
609
	'fa-search'
610 347c0214 Phil Davis
))->setAttribute('type','button')->addClass('btn-info');
611 501efbd2 Stephen Beaver
612 a0165602 Sjon Hortensius
$section->add($group);
613
614 2e101d89 Sander van Leeuwen
$section->addInput(new Form_Checkbox(
615 a0165602 Sjon Hortensius
	'ldap_extended_enabled',
616 2e101d89 Sander van Leeuwen
	'Extended query',
617
	'Enable extended query',
618 a0165602 Sjon Hortensius
	$pconfig['ldap_extended_enabled']
619 e39a41e9 Stephen Beaver
));
620 a0165602 Sjon Hortensius
621 2e101d89 Sander van Leeuwen
$group = new Form_Group('Query');
622 e39a41e9 Stephen Beaver
$group->addClass('extended');
623
624 a0165602 Sjon Hortensius
$group->add(new Form_Input(
625
	'ldap_extended_query',
626 2e101d89 Sander van Leeuwen
	'Query',
627 a0165602 Sjon Hortensius
	'text',
628
	$pconfig['ldap_extended_query']
629 603be247 AdamD
))->setHelp('Example: memberOf=CN=Groupname,OU=MyGroups,DC=example,DC=com');
630 2e101d89 Sander van Leeuwen
631 a0165602 Sjon Hortensius
$section->add($group);
632
633
$section->addInput(new Form_Checkbox(
634
	'ldap_anon',
635
	'Bind anonymous',
636
	'Use anonymous binds to resolve distinguished names',
637
	$pconfig['ldap_anon']
638 b0909f2e Stephen Beaver
));
639 a0165602 Sjon Hortensius
640 153c3aa6 Phil Davis
$group = new Form_Group('*Bind credentials');
641 b0909f2e Stephen Beaver
$group->addClass('ldapanon');
642
643 a0165602 Sjon Hortensius
$group->add(new Form_Input(
644
	'ldap_binddn',
645
	'User DN:',
646
	'text',
647
	$pconfig['ldap_binddn']
648
));
649 b0909f2e Stephen Beaver
650 a0165602 Sjon Hortensius
$group->add(new Form_Input(
651
	'ldap_bindpw',
652
	'Password',
653 1c1f08f9 Stephen Beaver
	'password',
654 a0165602 Sjon Hortensius
	$pconfig['ldap_bindpw']
655
));
656
$section->add($group);
657
658 ac9d8bed Stephen Beaver
if (!isset($id)) {
659
	$template_list = array();
660
661 9d3e8723 Phil Davis
	foreach ($ldap_templates as $option => $template) {
662 ac9d8bed Stephen Beaver
		$template_list[$option] = $template['desc'];
663
	}
664 a0165602 Sjon Hortensius
665
	$section->addInput(new Form_Select(
666
		'ldap_tmpltype',
667
		'Initial Template',
668
		$pconfig['ldap_template'],
669 ac9d8bed Stephen Beaver
		$template_list
670 a0165602 Sjon Hortensius
	));
671 fbf672cb Matthew Grooms
}
672
673 a0165602 Sjon Hortensius
$section->addInput(new Form_Input(
674
	'ldap_attr_user',
675 153c3aa6 Phil Davis
	'*User naming attribute',
676 a0165602 Sjon Hortensius
	'text',
677
	$pconfig['ldap_attr_user']
678
));
679
680
$section->addInput(new Form_Input(
681
	'ldap_attr_group',
682 153c3aa6 Phil Davis
	'*Group naming attribute',
683 a0165602 Sjon Hortensius
	'text',
684
	$pconfig['ldap_attr_group']
685
));
686
687
$section->addInput(new Form_Input(
688
	'ldap_attr_member',
689 153c3aa6 Phil Davis
	'*Group member attribute',
690 a0165602 Sjon Hortensius
	'text',
691
	$pconfig['ldap_attr_member']
692
));
693
694 149efbea jim-p
$section->addInput(new Form_Checkbox(
695
	'ldap_rfc2307',
696
	'RFC 2307 Groups',
697
	'LDAP Server uses RFC 2307 style group membership',
698
	$pconfig['ldap_rfc2307']
699
))->setHelp('RFC 2307 style group membership has members listed on the group '.
700
	'object rather than using groups listed on user object. Leave unchecked '.
701
	'for Active Directory style group membership (RFC 2307bis).');
702
703
$section->addInput(new Form_Input(
704
	'ldap_attr_groupobj',
705
	'Group Object Class',
706
	'text',
707
	$pconfig['ldap_attr_groupobj'],
708
	['placeholder' => 'posixGroup']
709
))->setHelp('Object class used for groups in RFC2307 mode. '.
710
	'Typically "posixGroup" or "group".');
711
712 a0165602 Sjon Hortensius
$section->addInput(new Form_Checkbox(
713
	'ldap_utf8',
714
	'UTF8 Encode',
715
	'UTF8 encode LDAP parameters before sending them to the server.',
716
	$pconfig['ldap_utf8']
717
))->setHelp('Required to support international characters, but may not be '.
718
	'supported by every LDAP server.');
719
720
$section->addInput(new Form_Checkbox(
721
	'ldap_nostrip_at',
722
	'Username Alterations',
723
	'Do not strip away parts of the username after the @ symbol',
724
	$pconfig['ldap_nostrip_at']
725
))->setHelp('e.g. user@host becomes user when unchecked.');
726
727
$form->add($section);
728 6157f724 Stephen Beaver
729
// ==== RADIUS section ========================================================
730 7aaf60a8 k-paulius
$section = new Form_Section('RADIUS Server Settings');
731 44d906ca Sjon Hortensius
$section->addClass('toggle-radius collapse');
732 a0165602 Sjon Hortensius
733 9da4a575 Renato Botelho
$section->addInput(new Form_Select(
734
	'radius_protocol',
735 153c3aa6 Phil Davis
	'*Protocol',
736 9da4a575 Renato Botelho
	$pconfig['radius_protocol'],
737
	$radius_protocol
738
));
739
740 a0165602 Sjon Hortensius
$section->addInput(new Form_Input(
741
	'radius_host',
742 153c3aa6 Phil Davis
	'*Hostname or IP address',
743 a0165602 Sjon Hortensius
	'text',
744
	$pconfig['radius_host']
745
));
746
747
$section->addInput(new Form_Input(
748
	'radius_secret',
749 153c3aa6 Phil Davis
	'*Shared Secret',
750 406a904b jim-p
	'password',
751 a0165602 Sjon Hortensius
	$pconfig['radius_secret']
752
));
753
754
$section->addInput(new Form_Select(
755
	'radius_srvcs',
756 153c3aa6 Phil Davis
	'*Services offered',
757 a0165602 Sjon Hortensius
	$pconfig['radius_srvcs'],
758
	$radius_srvcs
759
));
760
761
$section->addInput(new Form_Input(
762
	'radius_auth_port',
763 81ec3187 Chris Buechler
	'Authentication port',
764 a0165602 Sjon Hortensius
	'number',
765 df5d8616 Stephen Beaver
	$pconfig['radius_auth_port']
766 a0165602 Sjon Hortensius
));
767
768
$section->addInput(new Form_Input(
769
	'radius_acct_port',
770 df5d8616 Stephen Beaver
	'Accounting port',
771 a0165602 Sjon Hortensius
	'number',
772
	$pconfig['radius_acct_port']
773
));
774
775
$section->addInput(new Form_Input(
776
	'radius_timeout',
777
	'Authentication Timeout',
778
	'number',
779
	$pconfig['radius_timeout']
780
))->setHelp('This value controls how long, in seconds, that the RADIUS '.
781
	'server may take to respond to an authentication request. If left blank, the '.
782 89140b63 NOYB
	'default value is 5 seconds. NOTE: If using an interactive two-factor '.
783 a0165602 Sjon Hortensius
	'authentication system, increase this timeout to account for how long it will '.
784
	'take the user to receive and enter a token.');
785
786
if (isset($id) && $a_server[$id])
787
{
788
	$section->addInput(new Form_Input(
789
		'id',
790
		null,
791
		'hidden',
792
		$id
793
	));
794 6306b5dd Ermal Lu?i
}
795 a0165602 Sjon Hortensius
796
$form->add($section);
797 098604d3 Stephen Beaver
798
// Create a largely empty modal to show the available containers. We will populate it via AJAX later
799
$modal = new Modal("LDAP containers", "containers", true);
800
801
$form->add($modal);
802
803 a0165602 Sjon Hortensius
print $form;
804 ac9d8bed Stephen Beaver
?>
805 8fd9052f Colin Fleming
<script type="text/javascript">
806 ac9d8bed Stephen Beaver
//<![CDATA[
807 098604d3 Stephen Beaver
events.push(function() {
808
809
	// Create an AJAX request (to this page) to get the container list and controls
810 501efbd2 Stephen Beaver
	function select_clicked() {
811
		if (document.getElementById("ldap_port").value == '' ||
812 7b4b0ad3 Stephen Beaver
			document.getElementById("ldap_host").value == '' ||
813
			document.getElementById("ldap_scope").value == '' ||
814
			document.getElementById("ldap_basedn").value == '' ||
815
			document.getElementById("ldapauthcontainers").value == '') {
816 501efbd2 Stephen Beaver
			alert("<?=gettext("Please fill the required values.");?>");
817
			return;
818
		}
819 7b4b0ad3 Stephen Beaver
820 501efbd2 Stephen Beaver
		if (!document.getElementById("ldap_anon").checked) {
821
			if (document.getElementById("ldap_binddn").value == '' ||
822 7b4b0ad3 Stephen Beaver
				document.getElementById("ldap_bindpw").value == '') {
823 501efbd2 Stephen Beaver
				alert("<?=gettext("Please fill the bind username/password.");?>");
824
				return;
825
			}
826
		}
827 098604d3 Stephen Beaver
828
		var ajaxRequest;
829
		var authserver = $('#authmode').val();
830
		var cert;
831
832
<?php if (count($a_ca) > 0): ?>
833
			cert = $('#ldap_caref').val();
834
<?php else: ?>
835
			cert = '';
836
<?php endif; ?>
837 697b1e07 Stephen Beaver
/*
838 098604d3 Stephen Beaver
		$('#containers').modal('show');
839 79df3d68 Stephen Beaver
		$('#serverlist').parent('div').prev('label').remove();
840
		$('#serverlist').parent('div').removeClass("col-sm-10");
841
		$('#serverlist').parent('div').addClass("col-sm-12");
842 697b1e07 Stephen Beaver
*/
843 098604d3 Stephen Beaver
		ajaxRequest = $.ajax(
844
			{
845
				url: "/system_authservers.php",
846
				type: "post",
847
				data: {
848
					ajax: 	"ajax",
849
					port: 	$('#ldap_port').val(),
850
					host: 	$('#ldap_host').val(),
851
					scope: 	$('#ldap_scope').val(),
852
					basedn: $('#ldap_basedn').val(),
853
					binddn: $('#ldap_binddn').val(),
854
					bindpw: $('#ldap_bindpw').val(),
855
					urltype:$('#ldap_urltype').val(),
856
					proto:  $('#ldap_protver').val(),
857
					authcn: $('#ldapauthcontainers').val(),
858
					cert:   cert
859
				}
860
			}
861
		);
862
863
		// Deal with the results of the above ajax call
864
		ajaxRequest.done(function (response, textStatus, jqXHR) {
865 697b1e07 Stephen Beaver
			$('#containers').replaceWith(response);
866
867
			$('#containers').modal('show');
868 098604d3 Stephen Beaver
869
			// The button handler needs to be here because until the modal has been populated
870
			// the controls we need to attach handlers to do not exist
871
			$('#svcontbtn').prop("type", "button");
872
			$('#svcontbtn').removeAttr("href");
873
874
			$('#svcontbtn').click(function () {
875
				var ous = $('[id^=ou]').length;
876
				var i;
877
878
				$('#ldapauthcontainers').val("");
879
880
				for (i = 0; i < ous; i++) {
881
					if ($('#ou' + i).prop("checked")) {
882
						if ($('#ldapauthcontainers').val() != "") {
883
							$('#ldapauthcontainers').val($('#ldapauthcontainers').val() +";");
884
						}
885
886
						$('#ldapauthcontainers').val($('#ldapauthcontainers').val() + $('#ou' + i).val());
887
					}
888
				}
889
890
				$('#containers').modal('hide');
891
			});
892
		});
893
894 501efbd2 Stephen Beaver
	}
895 7b4b0ad3 Stephen Beaver
896 f3a43095 Stephen Beaver
	function set_ldap_port() {
897 d672403c derelict-pf
		if ($('#ldap_urltype').find(":selected").index() == 2)
898 7b4b0ad3 Stephen Beaver
			$('#ldap_port').val('636');
899 d672403c derelict-pf
		else
900
			$('#ldap_port').val('389');
901 7b4b0ad3 Stephen Beaver
	}
902
903 153c3aa6 Phil Davis
	function set_required_port_fields() {
904
		if (document.getElementById("radius_srvcs").value == 'auth') {
905
			setRequired('radius_auth_port', true);
906
			setRequired('radius_acct_port', false);
907
		} else if (document.getElementById("radius_srvcs").value == 'acct') {
908
			setRequired('radius_auth_port', false);
909
			setRequired('radius_acct_port', true);
910
		} else { // both
911
			setRequired('radius_auth_port', true);
912
			setRequired('radius_acct_port', true);
913
		}
914
	}
915
916 7b4b0ad3 Stephen Beaver
	// Hides all elements of the specified class. This will usually be a section
917
	function hideClass(s_class, hide) {
918 9d3e8723 Phil Davis
		if (hide)
919 7b4b0ad3 Stephen Beaver
			$('.' + s_class).hide();
920
		else
921
			$('.' + s_class).show();
922 f3a43095 Stephen Beaver
	}
923 7b4b0ad3 Stephen Beaver
924 ac9d8bed Stephen Beaver
	function ldap_tmplchange() {
925
		switch ($('#ldap_tmpltype').find(":selected").index()) {
926
<?php
927
		$index = 0;
928
		foreach ($ldap_templates as $tmpldata):
929
?>
930
			case <?=$index;?>:
931
				$('#ldap_attr_user').val("<?=$tmpldata['attr_user'];?>");
932
				$('#ldap_attr_group').val("<?=$tmpldata['attr_group'];?>");
933
				$('#ldap_attr_member').val("<?=$tmpldata['attr_member'];?>");
934
				break;
935
<?php
936
			$index++;
937
		endforeach;
938
?>
939
		}
940
	}
941 a0165602 Sjon Hortensius
942 eef93144 Jared Dillard
	// ---------- On initial page load ------------------------------------------------------------
943 782922c2 Stephen Beaver
944 c4302457 Stephen Beaver
<?php if ($act != 'edit') : ?>
945 ac9d8bed Stephen Beaver
	ldap_tmplchange();
946 c4302457 Stephen Beaver
<?php endif; ?>
947
948 b0909f2e Stephen Beaver
	hideClass('ldapanon', $('#ldap_anon').prop('checked'));
949 e39a41e9 Stephen Beaver
	hideClass('extended', !$('#ldap_extended_enabled').prop('checked'));
950 153c3aa6 Phil Davis
	set_required_port_fields();
951 7b4b0ad3 Stephen Beaver
952 9d3e8723 Phil Davis
	if ($('#ldap_port').val() == "")
953 f3a43095 Stephen Beaver
		set_ldap_port();
954 ac9d8bed Stephen Beaver
955 ea342b0f Stephen Beaver
<?php
956 9d3e8723 Phil Davis
	if ($act == 'edit') {
957 ea342b0f Stephen Beaver
?>
958 6157f724 Stephen Beaver
		$('#type option:not(:selected)').each(function(){
959 7b4b0ad3 Stephen Beaver
			$(this).attr('disabled', 'disabled');
960 6157f724 Stephen Beaver
		});
961 7b4b0ad3 Stephen Beaver
962 2138c41b Stephen Beaver
<?php
963 9d3e8723 Phil Davis
		if (!$input_errors) {
964 7b4b0ad3 Stephen Beaver
?>
965 6157f724 Stephen Beaver
		$('#name').prop("readonly", true);
966 ea342b0f Stephen Beaver
<?php
967 2138c41b Stephen Beaver
		}
968 ea342b0f Stephen Beaver
	}
969
?>
970 eef93144 Jared Dillard
	// ---------- Click checkbox handlers ---------------------------------------------------------
971 782922c2 Stephen Beaver
972 ac9d8bed Stephen Beaver
	$('#ldap_tmpltype').on('change', function() {
973
		ldap_tmplchange();
974
	});
975 b0909f2e Stephen Beaver
976 7b4b0ad3 Stephen Beaver
	$('#ldap_anon').click(function () {
977
		hideClass('ldapanon', this.checked);
978
	});
979
980 f3a43095 Stephen Beaver
	$('#ldap_urltype').on('change', function() {
981
		set_ldap_port();
982 7b4b0ad3 Stephen Beaver
	});
983
984
	$('#Select').click(function () {
985
		select_clicked();
986
	});
987 504bd882 Stephen Beaver
988 e39a41e9 Stephen Beaver
	$('#ldap_extended_enabled').click(function () {
989
		hideClass('extended', !this.checked);
990
	});
991 504bd882 Stephen Beaver
992 153c3aa6 Phil Davis
	$('#radius_srvcs').on('change', function() {
993
		set_required_port_fields();
994
	});
995
996 ac9d8bed Stephen Beaver
});
997
//]]>
998
</script>
999
<?php
1000 81ec3187 Chris Buechler
include("foot.inc");