Project

General

Profile

Download (33.6 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
if (isset($_POST['id']) && is_numericint($_POST['id']))
51
	$id = $_POST['id'];
52

    
53
if (!is_array($config['system']['authserver']))
54
	$config['system']['authserver'] = array();
55

    
56
$a_servers = auth_get_authserver_list();
57
foreach ($a_servers as $servers)
58
	$a_server[] = $servers;
59

    
60
if (!is_array($config['ca']))
61
        $config['ca'] = array();
62
$a_ca =& $config['ca'];
63

    
64
$act = $_GET['act'];
65
if ($_POST['act'])
66
	$act = $_POST['act'];
67

    
68
if ($act == "del") {
69

    
70
	if (!$a_server[$_GET['id']]) {
71
		pfSenseHeader("system_authservers.php");
72
		exit;
73
	}
74

    
75
	/* Remove server from main list. */
76
	$serverdeleted = $a_server[$_GET['id']]['name'];
77
	foreach ($config['system']['authserver'] as $k => $as) {
78
		if ($config['system']['authserver'][$k]['name'] == $serverdeleted)
79
			unset($config['system']['authserver'][$k]);
80
	}
81

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

    
85
	$savemsg = gettext("Authentication Server")." {$serverdeleted} ".
86
				gettext("deleted")."<br />";
87
	write_config($savemsg);
88
}
89

    
90
if ($act == "edit") {
91
	if (isset($id) && $a_server[$id]) {
92

    
93
		$pconfig['type'] = $a_server[$id]['type'];
94
		$pconfig['name'] = $a_server[$id]['name'];
95

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

    
115
			if (!$pconfig['ldap_binddn'] || !$pconfig['ldap_bindpw'])
116
				$pconfig['ldap_anon'] = true;
117
		}
118

    
119
		if ($pconfig['type'] == "radius") {
120
			$pconfig['radius_host'] = $a_server[$id]['host'];
121
			$pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port'];
122
			$pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port'];
123
			$pconfig['radius_secret'] = $a_server[$id]['radius_secret'];
124
			$pconfig['radius_timeout'] = $a_server[$id]['radius_timeout'];
125

    
126
			if ($pconfig['radius_auth_port'] &&
127
				$pconfig['radius_acct_port'] ) {
128
				$pconfig['radius_srvcs'] = "both";
129
			}
130

    
131
			if ( $pconfig['radius_auth_port'] &&
132
				!$pconfig['radius_acct_port'] ) {
133
				$pconfig['radius_srvcs'] = "auth";
134
				$pconfig['radius_acct_port'] = 1813;
135
			}
136

    
137
			if (!$pconfig['radius_auth_port'] &&
138
				 $pconfig['radius_acct_port'] ) {
139
				$pconfig['radius_srvcs'] = "acct";
140
				$pconfig['radius_auth_port'] = 1812;
141
			}
142

    
143
		}
144
	}
145
}
146

    
147
if ($act == "new") {
148
	$pconfig['ldap_protver'] = 3;
149
	$pconfig['ldap_anon'] = true;
150
	$pconfig['radius_srvcs'] = "both";
151
	$pconfig['radius_auth_port'] = "1812";
152
	$pconfig['radius_acct_port'] = "1813";
153
}
154

    
155
if ($_POST) {
156
	unset($input_errors);
157
	$pconfig = $_POST;
158

    
159
	/* input validation */
160

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

    
178
		if (!$pconfig['ldap_anon']) {
179
			$reqdfields[] = "ldap_binddn";
180
			$reqdfields[] = "ldap_bindpw";
181
			$reqdfieldsn[] = gettext("Bind user DN");
182
			$reqdfieldsn[] = gettext("Bind Password");
183
		}
184
	}
185

    
186
	if ($pconfig['type'] == "radius") {
187
		$reqdfields = explode(" ", "name type radius_host radius_srvcs");
188
		$reqdfieldsn = array(
189
			gettext("Descriptive name"),
190
			gettext("Type"),
191
			gettext("Hostname or IP"),
192
			gettext("Services"));
193

    
194
		if ($pconfig['radisu_srvcs'] == "both" ||
195
			$pconfig['radisu_srvcs'] == "auth") {
196
			$reqdfields[] = "radius_auth_port";
197
			$reqdfieldsn[] = gettext("Authentication port value");
198
		}
199

    
200
		if ($pconfig['radisu_srvcs'] == "both" ||
201
			$pconfig['radisu_srvcs'] == "acct") {
202
			$reqdfields[] = "radius_acct_port";
203
			$reqdfieldsn[] = gettext("Accounting port value");
204
		}
205

    
206
		if (!isset($id)) {
207
			$reqdfields[] = "radius_secret";
208
			$reqdfieldsn[] = gettext("Shared Secret");
209
		}
210
	}
211

    
212
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
213

    
214
	if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['host']))
215
		$input_errors[] = gettext("The host name contains invalid characters.");
216

    
217
	if (auth_get_authserver($pconfig['name']) && !isset($id))
218
		$input_errors[] = gettext("An authentication server with the same name already exists.");
219

    
220
	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))))
221
		$input_errors[] = gettext("RADIUS Timeout value must be numeric and positive.");
222

    
223
	/* if this is an AJAX caller then handle via JSON */
224
	if (isAjax() && is_array($input_errors)) {
225
		input_errors2Ajax($input_errors);
226
		exit;
227
	}
228

    
229
	if (!$input_errors) {
230
		$server = array();
231
		$server['refid'] = uniqid();
232
		if (isset($id) && $a_server[$id])
233
			$server = $a_server[$id];
234

    
235
		$server['type'] = $pconfig['type'];
236
		$server['name'] = $pconfig['name'];
237

    
238
		if ($server['type'] == "ldap") {
239

    
240
			if (!empty($pconfig['ldap_caref']))
241
				$server['ldap_caref'] = $pconfig['ldap_caref'];
242
			$server['host'] = $pconfig['ldap_host'];
243
			$server['ldap_port'] = $pconfig['ldap_port'];
244
			$server['ldap_urltype'] = $pconfig['ldap_urltype'];
245
			$server['ldap_protver'] = $pconfig['ldap_protver'];
246
			$server['ldap_scope'] = $pconfig['ldap_scope'];
247
			$server['ldap_basedn'] = $pconfig['ldap_basedn'];
248
			$server['ldap_authcn'] = $pconfig['ldapauthcontainers'];
249
			$server['ldap_extended_enabled'] = $pconfig['ldap_extended_enabled'];
250
			$server['ldap_extended_query'] = $pconfig['ldap_extended_query'];
251
			$server['ldap_attr_user'] = $pconfig['ldap_attr_user'];
252
			$server['ldap_attr_group'] = $pconfig['ldap_attr_group'];
253
			$server['ldap_attr_member'] = $pconfig['ldap_attr_member'];
254
			if ($pconfig['ldap_utf8'] == "yes")
255
				$server['ldap_utf8'] = true;
256
			else
257
				unset($server['ldap_utf8']);
258
			if ($pconfig['ldap_nostrip_at'] == "yes")
259
				$server['ldap_nostrip_at'] = true;
260
			else
261
				unset($server['ldap_nostrip_at']);
262

    
263

    
264
			if (!$pconfig['ldap_anon']) {
265
				$server['ldap_binddn'] = $pconfig['ldap_binddn'];
266
				$server['ldap_bindpw'] = $pconfig['ldap_bindpw'];
267
			} else {
268
				unset($server['ldap_binddn']);
269
				unset($server['ldap_bindpw']);
270
			}
271
		}
272

    
273
		if ($server['type'] == "radius") {
274

    
275
			$server['host'] = $pconfig['radius_host'];
276

    
277
			if ($pconfig['radius_secret'])
278
				$server['radius_secret'] = $pconfig['radius_secret'];
279

    
280
			if ($pconfig['radius_timeout'])
281
				$server['radius_timeout'] = $pconfig['radius_timeout'];
282
			else
283
				$server['radius_timeout'] = 5;
284

    
285
			if ($pconfig['radius_srvcs'] == "both") {
286
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
287
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
288
			}
289

    
290
			if ($pconfig['radius_srvcs'] == "auth") {
291
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
292
				unset($server['radius_acct_port']);
293
			}
294

    
295
			if ($pconfig['radius_srvcs'] == "acct") {
296
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
297
				unset($server['radius_auth_port']);
298
			}
299
		}
300

    
301
		if (isset($id) && $config['system']['authserver'][$id])
302
			$config['system']['authserver'][$id] = $server;
303
		else
304
			$config['system']['authserver'][] = $server;
305

    
306
		write_config();
307

    
308
		pfSenseHeader("system_authservers.php");
309
	}
310
}
311

    
312
include("head.inc");
313
?>
314

    
315
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
316
<?php include("fbegin.inc"); ?>
317
<script type="text/javascript">
318
//<![CDATA[
319

    
320
function server_typechange(typ) {
321

    
322
	var idx = 0;
323
	if (!typ) {
324
		idx = document.getElementById("type").selectedIndex;
325
		typ = document.getElementById("type").options[idx].value;
326
	}
327

    
328
    	switch (typ) {
329
		case "ldap":
330
			document.getElementById("ldap").style.display="";
331
			document.getElementById("radius").style.display="none";
332
			break;
333
		case "radius":
334
			document.getElementById("ldap").style.display="none";
335
			document.getElementById("radius").style.display="";
336
			break;
337
	}
338
}
339

    
340
function ldap_urlchange() {
341
    switch (document.getElementById("ldap_urltype").selectedIndex) {
342
<?php
343
	$index = 0;
344
	foreach ($ldap_urltypes as $urltype => $urlport):
345
?>
346
		case <?=$index;?>:
347
			document.getElementById("ldap_port").value = "<?=$urlport;?>";
348
			break;
349
<?php
350
		$index++;
351
	endforeach;
352
?>
353
	}
354
}
355

    
356
function ldap_bindchange() {
357

    
358
	if (document.getElementById("ldap_anon").checked)
359
		document.getElementById("ldap_bind").style.display="none";
360
    else
361
		document.getElementById("ldap_bind").style.display="";
362
}
363

    
364
function ldap_tmplchange(){
365
    switch (document.getElementById("ldap_tmpltype").selectedIndex) {
366
<?php
367
	$index = 0;
368
	foreach ($ldap_templates as $tmpldata):
369
?>
370
		case <?=$index;?>:
371
			document.getElementById("ldap_attr_user").value = "<?=$tmpldata['attr_user'];?>";
372
			document.getElementById("ldap_attr_group").value = "<?=$tmpldata['attr_group'];?>";
373
			document.getElementById("ldap_attr_member").value = "<?=$tmpldata['attr_member'];?>";
374
			break;
375
<?php
376
		$index++;
377
	endforeach;
378
?>
379
	}
380
}
381

    
382
function radius_srvcschange(){
383
    switch (document.getElementById("radius_srvcs").selectedIndex) {
384
		case 0: // both
385
			document.getElementById("radius_auth").style.display="";
386
			document.getElementById("radius_acct").style.display="";
387
			break;
388
		case 1: // authentication
389
			document.getElementById("radius_auth").style.display="";
390
			document.getElementById("radius_acct").style.display="none";
391
			break;
392
		case 2: // accounting
393
			document.getElementById("radius_auth").style.display="none";
394
			document.getElementById("radius_acct").style.display="";
395
			break;
396
	}
397
}
398

    
399
function select_clicked() {
400
	if (document.getElementById("ldap_port").value == '' ||
401
	    document.getElementById("ldap_host").value == '' ||
402
	    document.getElementById("ldap_scope").value == '' ||
403
	    document.getElementById("ldap_basedn").value == '' ||
404
	    document.getElementById("ldapauthcontainers").value == '') {
405
		alert("<?=gettext("Please fill the required values.");?>");
406
		return;
407
	}
408
	if (!document.getElementById("ldap_anon").checked) {
409
		if (document.getElementById("ldap_binddn").value == '' ||
410
		    document.getElementById("ldap_bindpw").value == '') {
411
				alert("<?=gettext("Please fill the bind username/password.");?>");
412
			return;
413
		}
414
	}
415
        var url = 'system_usermanager_settings_ldapacpicker.php?';
416
        url += 'port=' + document.getElementById("ldap_port").value;
417
        url += '&host=' + document.getElementById("ldap_host").value;
418
        url += '&scope=' + document.getElementById("ldap_scope").value;
419
        url += '&basedn=' + document.getElementById("ldap_basedn").value;
420
        url += '&binddn=' + document.getElementById("ldap_binddn").value;
421
        url += '&bindpw=' + document.getElementById("ldap_bindpw").value;
422
        url += '&urltype=' + document.getElementById("ldap_urltype").value;
423
        url += '&proto=' + document.getElementById("ldap_protver").value;
424
	url += '&authcn=' + document.getElementById("ldapauthcontainers").value;
425
	<?php if (count($a_ca) > 0): ?>
426
		url += '&cert=' + document.getElementById("ldap_caref").value;
427
	<?php else: ?>
428
		url += '&cert=';
429
	<?php endif; ?>
430

    
431
        var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
432
        if (oWin==null || typeof(oWin)=="undefined")
433
			alert("<?=gettext('Popup blocker detected.  Action aborted.');?>");
434
}
435
//]]>
436
</script>
437
<?php
438
	if ($input_errors)
439
		print_input_errors($input_errors);
440
	if ($savemsg)
441
		print_info_box($savemsg);
442
?>
443
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="auth servers">
444
	<tr>
445
		<td>
446
		<?php
447
			$tab_array = array();
448
			$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
449
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
450
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
451
			$tab_array[] = array(gettext("Servers"), true, "system_authservers.php");
452
			display_top_tabs($tab_array);
453
		?>
454
		</td>
455
	</tr>
456
	<tr>
457
		<td id="mainarea">
458
			<div class="tabcont">
459

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

    
462
				<form action="system_authservers.php" method="post" name="iform" id="iform">
463
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
464
						<tr>
465
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
466
							<td width="78%" class="vtable">
467
							<?php if (!isset($id)): ?>
468
								<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
469
							<?php else: ?>
470
                                                                <strong><?=htmlspecialchars($pconfig['name']);?></strong>
471
                                                                <input name='name' type='hidden' id='name' value="<?=htmlspecialchars($pconfig['name']);?>"/>
472
                                                                <?php endif; ?>
473
							</td>
474
						</tr>
475
						<tr>
476
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Type");?></td>
477
							<td width="78%" class="vtable">
478
								<?php if (!isset($id)): ?>
479
								<select name='type' id='type' class="formselect" onchange='server_typechange()'>
480
								<?php
481
									foreach ($auth_server_types as $typename => $typedesc ):
482
										$selected = "";
483
										if ($pconfig['type'] == $typename)
484
											$selected = "selected=\"selected\"";
485
								?>
486
									<option value="<?=$typename;?>" <?=$selected;?>><?=$typedesc;?></option>
487
								<?php endforeach; ?>
488
								</select>
489
								<?php else: ?>
490
								<strong><?=$auth_server_types[$pconfig['type']];?></strong>
491
								<input name='type' type='hidden' id='type' value="<?=htmlspecialchars($pconfig['type']);?>"/>
492
								<?php endif; ?>
493
							</td>
494
						</tr>
495
					</table>
496

    
497
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="ldap" style="display:none" summary="">
498
						<tr>
499
							<td colspan="2" class="list" height="12"></td>
500
						</tr>
501
						<tr>
502
							<td colspan="2" valign="top" class="listtopic"><?=gettext("LDAP Server Settings");?></td>
503
						</tr>
504
						<tr>
505
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP address");?></td>
506
							<td width="78%" class="vtable">
507
								<input name="ldap_host" type="text" class="formfld unknown" id="ldap_host" size="20" value="<?=htmlspecialchars($pconfig['ldap_host']);?>"/>
508
								<br /><?= gettext("NOTE: When using SSL, this hostname MUST match the Common Name (CN) of the LDAP server's SSL Certificate."); ?>
509
							</td>
510
						</tr>
511
						<tr>
512
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Port value");?></td>
513
							<td width="78%" class="vtable">
514
								<input name="ldap_port" type="text" class="formfld unknown" id="ldap_port" size="5" value="<?=htmlspecialchars($pconfig['ldap_port']);?>"/>
515
							</td>
516
						</tr>
517
						<tr>
518
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Transport");?></td>
519
							<td width="78%" class="vtable">
520
								<select name='ldap_urltype' id='ldap_urltype' class="formselect" onchange='ldap_urlchange()'>
521
								<?php
522
									foreach ($ldap_urltypes as $urltype => $urlport):
523
										$selected = "";
524
										if ($pconfig['ldap_urltype'] == $urltype)
525
											$selected = "selected=\"selected\"";
526
								?>
527
									<option value="<?=$urltype;?>" <?=$selected;?>><?=$urltype;?></option>
528
								<?php endforeach; ?>
529
								</select>
530
							</td>
531
						</tr>
532
						<tr id="tls_ca">
533
							<td width="22%" valign="top" class="vncell"><?=gettext("Peer Certificate Authority"); ?></td>
534
                                                        <td width="78%" class="vtable">
535
                                                        <?php if (count($a_ca)): ?>
536
								<select id='ldap_caref' name='ldap_caref' class="formselect">
537
                                                        <?php
538
                                                                foreach ($a_ca as $ca):
539
                                                                        $selected = "";
540
                                                                        if ($pconfig['ldap_caref'] == $ca['refid'])
541
                                                                                $selected = "selected=\"selected\"";
542
                                                        ?>
543
									<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
544
                                                        <?php	endforeach; ?>
545
								</select>
546
								<br /><span><?=gettext("This option is used if 'SSL Encrypted' option is choosen.");?> <br />
547
								<?=gettext("It must match with the CA in the AD otherwise problems will arise.");?></span>
548
                                                        <?php else: ?>
549
                                                                <b>No Certificate Authorities defined.</b> <br />Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.
550
                                                        <?php endif; ?>
551
                                                        </td>
552
						</tr>
553
						<tr>
554
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol version");?></td>
555
							<td width="78%" class="vtable">
556
								<select name='ldap_protver' id='ldap_protver' class="formselect">
557
								<?php
558
									foreach ($ldap_protvers as $version):
559
										$selected = "";
560
										if ($pconfig['ldap_protver'] == $version)
561
											$selected = "selected=\"selected\"";
562
								?>
563
									<option value="<?=$version;?>" <?=$selected;?>><?=$version;?></option>
564
								<?php endforeach; ?>
565
								</select>
566
							</td>
567
						</tr>
568
						<tr>
569
							<td width="22%" valign="top" class="vncell"><?=gettext("Search scope");?></td>
570
							<td width="78%" class="vtable">
571
								<table border="0" cellspacing="0" cellpadding="2" summary="search scope">
572
									<tr>
573
										<td><?=gettext("Level:");?> &nbsp;</td>
574
										<td>
575
											<select name='ldap_scope' id='ldap_scope' class="formselect">
576
											<?php
577
												foreach ($ldap_scopes as $scopename => $scopedesc):
578
													$selected = "";
579
													if ($pconfig['ldap_scope'] == $scopename)
580
														$selected = "selected=\"selected\"";
581
											?>
582
												<option value="<?=$scopename;?>" <?=$selected;?>><?=$scopedesc;?></option>
583
											<?php endforeach; ?>
584
											</select>
585
										</td>
586
									</tr>
587
									<tr>
588
										<td><?=gettext("Base DN:");?> &nbsp;</td>
589
										<td>
590
											<input name="ldap_basedn" type="text" class="formfld unknown" id="ldap_basedn" size="40" value="<?=htmlspecialchars($pconfig['ldap_basedn']);?>"/>
591
										</td>
592
									</tr>
593
								</table>
594

    
595
							</td>
596
						</tr>
597
						<tr>
598
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication containers");?></td>
599
							<td width="78%" class="vtable">
600
								<table border="0" cellspacing="0" cellpadding="2" summary="auth containers">
601
									<tr>
602
										<td><?=gettext("Containers:");?> &nbsp;</td>
603
										<td>
604
											<input name="ldapauthcontainers" type="text" class="formfld unknown" id="ldapauthcontainers" size="40" value="<?=htmlspecialchars($pconfig['ldap_authcn']);?>"/>
605
											<input type="button" onclick="select_clicked();" value="<?=gettext("Select");?>" />
606
											<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.");?>
607
											<br /><?=gettext("Example:");?> CN=Users;DC=example,DC=com
608
											<br /><?=gettext("Example:");?> OU=Staff;OU=Freelancers
609
										</td>
610
									</tr>
611
								</table>
612
							</td>
613
						</tr>
614
						<tr>
615
							<td width="22%" valign="top" class="vncell"><?=gettext("Extended Query");?></td>
616
							<td width="78%" class="vtable">
617
								<table border="0" cellspacing="0" cellpadding="2" summary="query">
618
									<tr>
619
										<td>
620
											<input name="ldap_extended_enabled" type="checkbox" id="ldap_extended_enabled" value="no" <?php if ($pconfig['ldap_extended_enabled']) echo "checked=\"checked\""; ?> />
621
										</td>
622
										<td>
623

    
624
											<input name="ldap_extended_query" type="text" class="formfld unknown" id="ldap_extended_query" size="40" value="<?=htmlspecialchars($pconfig['ldap_extended_query']);?>"/>
625
											<br /><?=gettext("Example:");?> &amp;(objectClass=inetOrgPerson)(mail=*@example.com)
626
										</td>
627
									</tr>
628
								</table>
629
							</td>
630
						</tr>
631
						<tr>
632
							<td width="22%" valign="top" class="vncell"><?=gettext("Bind credentials");?></td>
633
							<td width="78%" class="vtable">
634
								<table border="0" cellspacing="0" cellpadding="2" summary="bind credentials">
635
									<tr>
636
										<td>
637
											<input name="ldap_anon" type="checkbox" id="ldap_anon" value="yes" <?php if ($pconfig['ldap_anon']) echo "checked=\"checked\""; ?> onclick="ldap_bindchange()" />
638
										</td>
639
										<td>
640
											<?=gettext("Use anonymous binds to resolve distinguished names");?>
641
										</td>
642
									</tr>
643
								</table>
644
								<table border="0" cellspacing="0" cellpadding="2" id="ldap_bind" summary="bind">
645
									<tr>
646
										<td colspan="2"></td>
647
									</tr>
648
									<tr>
649
										<td><?=gettext("User DN:");?> &nbsp;</td>
650
										<td>
651
											<input name="ldap_binddn" type="text" class="formfld unknown" id="ldap_binddn" size="40" value="<?=htmlspecialchars($pconfig['ldap_binddn']);?>"/><br />
652
										</td>
653
									</tr>
654
									<tr>
655
										<td><?=gettext("Password:");?> &nbsp;</td>
656
										<td>
657
											<input name="ldap_bindpw" type="password" class="formfld pwd" id="ldap_bindpw" size="20" value="<?=htmlspecialchars($pconfig['ldap_bindpw']);?>"/><br />
658
										</td>
659
									</tr>
660
								</table>
661
							</td>
662
						</tr>
663
						<?php if (!isset($id)): ?>
664
						<tr>
665
							<td width="22%" valign="top" class="vncell"><?=gettext("Initial Template");?></td>
666
							<td width="78%" class="vtable">
667
								<select name='ldap_tmpltype' id='ldap_tmpltype' class="formselect" onchange='ldap_tmplchange()'>
668
								<?php
669
									foreach ($ldap_templates as $tmplname => $tmpldata):
670
										$selected = "";
671
										if ($pconfig['ldap_template'] == $tmplname)
672
											$selected = "selected=\"selected\"";
673
								?>
674
									<option value="<?=$tmplname;?>" <?=$selected;?>><?=$tmpldata['desc'];?></option>
675
								<?php endforeach; ?>
676
								</select>
677
							</td>
678
						</tr>
679
						<?php endif; ?>
680
						<tr>
681
							<td width="22%" valign="top" class="vncell"><?=gettext("User naming attribute");?></td>
682
							<td width="78%" class="vtable">
683
								<input name="ldap_attr_user" type="text" class="formfld unknown" id="ldap_attr_user" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_user']);?>"/>
684
							</td>
685
						</tr>
686
						<tr>
687
							<td width="22%" valign="top" class="vncell"><?=gettext("Group naming attribute");?></td>
688
							<td width="78%" class="vtable">
689
								<input name="ldap_attr_group" type="text" class="formfld unknown" id="ldap_attr_group" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_group']);?>"/>
690
							</td>
691
						</tr>
692
						<tr>
693
							<td width="22%" valign="top" class="vncell"><?=gettext("Group member attribute");?></td>
694
							<td width="78%" class="vtable">
695
								<input name="ldap_attr_member" type="text" class="formfld unknown" id="ldap_attr_member" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_member']);?>"/>
696
							</td>
697
						</tr>
698
						<tr>
699
							<td width="22%" valign="top" class="vncell"><?=gettext("UTF8 Encode");?></td>
700
							<td width="78%" class="vtable">
701
								<table border="0" cellspacing="0" cellpadding="2" summary="utf8 encoding">
702
									<tr>
703
										<td>
704
											<input name="ldap_utf8" type="checkbox" id="ldap_utf8" value="yes" <?php if ($pconfig['ldap_utf8']) echo "checked=\"checked\""; ?> />
705
										</td>
706
										<td>
707
											<?=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.");?>
708
										</td>
709
									</tr>
710
								</table>
711
							</td>
712
						</tr>
713
						<tr>
714
							<td width="22%" valign="top" class="vncell"><?=gettext("Username Alterations");?></td>
715
							<td width="78%" class="vtable">
716
								<table border="0" cellspacing="0" cellpadding="2" summary="username alterations">
717
									<tr>
718
										<td>
719
											<input name="ldap_nostrip_at" type="checkbox" id="ldap_nostrip_at" value="yes" <?php if ($pconfig['ldap_nostrip_at']) echo "checked=\"checked\""; ?> />
720
										</td>
721
										<td>
722
											<?=gettext("Do not strip away parts of the username after the @ symbol, e.g. user@host becomes user when unchecked.");?>
723
										</td>
724
									</tr>
725
								</table>
726
							</td>
727
						</tr>
728
					</table>
729

    
730
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="radius" style="display:none" summary="">
731
						<tr>
732
							<td colspan="2" class="list" height="12"></td>
733
						</tr>
734
						<tr>
735
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Radius Server Settings");?></td>
736
						</tr>
737
						<tr>
738
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP address");?></td>
739
							<td width="78%" class="vtable">
740
								<input name="radius_host" type="text" class="formfld unknown" id="radius_host" size="20" value="<?=htmlspecialchars($pconfig['radius_host']);?>"/>
741
							</td>
742
						</tr>
743
						<tr>
744
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Secret");?></td>
745
							<td width="78%" class="vtable">
746
								<input name="radius_secret" type="password" class="formfld pwd" id="radius_secret" size="20" value="<?=htmlspecialchars($pconfig['radius_secret']);?>"/>
747
							</td>
748
						</tr>
749
						<tr>
750
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Services offered");?></td>
751
							<td width="78%" class="vtable">
752
								<select name='radius_srvcs' id='radius_srvcs' class="formselect" onchange='radius_srvcschange()'>
753
								<?php
754
									foreach ($radius_srvcs as $srvcname => $srvcdesc):
755
										$selected = "";
756
										if ($pconfig['radius_srvcs'] == $srvcname)
757
											$selected = "selected=\"selected\"";
758
								?>
759
									<option value="<?=$srvcname;?>" <?=$selected;?>><?=$srvcdesc;?></option>
760
								<?php endforeach; ?>
761
								</select>
762
							</td>
763
						</tr>
764
						<tr id="radius_auth">
765
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication port value");?></td>
766
							<td width="78%" class="vtable">
767
								<input name="radius_auth_port" type="text" class="formfld unknown" id="radius_auth_port" size="5" value="<?=htmlspecialchars($pconfig['radius_auth_port']);?>"/>
768
							</td>
769
						</tr>
770
						<tr id="radius_acct">
771
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Accounting port value");?></td>
772
							<td width="78%" class="vtable">
773
								<input name="radius_acct_port" type="text" class="formfld unknown" id="radius_acct_port" size="5" value="<?=htmlspecialchars($pconfig['radius_acct_port']);?>"/>
774
							</td>
775
						</tr>
776
						<tr>
777
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication Timeout");?></td>
778
							<td width="78%" class="vtable">
779
								<input name="radius_timeout" type="text" class="formfld unknown" id="radius_timeout" size="20" value="<?=htmlspecialchars($pconfig['radius_timeout']);?>"/>
780
								<br /><?= gettext("This value controls how long, in seconds, that the RADIUS server may take to respond to an authentication request.") ?>
781
								<br /><?= gettext("If left blank, the default value is 5 seconds.") ?>
782
								<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.") ?>
783
							</td>
784
						</tr>
785
					</table>
786

    
787
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="">
788
						<tr>
789
							<td width="22%" valign="top">&nbsp;</td>
790
							<td width="78%">
791
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
792
								<?php if (isset($id) && $a_server[$id]): ?>
793
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
794
								<?php endif;?>
795
							</td>
796
						</tr>
797
					</table>
798
				</form>
799

    
800
				<?php else: ?>
801

    
802
				<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
803
					<thead>
804
						<tr>
805
							<th width="25%" class="listhdrr"><?=gettext("Server Name");?></th>
806
							<th width="25%" class="listhdrr"><?=gettext("Type");?></th>
807
							<th width="35%" class="listhdrr"><?=gettext("Host Name");?></th>
808
							<th width="10%" class="list"></th>
809
						</tr>
810
					</thead>
811
					<tfoot>
812
						<tr>
813
							<td class="list" colspan="3"></td>
814
							<td class="list">
815
								<a href="system_authservers.php?act=new">
816
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add server");?>" alt="<?=gettext("add server");?>" width="17" height="17" border="0" />
817
								</a>
818
							</td>
819
						</tr>
820
						<tr>
821
							<td colspan="3">
822
								<p>
823
									<?=gettext("Additional authentication servers can be added here.");?>
824
								</p>
825
							</td>
826
						</tr>
827
					</tfoot>
828
					<tbody>
829
						<?php
830
							$i = 0;
831
							foreach($a_server as $server):
832
								$name = htmlspecialchars($server['name']);
833
								$type = htmlspecialchars($auth_server_types[$server['type']]);
834
								$host = htmlspecialchars($server['host']);
835
						?>
836
						<tr <?php if ($i < (count($a_server) - 1)): ?> ondblclick="document.location='system_authservers.php?act=edit&amp;id=<?=$i;?>'" <?php endif; ?>>
837
							<td class="listlr"><?=$name?>&nbsp;</td>
838
							<td class="listr"><?=$type;?>&nbsp;</td>
839
							<td class="listr"><?=$host;?>&nbsp;</td>
840
							<td valign="middle" class="list nowrap">
841
							<?php if ($i < (count($a_server) - 1)): ?>
842
								<a href="system_authservers.php?act=edit&amp;id=<?=$i;?>">
843
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server");?>" alt="<?=gettext("edit server");?>" width="17" height="17" border="0" />
844
								</a>
845
								&nbsp;
846
								<a href="system_authservers.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Server?");?>')">
847
									<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server");?>" alt="<?=gettext("delete server");?>" width="17" height="17" border="0" />
848
								</a>
849
							<?php endif; ?>
850
							</td>
851
						</tr>
852
						<?php
853
							$i++; endforeach;
854
						?>
855
					</tbody>
856
				</table>
857

    
858
				<?php endif; ?>
859

    
860
			</div>
861
		</td>
862
	</tr>
863
</table>
864
<?php include("fend.inc"); ?>
865
<script type="text/javascript">
866
//<![CDATA[
867
server_typechange('<?=htmlspecialchars($pconfig['type']);?>');
868
<?php if (!isset($id) || $pconfig['type'] == "ldap"): ?>
869
ldap_bindchange();
870
if (document.getElementById("ldap_port").value == "")
871
	ldap_urlchange();
872
<?php if (!isset($id)): ?>
873
ldap_tmplchange();
874
<?php endif; ?>
875
<?php endif; ?>
876
<?php if (!isset($id) || $pconfig['type'] == "radius"): ?>
877
radius_srvcschange();
878
<?php endif; ?>
879
//]]>
880
</script>
881
</body>
882
</html>
(211-211/256)