Project

General

Profile

Download (30.1 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

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

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

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

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

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

    
138
		}
139
	}
140
}
141

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

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

    
154
	/* input validation */
155

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
284
		write_config();
285

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

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

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

    
298
function server_typechange(typ) {
299

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

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

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

    
334
function ldap_bindchange() {
335

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

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

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

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

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

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

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

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

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

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

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

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

    
738
				<?php else: ?>
739

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

    
796
				<?php endif; ?>
797

    
798
			</div>
799
		</td>
800
	</tr>
801
</table>
802
<?php include("fend.inc"); ?>
803
<script type="text/javascript">
804
<!--
805
server_typechange('<?=htmlspecialchars($pconfig['type']);?>');
806
<?php if (!isset($id) || $pconfig['type'] == "ldap"): ?>
807
ldap_bindchange();
808
if (document.getElementById("ldap_port").value == "")
809
	ldap_urlchange();
810
<?php if (!isset($id)): ?>
811
ldap_tmplchange();
812
<?php endif; ?>
813
<?php endif; ?>
814
<?php if (!isset($id) || $pconfig['type'] == "radius"): ?>
815
radius_srvcschange();
816
<?php endif; ?>
817
//-->
818
</script>
819
</body>
(205-205/249)