Project

General

Profile

Download (32.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	system_authservers.php
4

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	Copyright (C) 2010 Ermal Luçi
7
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_MODULE:	auth
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-system-authservers
37
##|*NAME=System: Authentication Servers
38
##|*DESCR=Allow access to the 'System: Authentication Servers' page.
39
##|*MATCH=system_authservers.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43
require_once("auth.inc");
44

    
45
$pgtitle = array(gettext("System"), gettext("Authentication Servers"));
46
$shortcut_section = "authentication";
47

    
48
if (is_numericint($_GET['id'])) {
49
	$id = $_GET['id'];
50
}
51
if (isset($_POST['id']) && is_numericint($_POST['id'])) {
52
	$id = $_POST['id'];
53
}
54

    
55
if (!is_array($config['system']['authserver'])) {
56
	$config['system']['authserver'] = array();
57
}
58

    
59
$a_servers = auth_get_authserver_list();
60
foreach ($a_servers as $servers) {
61
	$a_server[] = $servers;
62
}
63

    
64
if (!is_array($config['ca'])) {
65
	$config['ca'] = array();
66
}
67
$a_ca =& $config['ca'];
68

    
69
$act = $_GET['act'];
70
if ($_POST['act']) {
71
	$act = $_POST['act'];
72
}
73

    
74
if ($act == "del") {
75

    
76
	if (!$a_server[$_GET['id']]) {
77
		pfSenseHeader("system_authservers.php");
78
		exit;
79
	}
80

    
81
	/* Remove server from main list. */
82
	$serverdeleted = $a_server[$_GET['id']]['name'];
83
	foreach ($config['system']['authserver'] as $k => $as) {
84
		if ($config['system']['authserver'][$k]['name'] == $serverdeleted) {
85
			unset($config['system']['authserver'][$k]);
86
		}
87
	}
88

    
89
	/* Remove server from temp list used later on this page. */
90
	unset($a_server[$_GET['id']]);
91

    
92
	$savemsg = gettext("Authentication Server") . " " . htmlspecialchars($serverdeleted) . " " . gettext("deleted") . "<br />";
93
	write_config($savemsg);
94
}
95

    
96
if ($act == "edit") {
97
	if (isset($id) && $a_server[$id]) {
98

    
99
		$pconfig['type'] = $a_server[$id]['type'];
100
		$pconfig['name'] = $a_server[$id]['name'];
101

    
102
		if ($pconfig['type'] == "ldap") {
103
			$pconfig['ldap_caref'] = $a_server[$id]['ldap_caref'];
104
			$pconfig['ldap_host'] = $a_server[$id]['host'];
105
			$pconfig['ldap_port'] = $a_server[$id]['ldap_port'];
106
			$pconfig['ldap_urltype'] = $a_server[$id]['ldap_urltype'];
107
			$pconfig['ldap_protver'] = $a_server[$id]['ldap_protver'];
108
			$pconfig['ldap_scope'] = $a_server[$id]['ldap_scope'];
109
			$pconfig['ldap_basedn'] = $a_server[$id]['ldap_basedn'];
110
			$pconfig['ldap_authcn'] = $a_server[$id]['ldap_authcn'];
111
			$pconfig['ldap_extended_enabled'] = $a_server[$id]['ldap_extended_enabled'];
112
			$pconfig['ldap_extended_query'] = $a_server[$id]['ldap_extended_query'];
113
			$pconfig['ldap_binddn'] = $a_server[$id]['ldap_binddn'];
114
			$pconfig['ldap_bindpw'] = $a_server[$id]['ldap_bindpw'];
115
			$pconfig['ldap_attr_user'] = $a_server[$id]['ldap_attr_user'];
116
			$pconfig['ldap_attr_group'] = $a_server[$id]['ldap_attr_group'];
117
			$pconfig['ldap_attr_member'] = $a_server[$id]['ldap_attr_member'];
118
			$pconfig['ldap_utf8'] = isset($a_server[$id]['ldap_utf8']);
119
			$pconfig['ldap_nostrip_at'] = isset($a_server[$id]['ldap_nostrip_at']);
120

    
121
			if (!$pconfig['ldap_binddn'] || !$pconfig['ldap_bindpw']) {
122
				$pconfig['ldap_anon'] = true;
123
			}
124
		}
125

    
126
		if ($pconfig['type'] == "radius") {
127
			$pconfig['radius_host'] = $a_server[$id]['host'];
128
			$pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port'];
129
			$pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port'];
130
			$pconfig['radius_secret'] = $a_server[$id]['radius_secret'];
131
			$pconfig['radius_timeout'] = $a_server[$id]['radius_timeout'];
132

    
133
			if ($pconfig['radius_auth_port'] &&
134
			    $pconfig['radius_acct_port']) {
135
				$pconfig['radius_srvcs'] = "both";
136
			}
137

    
138
			if ($pconfig['radius_auth_port'] &&
139
			    !$pconfig['radius_acct_port']) {
140
				$pconfig['radius_srvcs'] = "auth";
141
				$pconfig['radius_acct_port'] = 1813;
142
			}
143

    
144
			if (!$pconfig['radius_auth_port'] &&
145
			    $pconfig['radius_acct_port']) {
146
				$pconfig['radius_srvcs'] = "acct";
147
				$pconfig['radius_auth_port'] = 1812;
148
			}
149

    
150
		}
151
	}
152
}
153

    
154
if ($act == "new") {
155
	$pconfig['ldap_protver'] = 3;
156
	$pconfig['ldap_anon'] = true;
157
	$pconfig['radius_srvcs'] = "both";
158
	$pconfig['radius_auth_port'] = "1812";
159
	$pconfig['radius_acct_port'] = "1813";
160
}
161

    
162
if ($_POST) {
163
	unset($input_errors);
164
	$pconfig = $_POST;
165

    
166
	/* input validation */
167

    
168
	if ($pconfig['type'] == "ldap") {
169
		$reqdfields = explode(" ",
170
			"name type ldap_host ldap_port " .
171
			"ldap_urltype ldap_protver ldap_scope " .
172
			"ldap_attr_user ldap_attr_group ldap_attr_member ldapauthcontainers");
173
		$reqdfieldsn = array(
174
			gettext("Descriptive name"),
175
			gettext("Type"),
176
			gettext("Hostname or IP"),
177
			gettext("Port value"),
178
			gettext("Transport"),
179
			gettext("Protocol version"),
180
			gettext("Search level"),
181
			gettext("User naming Attribute"),
182
			gettext("Group naming Attribute"),
183
			gettext("Group member attribute"),
184
			gettext("Authentication container"));
185

    
186
		if (!$pconfig['ldap_anon']) {
187
			$reqdfields[] = "ldap_binddn";
188
			$reqdfields[] = "ldap_bindpw";
189
			$reqdfieldsn[] = gettext("Bind user DN");
190
			$reqdfieldsn[] = gettext("Bind Password");
191
		}
192
	}
193

    
194
	if ($pconfig['type'] == "radius") {
195
		$reqdfields = explode(" ", "name type radius_host radius_srvcs");
196
		$reqdfieldsn = array(
197
			gettext("Descriptive name"),
198
			gettext("Type"),
199
			gettext("Hostname or IP"),
200
			gettext("Services"));
201

    
202
		if ($pconfig['radisu_srvcs'] == "both" ||
203
		    $pconfig['radisu_srvcs'] == "auth") {
204
			$reqdfields[] = "radius_auth_port";
205
			$reqdfieldsn[] = gettext("Authentication port value");
206
		}
207

    
208
		if ($pconfig['radisu_srvcs'] == "both" ||
209
		    $pconfig['radisu_srvcs'] == "acct") {
210
			$reqdfields[] = "radius_acct_port";
211
			$reqdfieldsn[] = gettext("Accounting port value");
212
		}
213

    
214
		if (!isset($id)) {
215
			$reqdfields[] = "radius_secret";
216
			$reqdfieldsn[] = gettext("Shared Secret");
217
		}
218
	}
219

    
220
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
221

    
222
	if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['host'])) {
223
		$input_errors[] = gettext("The host name contains invalid characters.");
224
	}
225

    
226
	if (auth_get_authserver($pconfig['name']) && !isset($id)) {
227
		$input_errors[] = gettext("An authentication server with the same name already exists.");
228
	}
229

    
230
	if (($pconfig['type'] == "radius") && isset($_POST['radius_timeout']) && !empty($_POST['radius_timeout']) && (!is_numeric($_POST['radius_timeout']) || (is_numeric($_POST['radius_timeout']) && ($_POST['radius_timeout'] <= 0)))) {
231
		$input_errors[] = gettext("RADIUS Timeout value must be numeric and positive.");
232
	}
233

    
234
	/* if this is an AJAX caller then handle via JSON */
235
	if (isAjax() && is_array($input_errors)) {
236
		input_errors2Ajax($input_errors);
237
		exit;
238
	}
239

    
240
	if (!$input_errors) {
241
		$server = array();
242
		$server['refid'] = uniqid();
243
		if (isset($id) && $a_server[$id]) {
244
			$server = $a_server[$id];
245
		}
246

    
247
		$server['type'] = $pconfig['type'];
248
		$server['name'] = $pconfig['name'];
249

    
250
		if ($server['type'] == "ldap") {
251

    
252
			if (!empty($pconfig['ldap_caref'])) {
253
				$server['ldap_caref'] = $pconfig['ldap_caref'];
254
			}
255
			$server['host'] = $pconfig['ldap_host'];
256
			$server['ldap_port'] = $pconfig['ldap_port'];
257
			$server['ldap_urltype'] = $pconfig['ldap_urltype'];
258
			$server['ldap_protver'] = $pconfig['ldap_protver'];
259
			$server['ldap_scope'] = $pconfig['ldap_scope'];
260
			$server['ldap_basedn'] = $pconfig['ldap_basedn'];
261
			$server['ldap_authcn'] = $pconfig['ldapauthcontainers'];
262
			$server['ldap_extended_enabled'] = $pconfig['ldap_extended_enabled'];
263
			$server['ldap_extended_query'] = $pconfig['ldap_extended_query'];
264
			$server['ldap_attr_user'] = $pconfig['ldap_attr_user'];
265
			$server['ldap_attr_group'] = $pconfig['ldap_attr_group'];
266
			$server['ldap_attr_member'] = $pconfig['ldap_attr_member'];
267
			if ($pconfig['ldap_utf8'] == "yes") {
268
				$server['ldap_utf8'] = true;
269
			} else {
270
				unset($server['ldap_utf8']);
271
			}
272
			if ($pconfig['ldap_nostrip_at'] == "yes") {
273
				$server['ldap_nostrip_at'] = true;
274
			} else {
275
				unset($server['ldap_nostrip_at']);
276
			}
277

    
278

    
279
			if (!$pconfig['ldap_anon']) {
280
				$server['ldap_binddn'] = $pconfig['ldap_binddn'];
281
				$server['ldap_bindpw'] = $pconfig['ldap_bindpw'];
282
			} else {
283
				unset($server['ldap_binddn']);
284
				unset($server['ldap_bindpw']);
285
			}
286
		}
287

    
288
		if ($server['type'] == "radius") {
289

    
290
			$server['host'] = $pconfig['radius_host'];
291

    
292
			if ($pconfig['radius_secret']) {
293
				$server['radius_secret'] = $pconfig['radius_secret'];
294
			}
295

    
296
			if ($pconfig['radius_timeout']) {
297
				$server['radius_timeout'] = $pconfig['radius_timeout'];
298
			} else {
299
				$server['radius_timeout'] = 5;
300
			}
301

    
302
			if ($pconfig['radius_srvcs'] == "both") {
303
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
304
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
305
			}
306

    
307
			if ($pconfig['radius_srvcs'] == "auth") {
308
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
309
				unset($server['radius_acct_port']);
310
			}
311

    
312
			if ($pconfig['radius_srvcs'] == "acct") {
313
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
314
				unset($server['radius_auth_port']);
315
			}
316
		}
317

    
318
		if (isset($id) && $config['system']['authserver'][$id]) {
319
			$config['system']['authserver'][$id] = $server;
320
		} else {
321
			$config['system']['authserver'][] = $server;
322
		}
323

    
324
		write_config();
325

    
326
		pfSenseHeader("system_authservers.php");
327
	}
328
}
329

    
330
include("head.inc");
331
?>
332

    
333
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
334
<?php include("fbegin.inc"); ?>
335
<script type="text/javascript">
336
//<![CDATA[
337

    
338
function server_typechange(typ) {
339

    
340
	var idx = 0;
341
	if (!typ) {
342
		idx = document.getElementById("type").selectedIndex;
343
		typ = document.getElementById("type").options[idx].value;
344
	}
345

    
346
	switch (typ) {
347
		case "ldap":
348
			document.getElementById("ldap").style.display="";
349
			document.getElementById("radius").style.display="none";
350
			break;
351
		case "radius":
352
			document.getElementById("ldap").style.display="none";
353
			document.getElementById("radius").style.display="";
354
			break;
355
	}
356
}
357

    
358
function ldap_urlchange() {
359
	switch (document.getElementById("ldap_urltype").selectedIndex) {
360
<?php
361
	$index = 0;
362
	foreach ($ldap_urltypes as $urltype => $urlport):
363
?>
364
		case <?=$index;?>:
365
			document.getElementById("ldap_port").value = "<?=$urlport;?>";
366
			break;
367
<?php
368
		$index++;
369
	endforeach;
370
?>
371
	}
372
}
373

    
374
function ldap_bindchange() {
375

    
376
	if (document.getElementById("ldap_anon").checked) {
377
		document.getElementById("ldap_bind").style.display="none";
378
	} else {
379
		document.getElementById("ldap_bind").style.display="";
380
	}
381
}
382

    
383
function ldap_tmplchange() {
384
	switch (document.getElementById("ldap_tmpltype").selectedIndex) {
385
<?php
386
	$index = 0;
387
	foreach ($ldap_templates as $tmpldata):
388
?>
389
		case <?=$index;?>:
390
			document.getElementById("ldap_attr_user").value = "<?=$tmpldata['attr_user'];?>";
391
			document.getElementById("ldap_attr_group").value = "<?=$tmpldata['attr_group'];?>";
392
			document.getElementById("ldap_attr_member").value = "<?=$tmpldata['attr_member'];?>";
393
			break;
394
<?php
395
		$index++;
396
	endforeach;
397
?>
398
	}
399
}
400

    
401
function radius_srvcschange() {
402
	switch (document.getElementById("radius_srvcs").selectedIndex) {
403
		case 0: // both
404
			document.getElementById("radius_auth").style.display="";
405
			document.getElementById("radius_acct").style.display="";
406
			break;
407
		case 1: // authentication
408
			document.getElementById("radius_auth").style.display="";
409
			document.getElementById("radius_acct").style.display="none";
410
			break;
411
		case 2: // accounting
412
			document.getElementById("radius_auth").style.display="none";
413
			document.getElementById("radius_acct").style.display="";
414
			break;
415
	}
416
}
417

    
418
function select_clicked() {
419
	if (document.getElementById("ldap_port").value == '' ||
420
	    document.getElementById("ldap_host").value == '' ||
421
	    document.getElementById("ldap_scope").value == '' ||
422
	    document.getElementById("ldap_basedn").value == '' ||
423
	    document.getElementById("ldapauthcontainers").value == '') {
424
		alert("<?=gettext("Please fill the required values.");?>");
425
		return;
426
	}
427
	if (!document.getElementById("ldap_anon").checked) {
428
		if (document.getElementById("ldap_binddn").value == '' ||
429
		    document.getElementById("ldap_bindpw").value == '') {
430
			alert("<?=gettext("Please fill the bind username/password.");?>");
431
			return;
432
		}
433
	}
434
	var url = 'system_usermanager_settings_ldapacpicker.php?';
435
	url += 'port=' + document.getElementById("ldap_port").value;
436
	url += '&host=' + document.getElementById("ldap_host").value;
437
	url += '&scope=' + document.getElementById("ldap_scope").value;
438
	url += '&basedn=' + document.getElementById("ldap_basedn").value;
439
	url += '&binddn=' + document.getElementById("ldap_binddn").value;
440
	url += '&bindpw=' + document.getElementById("ldap_bindpw").value;
441
	url += '&urltype=' + document.getElementById("ldap_urltype").value;
442
	url += '&proto=' + document.getElementById("ldap_protver").value;
443
	url += '&authcn=' + document.getElementById("ldapauthcontainers").value;
444
	<?php if (count($a_ca) > 0): ?>
445
		url += '&cert=' + document.getElementById("ldap_caref").value;
446
	<?php else: ?>
447
		url += '&cert=';
448
	<?php endif; ?>
449

    
450
	var oWin = window.open(url, "pfSensePop", "width=620,height=400,top=150,left=150");
451
	if (oWin == null || typeof(oWin) == "undefined") {
452
		alert("<?=gettext('Popup blocker detected.  Action aborted.');?>");
453
	}
454
}
455
//]]>
456
</script>
457
<?php
458
	if ($input_errors) {
459
		print_input_errors($input_errors);
460
	}
461
	if ($savemsg) {
462
		print_info_box($savemsg);
463
	}
464
?>
465
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="auth servers">
466
	<tr>
467
		<td>
468
		<?php
469
			$tab_array = array();
470
			$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
471
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
472
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
473
			$tab_array[] = array(gettext("Servers"), true, "system_authservers.php");
474
			display_top_tabs($tab_array);
475
		?>
476
		</td>
477
	</tr>
478
	<tr>
479
		<td id="mainarea">
480
			<div class="tabcont">
481

    
482
				<?php if ($act == "new" || $act == "edit" || $input_errors): ?>
483

    
484
				<form action="system_authservers.php" method="post" name="iform" id="iform">
485
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
486
						<tr>
487
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
488
							<td width="78%" class="vtable">
489
							<?php if (!isset($id)): ?>
490
								<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
491
							<?php else: ?>
492
								<strong><?=htmlspecialchars($pconfig['name']);?></strong>
493
								<input name='name' type='hidden' id='name' value="<?=htmlspecialchars($pconfig['name']);?>"/>
494
							<?php endif; ?>
495
							</td>
496
						</tr>
497
						<tr>
498
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Type");?></td>
499
							<td width="78%" class="vtable">
500
								<?php if (!isset($id)): ?>
501
								<select name='type' id='type' class="formselect" onchange='server_typechange()'>
502
								<?php
503
									foreach ($auth_server_types as $typename => $typedesc):
504
										$selected = "";
505
										if ($pconfig['type'] == $typename) {
506
											$selected = "selected=\"selected\"";
507
										}
508
								?>
509
									<option value="<?=$typename;?>" <?=$selected;?>><?=$typedesc;?></option>
510
								<?php endforeach; ?>
511
								</select>
512
								<?php else: ?>
513
								<strong><?=$auth_server_types[$pconfig['type']];?></strong>
514
								<input name='type' type='hidden' id='type' value="<?=htmlspecialchars($pconfig['type']);?>"/>
515
								<?php endif; ?>
516
							</td>
517
						</tr>
518
					</table>
519

    
520
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="ldap" style="display:none" summary="">
521
						<tr>
522
							<td colspan="2" class="list" height="12"></td>
523
						</tr>
524
						<tr>
525
							<td colspan="2" valign="top" class="listtopic"><?=gettext("LDAP Server Settings");?></td>
526
						</tr>
527
						<tr>
528
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP address");?></td>
529
							<td width="78%" class="vtable">
530
								<input name="ldap_host" type="text" class="formfld unknown" id="ldap_host" size="20" value="<?=htmlspecialchars($pconfig['ldap_host']);?>"/>
531
								<br /><?= gettext("NOTE: When using SSL, this hostname MUST match the Common Name (CN) of the LDAP server's SSL Certificate."); ?>
532
							</td>
533
						</tr>
534
						<tr>
535
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Port value");?></td>
536
							<td width="78%" class="vtable">
537
								<input name="ldap_port" type="text" class="formfld unknown" id="ldap_port" size="5" value="<?=htmlspecialchars($pconfig['ldap_port']);?>"/>
538
							</td>
539
						</tr>
540
						<tr>
541
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Transport");?></td>
542
							<td width="78%" class="vtable">
543
								<select name='ldap_urltype' id='ldap_urltype' class="formselect" onchange='ldap_urlchange()'>
544
								<?php
545
									foreach ($ldap_urltypes as $urltype => $urlport):
546
										$selected = "";
547
										if ($pconfig['ldap_urltype'] == $urltype) {
548
											$selected = "selected=\"selected\"";
549
										}
550
								?>
551
									<option value="<?=$urltype;?>" <?=$selected;?>><?=$urltype;?></option>
552
								<?php endforeach; ?>
553
								</select>
554
							</td>
555
						</tr>
556
						<tr id="tls_ca">
557
							<td width="22%" valign="top" class="vncell"><?=gettext("Peer Certificate Authority"); ?></td>
558
							<td width="78%" class="vtable">
559
								<?php if (count($a_ca)): ?>
560
								<select id='ldap_caref' name='ldap_caref' class="formselect">
561
								<?php
562
									foreach ($a_ca as $ca):
563
										$selected = "";
564
										if ($pconfig['ldap_caref'] == $ca['refid']) {
565
											$selected = "selected=\"selected\"";
566
										}
567
								?>
568
									<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
569
								<?php	endforeach; ?>
570
								</select>
571
								<br /><span><?=gettext("This option is used if 'SSL Encrypted' option is chosen.");?> <br />
572
								<?=gettext("It must match with the CA in the AD otherwise problems will arise.");?></span>
573
								<?php else: ?>
574
								<b>No Certificate Authorities defined.</b> <br />Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.
575
								<?php endif; ?>
576
							</td>
577
						</tr>
578
						<tr>
579
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol version");?></td>
580
							<td width="78%" class="vtable">
581
								<select name='ldap_protver' id='ldap_protver' class="formselect">
582
								<?php
583
									foreach ($ldap_protvers as $version):
584
										$selected = "";
585
										if ($pconfig['ldap_protver'] == $version) {
586
											$selected = "selected=\"selected\"";
587
										}
588
								?>
589
									<option value="<?=$version;?>" <?=$selected;?>><?=$version;?></option>
590
								<?php endforeach; ?>
591
								</select>
592
							</td>
593
						</tr>
594
						<tr>
595
							<td width="22%" valign="top" class="vncell"><?=gettext("Search scope");?></td>
596
							<td width="78%" class="vtable">
597
								<table border="0" cellspacing="0" cellpadding="2" summary="search scope">
598
									<tr>
599
										<td><?=gettext("Level:");?> &nbsp;</td>
600
										<td>
601
											<select name='ldap_scope' id='ldap_scope' class="formselect">
602
											<?php
603
												foreach ($ldap_scopes as $scopename => $scopedesc):
604
													$selected = "";
605
													if ($pconfig['ldap_scope'] == $scopename) {
606
														$selected = "selected=\"selected\"";
607
													}
608
											?>
609
												<option value="<?=$scopename;?>" <?=$selected;?>><?=$scopedesc;?></option>
610
											<?php endforeach; ?>
611
											</select>
612
										</td>
613
									</tr>
614
									<tr>
615
										<td><?=gettext("Base DN:");?> &nbsp;</td>
616
										<td>
617
											<input name="ldap_basedn" type="text" class="formfld unknown" id="ldap_basedn" size="40" value="<?=htmlspecialchars($pconfig['ldap_basedn']);?>"/>
618
										</td>
619
									</tr>
620
								</table>
621
							</td>
622
						</tr>
623
						<tr>
624
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication containers");?></td>
625
							<td width="78%" class="vtable">
626
								<table border="0" cellspacing="0" cellpadding="2" summary="auth containers">
627
									<tr>
628
										<td><?=gettext("Containers:");?> &nbsp;</td>
629
										<td>
630
											<input name="ldapauthcontainers" type="text" class="formfld unknown" id="ldapauthcontainers" size="40" value="<?=htmlspecialchars($pconfig['ldap_authcn']);?>"/>
631
											<input type="button" onclick="select_clicked();" value="<?=gettext("Select");?>" />
632
											<br /><?=gettext("Note: Semi-Colon separated. This will be prepended to the search base dn above or you can specify full container path containing a dc= component.");?>
633
											<br /><?=gettext("Example:");?> CN=Users;DC=example,DC=com
634
											<br /><?=gettext("Example:");?> OU=Staff;OU=Freelancers
635
										</td>
636
									</tr>
637
								</table>
638
							</td>
639
						</tr>
640
						<tr>
641
							<td width="22%" valign="top" class="vncell"><?=gettext("Extended Query");?></td>
642
							<td width="78%" class="vtable">
643
								<table border="0" cellspacing="0" cellpadding="2" summary="query">
644
									<tr>
645
										<td>
646
											<input name="ldap_extended_enabled" type="checkbox" id="ldap_extended_enabled" value="no" <?php if ($pconfig['ldap_extended_enabled']) echo "checked=\"checked\""; ?> />
647
										</td>
648
										<td>
649

    
650
											<input name="ldap_extended_query" type="text" class="formfld unknown" id="ldap_extended_query" size="40" value="<?=htmlspecialchars($pconfig['ldap_extended_query']);?>"/>
651
											<br /><?=gettext("Example:");?> &amp;(objectClass=inetOrgPerson)(mail=*@example.com)
652
										</td>
653
									</tr>
654
								</table>
655
							</td>
656
						</tr>
657
						<tr>
658
							<td width="22%" valign="top" class="vncell"><?=gettext("Bind credentials");?></td>
659
							<td width="78%" class="vtable">
660
								<table border="0" cellspacing="0" cellpadding="2" summary="bind credentials">
661
									<tr>
662
										<td>
663
											<input name="ldap_anon" type="checkbox" id="ldap_anon" value="yes" <?php if ($pconfig['ldap_anon']) echo "checked=\"checked\""; ?> onclick="ldap_bindchange()" />
664
										</td>
665
										<td>
666
											<?=gettext("Use anonymous binds to resolve distinguished names");?>
667
										</td>
668
									</tr>
669
								</table>
670
								<table border="0" cellspacing="0" cellpadding="2" id="ldap_bind" summary="bind">
671
									<tr>
672
										<td colspan="2"></td>
673
									</tr>
674
									<tr>
675
										<td><?=gettext("User DN:");?> &nbsp;</td>
676
										<td>
677
											<input name="ldap_binddn" type="text" class="formfld unknown" id="ldap_binddn" size="40" value="<?=htmlspecialchars($pconfig['ldap_binddn']);?>"/><br />
678
										</td>
679
									</tr>
680
									<tr>
681
										<td><?=gettext("Password:");?> &nbsp;</td>
682
										<td>
683
											<input name="ldap_bindpw" type="password" class="formfld pwd" id="ldap_bindpw" size="20" value="<?=htmlspecialchars($pconfig['ldap_bindpw']);?>"/><br />
684
										</td>
685
									</tr>
686
								</table>
687
							</td>
688
						</tr>
689
						<?php if (!isset($id)): ?>
690
						<tr>
691
							<td width="22%" valign="top" class="vncell"><?=gettext("Initial Template");?></td>
692
							<td width="78%" class="vtable">
693
								<select name='ldap_tmpltype' id='ldap_tmpltype' class="formselect" onchange='ldap_tmplchange()'>
694
								<?php
695
									foreach ($ldap_templates as $tmplname => $tmpldata):
696
										$selected = "";
697
										if ($pconfig['ldap_template'] == $tmplname) {
698
											$selected = "selected=\"selected\"";
699
										}
700
								?>
701
									<option value="<?=$tmplname;?>" <?=$selected;?>><?=$tmpldata['desc'];?></option>
702
								<?php endforeach; ?>
703
								</select>
704
							</td>
705
						</tr>
706
						<?php endif; ?>
707
						<tr>
708
							<td width="22%" valign="top" class="vncell"><?=gettext("User naming attribute");?></td>
709
							<td width="78%" class="vtable">
710
								<input name="ldap_attr_user" type="text" class="formfld unknown" id="ldap_attr_user" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_user']);?>"/>
711
							</td>
712
						</tr>
713
						<tr>
714
							<td width="22%" valign="top" class="vncell"><?=gettext("Group naming attribute");?></td>
715
							<td width="78%" class="vtable">
716
								<input name="ldap_attr_group" type="text" class="formfld unknown" id="ldap_attr_group" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_group']);?>"/>
717
							</td>
718
						</tr>
719
						<tr>
720
							<td width="22%" valign="top" class="vncell"><?=gettext("Group member attribute");?></td>
721
							<td width="78%" class="vtable">
722
								<input name="ldap_attr_member" type="text" class="formfld unknown" id="ldap_attr_member" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_member']);?>"/>
723
							</td>
724
						</tr>
725
						<tr>
726
							<td width="22%" valign="top" class="vncell"><?=gettext("UTF8 Encode");?></td>
727
							<td width="78%" class="vtable">
728
								<table border="0" cellspacing="0" cellpadding="2" summary="utf8 encoding">
729
									<tr>
730
										<td>
731
											<input name="ldap_utf8" type="checkbox" id="ldap_utf8" value="yes" <?php if ($pconfig['ldap_utf8']) echo "checked=\"checked\""; ?> />
732
										</td>
733
										<td>
734
											<?=gettext("UTF8 encode LDAP parameters before sending them to the server. Required to support international characters, but may not be supported by every LDAP server.");?>
735
										</td>
736
									</tr>
737
								</table>
738
							</td>
739
						</tr>
740
						<tr>
741
							<td width="22%" valign="top" class="vncell"><?=gettext("Username Alterations");?></td>
742
							<td width="78%" class="vtable">
743
								<table border="0" cellspacing="0" cellpadding="2" summary="username alterations">
744
									<tr>
745
										<td>
746
											<input name="ldap_nostrip_at" type="checkbox" id="ldap_nostrip_at" value="yes" <?php if ($pconfig['ldap_nostrip_at']) echo "checked=\"checked\""; ?> />
747
										</td>
748
										<td>
749
											<?=gettext("Do not strip away parts of the username after the @ symbol, e.g. user@host becomes user when unchecked.");?>
750
										</td>
751
									</tr>
752
								</table>
753
							</td>
754
						</tr>
755
					</table>
756

    
757
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="radius" style="display:none" summary="">
758
						<tr>
759
							<td colspan="2" class="list" height="12"></td>
760
						</tr>
761
						<tr>
762
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Radius Server Settings");?></td>
763
						</tr>
764
						<tr>
765
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP address");?></td>
766
							<td width="78%" class="vtable">
767
								<input name="radius_host" type="text" class="formfld unknown" id="radius_host" size="20" value="<?=htmlspecialchars($pconfig['radius_host']);?>"/>
768
							</td>
769
						</tr>
770
						<tr>
771
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Secret");?></td>
772
							<td width="78%" class="vtable">
773
								<input name="radius_secret" type="password" class="formfld pwd" id="radius_secret" size="20" value="<?=htmlspecialchars($pconfig['radius_secret']);?>"/>
774
							</td>
775
						</tr>
776
						<tr>
777
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Services offered");?></td>
778
							<td width="78%" class="vtable">
779
								<select name='radius_srvcs' id='radius_srvcs' class="formselect" onchange='radius_srvcschange()'>
780
								<?php
781
									foreach ($radius_srvcs as $srvcname => $srvcdesc):
782
										$selected = "";
783
										if ($pconfig['radius_srvcs'] == $srvcname) {
784
											$selected = "selected=\"selected\"";
785
										}
786
								?>
787
									<option value="<?=$srvcname;?>" <?=$selected;?>><?=$srvcdesc;?></option>
788
								<?php endforeach; ?>
789
								</select>
790
							</td>
791
						</tr>
792
						<tr id="radius_auth">
793
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication port value");?></td>
794
							<td width="78%" class="vtable">
795
								<input name="radius_auth_port" type="text" class="formfld unknown" id="radius_auth_port" size="5" value="<?=htmlspecialchars($pconfig['radius_auth_port']);?>"/>
796
							</td>
797
						</tr>
798
						<tr id="radius_acct">
799
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Accounting port value");?></td>
800
							<td width="78%" class="vtable">
801
								<input name="radius_acct_port" type="text" class="formfld unknown" id="radius_acct_port" size="5" value="<?=htmlspecialchars($pconfig['radius_acct_port']);?>"/>
802
							</td>
803
						</tr>
804
						<tr>
805
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication Timeout");?></td>
806
							<td width="78%" class="vtable">
807
								<input name="radius_timeout" type="text" class="formfld unknown" id="radius_timeout" size="20" value="<?=htmlspecialchars($pconfig['radius_timeout']);?>"/>
808
								<br /><?= gettext("This value controls how long, in seconds, that the RADIUS server may take to respond to an authentication request.") ?>
809
								<br /><?= gettext("If left blank, the default value is 5 seconds.") ?>
810
								<br /><br /><?= gettext("NOTE: If you are using an interactive two-factor authentication system, increase this timeout to account for how long it will take the user to receive and enter a token.") ?>
811
							</td>
812
						</tr>
813
					</table>
814

    
815
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="">
816
						<tr>
817
							<td width="22%" valign="top">&nbsp;</td>
818
							<td width="78%">
819
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
820
								<?php if (isset($id) && $a_server[$id]): ?>
821
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
822
								<?php endif;?>
823
							</td>
824
						</tr>
825
					</table>
826
				</form>
827

    
828
				<?php else: ?>
829

    
830
				<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
831
					<thead>
832
						<tr>
833
							<th width="25%" class="listhdrr"><?=gettext("Server Name");?></th>
834
							<th width="25%" class="listhdrr"><?=gettext("Type");?></th>
835
							<th width="35%" class="listhdrr"><?=gettext("Host Name");?></th>
836
							<th width="10%" class="list"></th>
837
						</tr>
838
					</thead>
839
					<tfoot>
840
						<tr>
841
							<td class="list" colspan="3"></td>
842
							<td class="list">
843
								<a href="system_authservers.php?act=new">
844
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add server");?>" alt="<?=gettext("add server");?>" width="17" height="17" border="0" />
845
								</a>
846
							</td>
847
						</tr>
848
						<tr>
849
							<td colspan="3">
850
								<p>
851
									<?=gettext("Additional authentication servers can be added here.");?>
852
								</p>
853
							</td>
854
						</tr>
855
					</tfoot>
856
					<tbody>
857
						<?php
858
							$i = 0;
859
							foreach ($a_server as $server):
860
								$name = htmlspecialchars($server['name']);
861
								$type = htmlspecialchars($auth_server_types[$server['type']]);
862
								$host = htmlspecialchars($server['host']);
863
						?>
864
						<tr <?php if ($i < (count($a_server) - 1)): ?> ondblclick="document.location='system_authservers.php?act=edit&amp;id=<?=$i;?>'" <?php endif; ?>>
865
							<td class="listlr"><?=$name?>&nbsp;</td>
866
							<td class="listr"><?=$type;?>&nbsp;</td>
867
							<td class="listr"><?=$host;?>&nbsp;</td>
868
							<td valign="middle" class="list nowrap">
869
							<?php if ($i < (count($a_server) - 1)): ?>
870
								<a href="system_authservers.php?act=edit&amp;id=<?=$i;?>">
871
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server");?>" alt="<?=gettext("edit server");?>" width="17" height="17" border="0" />
872
								</a>
873
								&nbsp;
874
								<a href="system_authservers.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Server?");?>')">
875
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server");?>" alt="<?=gettext("delete server");?>" width="17" height="17" border="0" />
876
								</a>
877
							<?php endif; ?>
878
							</td>
879
						</tr>
880
						<?php
881
								$i++;
882
							endforeach;
883
						?>
884
					</tbody>
885
				</table>
886

    
887
				<?php endif; ?>
888

    
889
			</div>
890
		</td>
891
	</tr>
892
</table>
893
<?php include("fend.inc"); ?>
894
<script type="text/javascript">
895
//<![CDATA[
896
server_typechange('<?=htmlspecialchars($pconfig['type']);?>');
897
<?php if (!isset($id) || $pconfig['type'] == "ldap"): ?>
898
ldap_bindchange();
899
if (document.getElementById("ldap_port").value == "") {
900
	ldap_urlchange();
901
}
902
<?php if (!isset($id)): ?>
903
ldap_tmplchange();
904
<?php endif; ?>
905
<?php endif; ?>
906
<?php if (!isset($id) || $pconfig['type'] == "radius"): ?>
907
radius_srvcschange();
908
<?php endif; ?>
909
//]]>
910
</script>
911
</body>
912
</html>
(207-207/252)