Project

General

Profile

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

    
5
    Copyright (C) 2010 Ermal Luçi
6
    Copyright (C) 2008 Shrew Soft Inc.
7
    All rights reserved.
8

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

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

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

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

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

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

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

    
47
$id = $_GET['id'];
48
if (isset($_POST['id']))
49
	$id = $_POST['id'];
50

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

    
54
$a_servers = auth_get_authserver_list();
55
foreach ($a_servers as $servers)
56
	$a_server[] = $servers;
57

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

    
62
$act = $_GET['act'];
63
if ($_POST['act'])
64
	$act = $_POST['act'];
65

    
66
if ($act == "del") {
67

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

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

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

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

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

    
91
		$pconfig['type'] = $a_server[$id]['type'];
92
		$pconfig['name'] = $a_server[$id]['name'];
93

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

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

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

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

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

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

    
141
		}
142
	}
143
}
144

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

    
153
if ($_POST) {
154
	unset($input_errors);
155
	$pconfig = $_POST;
156

    
157
	/* input validation */
158

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

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

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

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

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

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

    
210
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
211

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

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

    
218
	if (($pconfig['type'] == "radius") && isset($_POST['radius_timeout']) && (!is_numeric($_POST['radius_timeout']) || (is_numeric($_POST['radius_timeout']) && ($_POST['radius_timeout'] <= 0))))
219
		$input_errors[] = gettext("RADIUS Timeout value must be numeric and positive.");
220

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

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

    
233
		$server['type'] = $pconfig['type'];
234
		$server['name'] = $pconfig['name'];
235

    
236
		if ($server['type'] == "ldap") {
237

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

    
261

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

    
271
		if ($server['type'] == "radius") {
272

    
273
			$server['host'] = $pconfig['radius_host'];
274

    
275
			if ($pconfig['radius_secret'])
276
				$server['radius_secret'] = $pconfig['radius_secret'];
277

    
278
			if ($pconfig['radius_timeout'])
279
				$server['radius_timeout'] = $pconfig['radius_timeout'];
280

    
281
			if ($pconfig['radius_srvcs'] == "both") {
282
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
283
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
284
			}
285

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

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

    
297
		if (isset($id) && $config['system']['authserver'][$id])
298
			$config['system']['authserver'][$id] = $server;
299
		else
300
			$config['system']['authserver'][] = $server;
301

    
302
		write_config();
303

    
304
		pfSenseHeader("system_authservers.php");
305
	}
306
}
307

    
308
include("head.inc");
309
?>
310

    
311
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
312
<?php include("fbegin.inc"); ?>
313
<script type="text/javascript">
314
//<![CDATA[
315

    
316
function server_typechange(typ) {
317

    
318
	var idx = 0;
319
	if (!typ) {
320
		idx = document.getElementById("type").selectedIndex;
321
		typ = document.getElementById("type").options[idx].value;
322
	}
323

    
324
    	switch (typ) {
325
		case "ldap":
326
			document.getElementById("ldap").style.display="";
327
			document.getElementById("radius").style.display="none";
328
			break;
329
		case "radius":
330
			document.getElementById("ldap").style.display="none";
331
			document.getElementById("radius").style.display="";
332
			break;
333
	}
334
}
335

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

    
352
function ldap_bindchange() {
353

    
354
	if (document.getElementById("ldap_anon").checked)
355
		document.getElementById("ldap_bind").style.display="none";
356
    else
357
		document.getElementById("ldap_bind").style.display="";
358
}
359

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

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

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

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

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

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

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

    
591
							</td>
592
						</tr>
593
						<tr>
594
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication containers");?></td>
595
							<td width="78%" class="vtable">
596
								<table border="0" cellspacing="0" cellpadding="2" summary="auth containers">
597
									<tr>
598
										<td><?=gettext("Containers:");?> &nbsp;</td>
599
										<td>
600
											<input name="ldapauthcontainers" type="text" class="formfld unknown" id="ldapauthcontainers" size="40" value="<?=htmlspecialchars($pconfig['ldap_authcn']);?>"/>
601
											<input type="button" onclick="select_clicked();" value="<?=gettext("Select");?>" />
602
											<br /><?=gettext("Note: Semi-Colon separated. This will be prepended to the search base dn above or you can specify full container path.");?>
603
											<br /><?=gettext("Example: CN=Users;DC=example");?>
604
											<br /><?=gettext("Example: CN=Users,DC=example,DC=com;OU=OtherUsers,DC=example,DC=com ");?>
605
										</td>
606
									</tr>
607
								</table>
608
							</td>
609
						</tr>
610
						<tr>
611
							<td width="22%" valign="top" class="vncell"><?=gettext("Extended Query");?></td>
612
							<td width="78%" class="vtable">
613
								<table border="0" cellspacing="0" cellpadding="2" summary="query">
614
									<tr>
615
										<td>
616
											<input name="ldap_extended_enabled" type="checkbox" id="ldap_extended_enabled" value="no" <?php if ($pconfig['ldap_extended_enabled']) echo "checked=\"checked\""; ?> />
617
										</td>
618
										<td>
619

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

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

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

    
796
				<?php else: ?>
797

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

    
854
				<?php endif; ?>
855

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