Project

General

Profile

Feature #1009 » system_authservers.php

Included logic for the optional additional configuration right under authentication containers - Andy I., 08/27/2011 04:38 AM

 
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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
110
			if (!$pconfig['ldap_binddn'] || !$pconfig['ldap_bindpw'])
111
				$pconfig['ldap_anon'] = true;
112
		}
113

    
114
		if ($pconfig['type'] == "radius") {
115
			$pconfig['radius_host'] = $a_server[$id]['host'];
116
			$pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port'];
117
			$pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port'];
118
			$pconfig['radius_secret'] = $a_server[$id]['radius_secret'];
119

    
120
			if ($pconfig['radius_auth_port'] &&
121
				$pconfig['radius_acct_port'] ) {
122
				$pconfig['radius_srvcs'] = "both";
123
			}
124

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

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

    
137
		}
138
	}
139
}
140

    
141
if ($act == "new") {
142
	$pconfig['ldap_protver'] = 3;
143
	$pconfig['ldap_anon'] = true;
144
	$pconfig['radius_srvcs'] = "both";
145
	$pconfig['radius_auth_port'] = "1812";
146
	$pconfig['radius_acct_port'] = "1813";
147
}
148

    
149
if ($_POST) {
150
	unset($input_errors);
151
	$pconfig = $_POST;
152

    
153
	/* input validation */
154

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

    
172
		if (!$pconfig['ldap_anon']) {
173
			$reqdfields[] = "ldap_binddn";
174
			$reqdfields[] = "ldap_bindpw";
175
			$reqdfieldsn[] = gettext("Bind user DN");
176
			$reqdfieldsn[] = gettext("Bind Password");
177
		}
178
	}
179

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

    
188
		if ($pconfig['radisu_srvcs'] == "both" ||
189
			$pconfig['radisu_srvcs'] == "auth") {
190
			$reqdfields[] = "radius_auth_port";
191
			$reqdfieldsn[] = gettext("Authentication port value");
192
		}
193

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

    
200
		if (!isset($id)) {
201
			$reqdfields[] = "radius_secret";
202
			$reqdfieldsn[] = gettext("Shared Secret");
203
		}
204
	}
205

    
206
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
207

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

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

    
214
	/* if this is an AJAX caller then handle via JSON */
215
	if (isAjax() && is_array($input_errors)) {
216
		input_errors2Ajax($input_errors);
217
		exit;
218
	}
219

    
220
	if (!$input_errors) {
221
		$server = array();
222
		$server['refid'] = uniqid();
223
		if (isset($id) && $a_server[$id])
224
			$server = $a_server[$id];
225

    
226
		$server['type'] = $pconfig['type'];
227
		$server['name'] = $pconfig['name'];
228

    
229
		if ($server['type'] == "ldap") {
230

    
231
			if (!empty($pconfig['ldap_caref']))
232
				$server['ldap_caref'] = $pconfig['ldap_caref'];
233
			$server['host'] = $pconfig['ldap_host'];
234
			$server['ldap_port'] = $pconfig['ldap_port'];
235
			$server['ldap_urltype'] = $pconfig['ldap_urltype'];
236
			$server['ldap_protver'] = $pconfig['ldap_protver'];
237
			$server['ldap_scope'] = $pconfig['ldap_scope'];
238
			$server['ldap_basedn'] = $pconfig['ldap_basedn'];
239
			$server['ldap_authcn'] = $pconfig['ldapauthcontainers'];
240
			$server['ldap_extended_enabled'] = $pconfig['ldap_extended_enabled'];
241
			$server['ldap_extended_query'] = $pconfig['ldap_extended_query'];
242
			$server['ldap_attr_user'] = $pconfig['ldap_attr_user'];
243
			$server['ldap_attr_group'] = $pconfig['ldap_attr_group'];
244
			$server['ldap_attr_member'] = $pconfig['ldap_attr_member'];
245

    
246
			if (!$pconfig['ldap_anon']) {
247
				$server['ldap_binddn'] = $pconfig['ldap_binddn'];
248
				$server['ldap_bindpw'] = $pconfig['ldap_bindpw'];
249
			} else {
250
				unset($server['ldap_binddn']);
251
				unset($server['ldap_bindpw']);
252
			}
253
		}
254

    
255
		if ($server['type'] == "radius") {
256

    
257
			$server['host'] = $pconfig['radius_host'];
258

    
259
			if ($pconfig['radius_secret'])
260
				$server['radius_secret'] = $pconfig['radius_secret'];
261

    
262
			if ($pconfig['radius_srvcs'] == "both") {
263
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
264
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
265
			}
266

    
267
			if ($pconfig['radius_srvcs'] == "auth") {
268
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
269
				unset($server['radius_acct_port']);
270
			}
271

    
272
			if ($pconfig['radius_srvcs'] == "acct") {
273
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
274
				unset($server['radius_auth_port']);
275
			}
276
		}
277

    
278
		if (isset($id) && $config['system']['authserver'][$id])
279
			$config['system']['authserver'][$id] = $server;
280
		else
281
			$config['system']['authserver'][] = $server;
282

    
283
		write_config();
284

    
285
		pfSenseHeader("system_authservers.php");
286
	}
287
}
288

    
289
include("head.inc");
290
?>
291

    
292
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
293
<?php include("fbegin.inc"); ?>
294
<script type="text/javascript">
295
<!--
296

    
297
function server_typechange(typ) {
298

    
299
	var idx = 0;
300
	if (!typ) {
301
		idx = document.getElementById("type").selectedIndex;
302
		typ = document.getElementById("type").options[idx].value;
303
	}
304

    
305
    	switch (typ) {
306
		case "ldap":
307
			document.getElementById("ldap").style.display="";
308
			document.getElementById("radius").style.display="none";
309
			break;
310
		case "radius":
311
			document.getElementById("ldap").style.display="none";
312
			document.getElementById("radius").style.display="";
313
			break;
314
	}
315
}
316

    
317
function ldap_urlchange() {
318
    switch (document.getElementById("ldap_urltype").selectedIndex) {
319
<?php
320
	$index = 0;
321
	foreach ($ldap_urltypes as $urltype => $urlport):
322
?>
323
		case <?=$index;?>:
324
			document.getElementById("ldap_port").value = "<?=$urlport;?>";
325
			break;
326
<?php
327
		$index++;
328
	endforeach;
329
?>
330
	}
331
}
332

    
333
function ldap_bindchange() {
334

    
335
	if (document.getElementById("ldap_anon").checked)
336
		document.getElementById("ldap_bind").style.display="none";
337
    else
338
		document.getElementById("ldap_bind").style.display="";
339
}
340

    
341
function ldap_tmplchange(){
342
    switch (document.getElementById("ldap_tmpltype").selectedIndex) {
343
<?php
344
	$index = 0;
345
	foreach ($ldap_templates as $tmpldata):
346
?>
347
		case <?=$index;?>:
348
			document.getElementById("ldap_attr_user").value = "<?=$tmpldata['attr_user'];?>";
349
			document.getElementById("ldap_attr_group").value = "<?=$tmpldata['attr_group'];?>";
350
			document.getElementById("ldap_attr_member").value = "<?=$tmpldata['attr_member'];?>";
351
			break;
352
<?php
353
		$index++;
354
	endforeach;
355
?>
356
	}
357
}
358

    
359
function radius_srvcschange(){
360
    switch (document.getElementById("radius_srvcs").selectedIndex) {
361
		case 0: // both
362
			document.getElementById("radius_auth").style.display="";
363
			document.getElementById("radius_acct").style.display="";
364
			break;
365
		case 1: // authentication
366
			document.getElementById("radius_auth").style.display="";
367
			document.getElementById("radius_acct").style.display="none";
368
			break;
369
		case 2: // accounting
370
			document.getElementById("radius_auth").style.display="none";
371
			document.getElementById("radius_acct").style.display="";
372
			break;
373
	}
374
}
375

    
376
function select_clicked() {
377
	if (document.getElementById("ldap_port").value == '' ||
378
	    document.getElementById("ldap_host").value == '' ||
379
	    document.getElementById("ldap_scope").value == '' ||
380
	    document.getElementById("ldap_basedn").value == '' ||
381
	    document.getElementById("ldapauthcontainers").value == '') {
382
		alert("<?=gettext("Please fill the required values.");?>");
383
		return;
384
	}
385
	if (!document.getElementById("ldap_anon").checked) {
386
		if (document.getElementById("ldap_binddn").value == '' ||
387
		    document.getElementById("ldap_bindpw").value == '') {
388
				alert("<?=gettext("Please fill the bind username/password.");?>");
389
			return;
390
		}
391
	}
392
        var url = 'system_usermanager_settings_ldapacpicker.php?';
393
        url += 'port=' + document.getElementById("ldap_port").value;
394
        url += '&host=' + document.getElementById("ldap_host").value;
395
        url += '&scope=' + document.getElementById("ldap_scope").value;
396
        url += '&basedn=' + document.getElementById("ldap_basedn").value;
397
        url += '&binddn=' + document.getElementById("ldap_binddn").value;
398
        url += '&bindpw=' + document.getElementById("ldap_bindpw").value;
399
        url += '&urltype=' + document.getElementById("ldap_urltype").value;
400
        url += '&proto=' + document.getElementById("ldap_protver").value;
401
	url += '&authcn=' + document.getElementById("ldapauthcontainers").value;
402
	url += '&cert=' + document.getElementById("ldap_caref").value;
403

    
404
        var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
405
        if (oWin==null || typeof(oWin)=="undefined")
406
			alert("<?=gettext('Popup blocker detected.  Action aborted.');?>");
407
}
408
//-->
409
</script>
410
<?php
411
	if ($input_errors)
412
		print_input_errors($input_errors);
413
	if ($savemsg)
414
		print_info_box($savemsg);
415
?>
416
<table width="100%" border="0" cellpadding="0" cellspacing="0">
417
	<tr>
418
		<td>
419
		<?php
420
			$tab_array = array();
421
			$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
422
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
423
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
424
			$tab_array[] = array(gettext("Servers"), true, "system_authservers.php");
425
			display_top_tabs($tab_array);
426
		?>
427
		</td>
428
	</tr>
429
	<tr>
430
		<td id="mainarea">
431
			<div class="tabcont">
432

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

    
435
				<form action="system_authservers.php" method="post" name="iform" id="iform">
436
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
437
						<tr>
438
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
439
							<td width="78%" class="vtable">
440
							<?php if (!isset($id)): ?>
441
								<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
442
							<?php else: ?>
443
                                                                <strong><?=htmlspecialchars($pconfig['name']);?></strong>
444
                                                                <input name='name' type='hidden' id='name' value="<?=htmlspecialchars($pconfig['name']);?>"/>
445
                                                                <?php endif; ?>
446
							</td>
447
						</tr>
448
						<tr>
449
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Type");?></td>
450
							<td width="78%" class="vtable">
451
								<?php if (!isset($id)): ?>
452
								<select name='type' id='type' class="formselect" onchange='server_typechange()'>
453
								<?php
454
									foreach ($auth_server_types as $typename => $typedesc ):
455
										$selected = "";
456
										if ($pconfig['type'] == $typename)
457
											$selected = "selected";
458
								?>
459
									<option value="<?=$typename;?>" <?=$selected;?>><?=$typedesc;?></option>
460
								<?php endforeach; ?>
461
								</select>
462
								<?php else: ?>
463
								<strong><?=$auth_server_types[$pconfig['type']];?></strong>
464
								<input name='type' type='hidden' id='type' value="<?=htmlspecialchars($pconfig['type']);?>"/>
465
								<?php endif; ?>
466
							</td>
467
						</tr>
468
					</table>
469

    
470
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="ldap" style="display:none">
471
						<tr>
472
							<td colspan="2" class="list" height="12"></td>
473
						</tr>
474
						<tr>
475
							<td colspan="2" valign="top" class="listtopic"><?=gettext("LDAP Server Settings");?></td>
476
						</tr>
477
						<tr>
478
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP address");?></td>
479
							<td width="78%" class="vtable">
480
								<input name="ldap_host" type="text" class="formfld unknown" id="ldap_host" size="20" value="<?=htmlspecialchars($pconfig['ldap_host']);?>"/>
481
							</td>
482
						</tr>
483
						<tr>
484
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Port value");?></td>
485
							<td width="78%" class="vtable">
486
								<input name="ldap_port" type="text" class="formfld unknown" id="ldap_port" size="5" value="<?=htmlspecialchars($pconfig['ldap_port']);?>"/>
487
							</td>
488
						</tr>
489
						<tr>
490
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Transport");?></td>
491
							<td width="78%" class="vtable">
492
								<select name='ldap_urltype' id='ldap_urltype' class="formselect" onchange='ldap_urlchange()'>
493
								<?php
494
									foreach ($ldap_urltypes as $urltype => $urlport):
495
										$selected = "";
496
										if ($pconfig['ldap_urltype'] == $urltype)
497
											$selected = "selected";
498
								?>
499
									<option value="<?=$urltype;?>" <?=$selected;?>><?=$urltype;?></option>
500
								<?php endforeach; ?>
501
								</select>
502
							</td>
503
						</tr>
504
						<tr id="tls_ca">
505
							<td width="22%" valign="top" class="vncell"><?=gettext("Peer Certificate Authority"); ?></td>
506
                                                        <td width="78%" class="vtable">
507
                                                        <?php if (count($a_ca)): ?>
508
								<select name='ldap_caref' class="formselect">
509
                                                        <?php
510
                                                                foreach ($a_ca as $ca):
511
                                                                        $selected = "";
512
                                                                        if ($pconfig['ldap_caref'] == $ca['refid'])
513
                                                                                $selected = "selected";
514
                                                        ?>
515
									<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=$ca['descr'];?></option>
516
                                                        <?php	endforeach; ?>
517
								</select>
518
								<br/><span><?=gettext("This option is used if 'SSL Encrypted' option is choosen.");?> <br/>
519
								<?=gettext("It must match with the CA in the AD otherwise problems will arise.");?></span>
520
                                                        <?php else: ?>
521
                                                                <b>No Certificate Authorities defined.</b> <br/>Create one under <a href="system_camanager.php">System &gt; Cert Manager</a>.
522
                                                        <?php endif; ?>
523
                                                        </td>
524
						</tr>
525
						<tr>
526
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol version");?></td>
527
							<td width="78%" class="vtable">
528
								<select name='ldap_protver' id='ldap_protver' class="formselect">
529
								<?php
530
									foreach ($ldap_protvers as $version):
531
										$selected = "";
532
										if ($pconfig['ldap_protver'] == $version)
533
											$selected = "selected";
534
								?>
535
									<option value="<?=$version;?>" <?=$selected;?>><?=$version;?></option>
536
								<?php endforeach; ?>
537
								</select>
538
							</td>
539
						</tr>
540
						<tr>
541
							<td width="22%" valign="top" class="vncell"><?=gettext("Search scope");?></td>
542
							<td width="78%" class="vtable">
543
								<table border="0" cellspacing="0" cellpadding="2">
544
									<tr>
545
										<td><?=gettext("Level:");?> &nbsp;</td>
546
										<td>
547
											<select name='ldap_scope' id='ldap_scope' class="formselect">
548
											<?php
549
												foreach ($ldap_scopes as $scopename => $scopedesc):
550
													$selected = "";
551
													if ($pconfig['ldap_scope'] == $scopename)
552
														$selected = "selected";
553
											?>
554
												<option value="<?=$scopename;?>" <?=$selected;?>><?=$scopedesc;?></option>
555
											<?php endforeach; ?>
556
											</select>
557
										</td>
558
									</tr>
559
									<tr>
560
										<td><?=gettext("Base DN:");?> &nbsp;</td>
561
										<td>
562
											<input name="ldap_basedn" type="text" class="formfld unknown" id="ldap_basedn" size="40" value="<?=htmlspecialchars($pconfig['ldap_basedn']);?>"/>
563
										</td>
564
									</tr>
565
								</table>
566

    
567
							</td>
568
						</tr>
569
						<tr>
570
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication containers");?></td>
571
							<td width="78%" class="vtable">
572
								<table border="0" cellspacing="0" cellpadding="2">
573
									<tr>
574
										<td><?=gettext("Containers:");?> &nbsp;</td>
575
										<td>
576
											<input name="ldapauthcontainers" type="text" class="formfld unknown" id="ldapauthcontainers" size="40" value="<?=htmlspecialchars($pconfig['ldap_authcn']);?>"/>
577
											<input type="button" onClick="select_clicked();" value="<?=gettext("Select");?>">
578
											<br /><?=gettext("Note: Semi-Colon separated. This will be prepended to the search base dn above or you can specify full container path.");?>
579
											<br /><?=gettext("Example: CN=Users;DC=example");?>
580
											<br /><?=gettext("Example: CN=Users,DC=example,DC=com;OU=OtherUsers,DC=example,DC=com ");?>
581
										</td>
582
									</tr>
583
								</table>
584
							</td>
585
						</tr>
586
						<tr>
587
							<td width="22%" valign="top" class="vncell"><?=gettext("Extended Query");?></td>
588
							<td width="78%" class="vtable">
589
								<table border="0" cellspacing="0" cellpadding="2">
590
									<tr>
591
										<td>
592
											<input name="ldap_extended_enabled" type="checkbox" id="ldap_extended_enabled" value="no" <?php if ($pconfig['ldap_extended_enabled']) echo "checked"; ?> >
593
										</td>
594
										<td>
595

    
596
											<input name="ldap_extended_query" type="text" class="formfld unknown" id="ldap_extended_query" size="40" value="<?=htmlspecialchars($pconfig['ldap_extended_query']);?>"/>
597
											<br /><?=gettext("Example: CN=Groupname,OU=MyGroups,DC=example,DC=com;OU=OtherUsers,DC=example,DC=com ");?>
598
										</td>
599
									</tr>
600
								</table>
601
							</td>
602
						</tr>
603
						<tr>
604
							<td width="22%" valign="top" class="vncell"><?=gettext("Bind credentials");?></td>
605
							<td width="78%" class="vtable">
606
								<table border="0" cellspacing="0" cellpadding="2">
607
									<tr>
608
										<td>
609
											<input name="ldap_anon" type="checkbox" id="ldap_anon" value="yes" <?php if ($pconfig['ldap_anon']) echo "checked"; ?> onClick="ldap_bindchange()">
610
										</td>
611
										<td>
612
											<?=gettext("Use anonymous binds to resolve distinguished names");?>
613
										</td>
614
									</tr>
615
								</table>
616
								<table border="0" cellspacing="0" cellpadding="2" id="ldap_bind">
617
									<tr>
618
										<td colspan="2"></td>
619
									</tr>
620
									<tr>
621
										<td><?=gettext("User DN:");?> &nbsp;</td>
622
										<td>
623
											<input name="ldap_binddn" type="text" class="formfld unknown" id="ldap_binddn" size="40" value="<?=htmlspecialchars($pconfig['ldap_binddn']);?>"/><br/>
624
										</td>
625
									</tr>
626
									<tr>
627
										<td><?=gettext("Password:");?> &nbsp;</td>
628
										<td>
629
											<input name="ldap_bindpw" type="password" class="formfld pwd" id="ldap_bindpw" size="20" value="<?=htmlspecialchars($pconfig['ldap_bindpw']);?>"/><br/>
630
										</td>
631
									</tr>
632
								</table>
633
							</td>
634
						</tr>
635
						<?php if (!isset($id)): ?>
636
						<tr>
637
							<td width="22%" valign="top" class="vncell"><?=gettext("Initial Template");?></td>
638
							<td width="78%" class="vtable">
639
								<select name='ldap_tmpltype' id='ldap_tmpltype' class="formselect" onchange='ldap_tmplchange()'>
640
								<?php
641
									foreach ($ldap_templates as $tmplname => $tmpldata):
642
										$selected = "";
643
										if ($pconfig['ldap_template'] == $tmplname)
644
											$selected = "selected";
645
								?>
646
									<option value="<?=$tmplname;?>" <?=$selected;?>><?=$tmpldata['desc'];?></option>
647
								<?php endforeach; ?>
648
								</select>
649
							</td>
650
						</tr>
651
						<?php endif; ?>
652
						<tr>
653
							<td width="22%" valign="top" class="vncell"><?=gettext("User naming attribute");?></td>
654
							<td width="78%" class="vtable">
655
								<input name="ldap_attr_user" type="text" class="formfld unknown" id="ldap_attr_user" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_user']);?>"/>
656
							</td>
657
						</tr>
658
						<tr>
659
							<td width="22%" valign="top" class="vncell"><?=gettext("Group naming attribute");?></td>
660
							<td width="78%" class="vtable">
661
								<input name="ldap_attr_group" type="text" class="formfld unknown" id="ldap_attr_group" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_group']);?>"/>
662
							</td>
663
						</tr>
664
						<tr>
665
							<td width="22%" valign="top" class="vncell"><?=gettext("Group member attribute");?></td>
666
							<td width="78%" class="vtable">
667
								<input name="ldap_attr_member" type="text" class="formfld unknown" id="ldap_attr_member" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_member']);?>"/>
668
							</td>
669
						</tr>
670
					</table>
671

    
672
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="radius" style="display:none">
673
						<tr>
674
							<td colspan="2" class="list" height="12"></td>
675
						</tr>
676
						<tr>
677
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Radius Server Settings");?></td>
678
						</tr>
679
						<tr>
680
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP address");?></td>
681
							<td width="78%" class="vtable">
682
								<input name="radius_host" type="text" class="formfld unknown" id="radius_host" size="20" value="<?=htmlspecialchars($pconfig['radius_host']);?>"/>
683
							</td>
684
						</tr>
685
						<tr>
686
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Secret");?></td>
687
							<td width="78%" class="vtable">
688
								<input name="radius_secret" type="password" class="formfld pwd" id="radius_secret" size="20" value="<?=htmlspecialchars($pconfig['radius_secret']);?>"/>
689
							</td>
690
						</tr>
691
						<tr>
692
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Services offered");?></td>
693
							<td width="78%" class="vtable">
694
								<select name='radius_srvcs' id='radius_srvcs' class="formselect" onchange='radius_srvcschange()'>
695
								<?php
696
									foreach ($radius_srvcs as $srvcname => $srvcdesc):
697
										$selected = "";
698
										if ($pconfig['radius_srvcs'] == $srvcname)
699
											$selected = "selected";
700
								?>
701
									<option value="<?=$srvcname;?>" <?=$selected;?>><?=$srvcdesc;?></option>
702
								<?php endforeach; ?>
703
								</select>
704
							</td>
705
						</tr>
706
						<tr id="radius_auth">
707
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication port value");?></td>
708
							<td width="78%" class="vtable">
709
								<input name="radius_auth_port" type="text" class="formfld unknown" id="radius_auth_port" size="5" value="<?=htmlspecialchars($pconfig['radius_auth_port']);?>"/>
710
							</td>
711
						</tr>
712
						<tr id="radius_acct">
713
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Accounting port value");?></td>
714
							<td width="78%" class="vtable">
715
								<input name="radius_acct_port" type="text" class="formfld unknown" id="radius_acct_port" size="5" value="<?=htmlspecialchars($pconfig['radius_acct_port']);?>"/>
716
							</td>
717
						</tr>
718
					</table>
719

    
720
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
721
						<tr>
722
							<td width="22%" valign="top">&nbsp;</td>
723
							<td width="78%">
724
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
725
								<?php if (isset($id) && $a_server[$id]): ?>
726
								<input name="id" type="hidden" value="<?=$id;?>" />
727
								<?php endif;?>
728
							</td>
729
						</tr>
730
					</table>
731
				</form>
732

    
733
				<?php else: ?>
734

    
735
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
736
					<tr>
737
						<td width="25%" class="listhdrr"><?=gettext("Server Name");?></td>
738
						<td width="25%" class="listhdrr"><?=gettext("Type");?></td>
739
						<td width="35%" class="listhdrr"><?=gettext("Host Name");?></td>
740
						<td width="10%" class="list"></td>
741
					</tr>
742
					<?php
743
						$i = 0;
744
						foreach($a_server as $server):
745
							$name = htmlspecialchars($server['name']);
746
							$type = htmlspecialchars($auth_server_types[$server['type']]);
747
							$host = htmlspecialchars($server['host']);
748
					?>
749
					<tr <?php if ($i < (count($a_server) - 1)): ?> ondblclick="document.location='system_authservers.php?act=edit&id=<?=$i;?>'" <?php endif; ?>>
750
						<td class="listlr"><?=$name?>&nbsp;</td>
751
						<td class="listr"><?=$type;?>&nbsp;</td>
752
						<td class="listr"><?=$host;?>&nbsp;</td>
753
						<td valign="middle" nowrap class="list">
754
						<?php if ($i < (count($a_server) - 1)): ?>
755
							<a href="system_authservers.php?act=edit&id=<?=$i;?>">
756
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server");?>" alt="<?=gettext("edit server");?>" width="17" height="17" border="0" />
757
							</a>
758
							&nbsp;
759
							<a href="system_authservers.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Server?");?>')">
760
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server");?>" alt="<?=gettext("delete server");?>" width="17" height="17" border="0" />
761
							</a>
762
						<?php endif; ?>
763
						</td>
764
					</tr>
765
					<?php
766
						$i++; endforeach;
767
					?>
768
					<tr>
769
						<td class="list" colspan="3"></td>
770
						<td class="list">
771
							<a href="system_authservers.php?act=new">
772
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add server");?>" alt="<?=gettext("add server");?>" width="17" height="17" border="0" />
773
							</a>
774
						</td>
775
					</tr>
776
					<tr>
777
						<td colspan="3">
778
							<p>
779
								<?=gettext("Additional authentication servers can be added here.");?>
780
							</p>
781
						</td>
782
					</tr>
783
				</table>
784

    
785
				<?php endif; ?>
786

    
787
			</div>
788
		</td>
789
	</tr>
790
</table>
791
<?php include("fend.inc"); ?>
792
<script type="text/javascript">
793
<!--
794
server_typechange('<?=htmlspecialchars($pconfig['type']);?>');
795
<?php if (!isset($id) || $pconfig['type'] == "ldap"): ?>
796
ldap_bindchange();
797
ldap_urlchange();
798
<?php if (!isset($id)): ?>
799
ldap_tmplchange();
800
<?php endif; ?>
801
<?php endif; ?>
802
<?php if (!isset($id) || $pconfig['type'] == "radius"): ?>
803
radius_srvcschange();
804
<?php endif; ?>
805
//-->
806
</script>
807
</body>
(3-3/4)