Project

General

Profile

Download (26.8 KB) Statistics
| Branch: | Tag: | Revision:
1 fbf672cb Matthew Grooms
<?php
2
/*
3
    system_authservers.php
4
5 8a6b0fbe Ermal Lu?i
    Copyright (C) 2010 Ermal Lu?i
6 fbf672cb Matthew Grooms
    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 1d333258 Scott Ullrich
/*
31
	pfSense_MODULE:	auth
32
*/
33 fbf672cb Matthew Grooms
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 acee624f Ermal Lu?i
require_once("auth.inc");
43 fbf672cb Matthew Grooms
44 257705ca Renato Botelho
$pgtitle = array(gettext("System"), gettext("Authentication Servers"));
45 fbf672cb Matthew Grooms
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 6306b5dd Ermal Lu?i
$a_servers = auth_get_authserver_list();
54
foreach ($a_servers as $servers)
55
	$a_server[] = $servers;
56 fbf672cb Matthew Grooms
57
$act = $_GET['act'];
58
if ($_POST['act'])
59
	$act = $_POST['act'];
60
61
if ($act == "del") {
62
63
	if (!$a_server[$_GET['id']]) {
64
		pfSenseHeader("system_authservers.php");
65
		exit;
66
	}
67
68 9db6993f jim-p
	/* Remove server from main list. */
69 fbf672cb Matthew Grooms
	$serverdeleted = $a_server[$_GET['id']]['name'];
70 9db6993f jim-p
	foreach ($config['system']['authserver'] as $k => $as) {
71
		if ($config['system']['authserver'][$k]['name'] == $serverdeleted)
72
			unset($config['system']['authserver'][$k]);
73
	}
74
75
	/* Remove server from temp list used later on this page. */
76 fbf672cb Matthew Grooms
	unset($a_server[$_GET['id']]);
77 9db6993f jim-p
78 fbf672cb Matthew Grooms
	$savemsg = gettext("Authentication Server")." {$serverdeleted} ".
79 9db6993f jim-p
				gettext("deleted")."<br/>";
80
	write_config($savemsg);
81 fbf672cb Matthew Grooms
}
82
83
if ($act == "edit") {
84
	if (isset($id) && $a_server[$id]) {
85
86
		$pconfig['type'] = $a_server[$id]['type'];
87
		$pconfig['name'] = $a_server[$id]['name'];
88
89
		if ($pconfig['type'] == "ldap") {
90
			$pconfig['ldap_host'] = $a_server[$id]['host'];
91
			$pconfig['ldap_port'] = $a_server[$id]['ldap_port'];
92
			$pconfig['ldap_urltype'] = $a_server[$id]['ldap_urltype'];
93
			$pconfig['ldap_protver'] = $a_server[$id]['ldap_protver'];
94
			$pconfig['ldap_scope'] = $a_server[$id]['ldap_scope'];
95
			$pconfig['ldap_basedn'] = $a_server[$id]['ldap_basedn'];
96 c61e4626 Ermal Lu?i
			$pconfig['ldap_authcn'] = $a_server[$id]['ldap_authcn'];
97 fbf672cb Matthew Grooms
			$pconfig['ldap_binddn'] = $a_server[$id]['ldap_binddn'];
98
			$pconfig['ldap_bindpw'] = $a_server[$id]['ldap_bindpw'];
99
			$pconfig['ldap_attr_user'] = $a_server[$id]['ldap_attr_user'];
100
			$pconfig['ldap_attr_group'] = $a_server[$id]['ldap_attr_group'];
101
			$pconfig['ldap_attr_member'] = $a_server[$id]['ldap_attr_member'];
102
103
			if (!$pconfig['ldap_binddn'] || !$pconfig['ldap_bindpw'])
104
				$pconfig['ldap_anon'] = true;
105
		}
106
107
		if ($pconfig['type'] == "radius") {
108
			$pconfig['radius_host'] = $a_server[$id]['host'];
109
			$pconfig['radius_auth_port'] = $a_server[$id]['radius_auth_port'];
110
			$pconfig['radius_acct_port'] = $a_server[$id]['radius_acct_port'];
111 e8a58de4 Ermal Lu?i
			$pconfig['radius_secret'] = $a_server[$id]['radius_secret'];
112 fbf672cb Matthew Grooms
113
			if ($pconfig['radius_auth_port'] &&
114
				$pconfig['radius_acct_port'] ) {
115
				$pconfig['radius_srvcs'] = "both";
116
			}
117
118
			if ( $pconfig['radius_auth_port'] &&
119
				!$pconfig['radius_acct_port'] ) {
120
				$pconfig['radius_srvcs'] = "auth";
121 acee624f Ermal Lu?i
				$pconfig['radius_acct_port'] = 1813;
122 fbf672cb Matthew Grooms
			}
123
124
			if (!$pconfig['radius_auth_port'] &&
125
				 $pconfig['radius_acct_port'] ) {
126
				$pconfig['radius_srvcs'] = "acct";
127 acee624f Ermal Lu?i
				$pconfig['radius_auth_port'] = 1812;
128 fbf672cb Matthew Grooms
			}
129
130
		}
131
	}
132
}
133
134
if ($act == "new") {
135
	$pconfig['ldap_protver'] = 3;
136
	$pconfig['ldap_anon'] = true;
137
	$pconfig['radius_srvcs'] = "both";
138 acee624f Ermal Lu?i
	$pconfig['radius_auth_port'] = "1812";
139
	$pconfig['radius_acct_port'] = "1813";
140 fbf672cb Matthew Grooms
}
141
142
if ($_POST) {
143
	unset($input_errors);
144
	$pconfig = $_POST;
145
146
	/* input validation */
147
148
	if ($pconfig['type'] == "ldap") {
149
		$reqdfields = explode(" ", "name type ldap_host ldap_port ".
150
						"ldap_urltype ldap_protver ldap_scope ldap_basedn ".
151 c61e4626 Ermal Lu?i
						"ldap_attr_user ldap_attr_group ldap_attr_member ldapauthcontainers");
152 257705ca Renato Botelho
		$reqdfieldsn = array(
153
			gettext("Descriptive name"),
154
			gettext("Type"),
155
			gettext("Hostname or IP"),
156
			gettext("Port value"),
157
			gettext("Transport"),
158
			gettext("Protocol version"),
159
			gettext("Search level"),
160
			gettext("Search Base DN"),
161
			gettext("User naming Attribute"),
162
			gettext("Group naming Attribute"),
163
			gettext("Group member attribute"),
164
			gettext("Authentication container"));
165 fbf672cb Matthew Grooms
166
		if (!$pconfig['ldap_anon']) {
167
			$reqdfields[] = "ldap_binddn";
168
			$reqdfields[] = "ldap_bindpw";
169 257705ca Renato Botelho
			$reqdfieldsn[] = gettext("Bind user DN");
170
			$reqdfieldsn[] = gettext("Bind Password");
171 fbf672cb Matthew Grooms
		}
172 acee624f Ermal Lu?i
173 fbf672cb Matthew Grooms
	}
174
175
	if ($pconfig['type'] == "radius") {
176
		$reqdfields = explode(" ", "name type radius_host radius_srvcs");
177 257705ca Renato Botelho
		$reqdfieldsn = array(
178
			gettext("Descriptive name"),
179
			gettext("Type"),
180
			gettext("Hostname or IP"),
181
			gettext("Services"));
182 fbf672cb Matthew Grooms
183
		if ($pconfig['radisu_srvcs'] == "both" ||
184
			$pconfig['radisu_srvcs'] == "auth") {
185
			$reqdfields[] = "radius_auth_port";
186 257705ca Renato Botelho
			$reqdfieldsn[] = gettext("Authentication port value");
187 fbf672cb Matthew Grooms
		}
188
189
		if ($pconfig['radisu_srvcs'] == "both" ||
190
			$pconfig['radisu_srvcs'] == "acct") {
191
			$reqdfields[] = "radius_acct_port";
192 257705ca Renato Botelho
			$reqdfieldsn[] = gettext("Accounting port value");
193 fbf672cb Matthew Grooms
		}
194
195
		if (!isset($id)) {
196
			$reqdfields[] = "radius_secret";
197 257705ca Renato Botelho
			$reqdfieldsn[] = gettext("Shared Secret");
198 fbf672cb Matthew Grooms
		}
199
	}
200
201
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
202
203
	if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['host']))
204
		$input_errors[] = gettext("The host name contains invalid characters.");
205
206 6306b5dd Ermal Lu?i
	if (auth_get_authserver($pconfig['name']) && !isset($id))
207 257705ca Renato Botelho
		$input_errors[] = gettext("An authentication server with the same name already exists.");
208 acee624f Ermal Lu?i
209 fbf672cb Matthew Grooms
	/* if this is an AJAX caller then handle via JSON */
210
	if (isAjax() && is_array($input_errors)) {
211
		input_errors2Ajax($input_errors);
212
		exit;
213
	}
214
215
	if (!$input_errors) {
216
		$server = array();
217
		$server['refid'] = uniqid();
218
		if (isset($id) && $a_server[$id])
219
			$server = $a_server[$id];
220
221
		$server['type'] = $pconfig['type'];
222
		$server['name'] = $pconfig['name'];
223
224
		if ($server['type'] == "ldap") {
225
226
			$server['host'] = $pconfig['ldap_host'];
227
			$server['ldap_port'] = $pconfig['ldap_port'];
228
			$server['ldap_urltype'] = $pconfig['ldap_urltype'];
229
			$server['ldap_protver'] = $pconfig['ldap_protver'];
230
			$server['ldap_scope'] = $pconfig['ldap_scope'];
231
			$server['ldap_basedn'] = $pconfig['ldap_basedn'];
232 c61e4626 Ermal Lu?i
			$server['ldap_authcn'] = $pconfig['ldapauthcontainers'];
233 fbf672cb Matthew Grooms
			$server['ldap_attr_user'] = $pconfig['ldap_attr_user'];
234
			$server['ldap_attr_group'] = $pconfig['ldap_attr_group'];
235
			$server['ldap_attr_member'] = $pconfig['ldap_attr_member'];
236
237
			if (!$pconfig['ldap_anon']) {
238
				$server['ldap_binddn'] = $pconfig['ldap_binddn'];
239
				$server['ldap_bindpw'] = $pconfig['ldap_bindpw'];
240
			} else {
241
				unset($server['ldap_binddn']);
242
				unset($server['ldap_bindpw']);
243
			}
244
		}
245
246
		if ($server['type'] == "radius") {
247
248
			$server['host'] = $pconfig['radius_host'];
249
250
			if ($pconfig['radius_secret'])
251
				$server['radius_secret'] = $pconfig['radius_secret'];
252
253
			if ($pconfig['radius_srvcs'] == "both") {
254
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
255
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
256
			}
257
258
			if ($pconfig['radius_srvcs'] == "auth") {
259
				$server['radius_auth_port'] = $pconfig['radius_auth_port'];
260
				unset($server['radius_acct_port']);
261
			}
262
263
			if ($pconfig['radius_srvcs'] == "acct") {
264
				$server['radius_acct_port'] = $pconfig['radius_acct_port'];
265
				unset($server['radius_auth_port']);
266
			}
267
		}
268
269 6306b5dd Ermal Lu?i
		if (isset($id) && $config['system']['authserver'][$id])
270
			$config['system']['authserver'][$id] = $server;
271 fbf672cb Matthew Grooms
		else
272 6306b5dd Ermal Lu?i
			$config['system']['authserver'][] = $server;
273 fbf672cb Matthew Grooms
274
		write_config();
275
276
		pfSenseHeader("system_authservers.php");
277
	}
278
}
279
280
include("head.inc");
281
?>
282
283
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
284
<?php include("fbegin.inc"); ?>
285
<script type="text/javascript">
286
<!--
287
288 6306b5dd Ermal Lu?i
function server_typechange(typ) {
289 fbf672cb Matthew Grooms
290 6306b5dd Ermal Lu?i
	var idx = 0;
291
	if (!typ) {
292
		idx = document.getElementById("type").selectedIndex;
293
		typ = document.getElementById("type").options[idx].value;
294 fbf672cb Matthew Grooms
	}
295
296 6306b5dd Ermal Lu?i
    	switch (typ) {
297 fbf672cb Matthew Grooms
		case "ldap":
298
			document.getElementById("ldap").style.display="";
299
			document.getElementById("radius").style.display="none";
300
			break;
301
		case "radius":
302
			document.getElementById("ldap").style.display="none";
303
			document.getElementById("radius").style.display="";
304
			break;
305
	}
306
}
307
308
function ldap_urlchange() {
309 6306b5dd Ermal Lu?i
    switch (document.getElementById("ldap_urltype").selectedIndex) {
310 fbf672cb Matthew Grooms
<?php
311
	$index = 0;
312
	foreach ($ldap_urltypes as $urltype => $urlport):
313
?>
314
		case <?=$index;?>:
315 6306b5dd Ermal Lu?i
			document.getElementById("ldap_port").value = "<?=$urlport;?>";
316 fbf672cb Matthew Grooms
			break;
317
<?php
318
		$index++;
319
	endforeach;
320
?>
321
	}
322
}
323
324
function ldap_bindchange() {
325
326 6306b5dd Ermal Lu?i
	if (document.getElementById("ldap_anon").checked)
327 fbf672cb Matthew Grooms
		document.getElementById("ldap_bind").style.display="none";
328
    else
329
		document.getElementById("ldap_bind").style.display="";
330
}
331
332
function ldap_tmplchange(){
333 6306b5dd Ermal Lu?i
    switch (document.getElementById("ldap_tmpltype").selectedIndex) {
334 fbf672cb Matthew Grooms
<?php
335
	$index = 0;
336
	foreach ($ldap_templates as $tmpldata):
337
?>
338
		case <?=$index;?>:
339 6306b5dd Ermal Lu?i
			document.getElementById("ldap_attr_user").value = "<?=$tmpldata['attr_user'];?>";
340
			document.getElementById("ldap_attr_group").value = "<?=$tmpldata['attr_group'];?>";
341
			document.getElementById("ldap_attr_member").value = "<?=$tmpldata['attr_member'];?>";
342 fbf672cb Matthew Grooms
			break;
343
<?php
344
		$index++;
345
	endforeach;
346
?>
347
	}
348
}
349
350
function radius_srvcschange(){
351 6306b5dd Ermal Lu?i
    switch (document.getElementById("radius_srvcs").selectedIndex) {
352 fbf672cb Matthew Grooms
		case 0: // both
353
			document.getElementById("radius_auth").style.display="";
354
			document.getElementById("radius_acct").style.display="";
355
			break;
356
		case 1: // authentication
357
			document.getElementById("radius_auth").style.display="";
358
			document.getElementById("radius_acct").style.display="none";
359
			break;
360
		case 2: // accounting
361
			document.getElementById("radius_auth").style.display="none";
362
			document.getElementById("radius_acct").style.display="";
363
			break;
364
	}
365
}
366
367 6306b5dd Ermal Lu?i
function select_clicked() {
368 7a938f1b Ermal
	if (document.getElementById("ldap_port").value == '' ||
369
	    document.getElementById("ldap_host").value == '' ||
370
	    document.getElementById("ldap_scope").value == '' ||
371
	    document.getElementById("ldap_basedn").value == '' ||
372
	    document.getElementById("ldapauthcontainers").value == '') {
373 257705ca Renato Botelho
		alert("<?=gettext("Please fill the required values.");?>");
374 7a938f1b Ermal
		return;
375
	}
376
	if (!document.getElementById("ldap_anon").checked) {
377
		if (document.getElementById("ldap_binddn").value == '' ||
378
		    document.getElementById("ldap_bindpw").value == '') {
379 257705ca Renato Botelho
				alert("<?=gettext("Please fill the bind username/password.");?>");
380 7a938f1b Ermal
			return;
381
		}
382
	}
383 6306b5dd Ermal Lu?i
        var url = 'system_usermanager_settings_ldapacpicker.php?';
384
        url += 'port=' + document.getElementById("ldap_port").value;
385
        url += '&host=' + document.getElementById("ldap_host").value;
386
        url += '&scope=' + document.getElementById("ldap_scope").value;
387
        url += '&basedn=' + document.getElementById("ldap_basedn").value;
388
        url += '&binddn=' + document.getElementById("ldap_binddn").value;
389
        url += '&bindpw=' + document.getElementById("ldap_bindpw").value;
390
        url += '&urltype=' + document.getElementById("ldap_urltype").value;
391
        url += '&proto=' + document.getElementById("ldap_protver").value;
392
	url += '&authcn=' + document.getElementById("ldapauthcontainers").value;
393
394
        var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
395
        if (oWin==null || typeof(oWin)=="undefined")
396 257705ca Renato Botelho
			alert("<?=gettext('Popup blocker detected.  Action aborted.');?>");
397 6306b5dd Ermal Lu?i
}
398 fbf672cb Matthew Grooms
//-->
399
</script>
400
<?php
401
	if ($input_errors)
402
		print_input_errors($input_errors);
403
	if ($savemsg)
404
		print_info_box($savemsg);
405
?>
406
<table width="100%" border="0" cellpadding="0" cellspacing="0">
407
	<tr>
408 e30001cf Matthew Grooms
		<td>
409 fbf672cb Matthew Grooms
		<?php
410
			$tab_array = array();
411
			$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
412
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
413
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
414 d799787e Matthew Grooms
			$tab_array[] = array(gettext("Servers"), true, "system_authservers.php");
415 fbf672cb Matthew Grooms
			display_top_tabs($tab_array);
416
		?>
417
		</td>
418
	</tr>
419
	<tr>
420 e30001cf Matthew Grooms
		<td id="mainarea">
421
			<div class="tabcont">
422
423
				<?php if ($act == "new" || $act == "edit" || $input_errors): ?>
424
425
				<form action="system_authservers.php" method="post" name="iform" id="iform">
426
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
427
						<tr>
428
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
429
							<td width="78%" class="vtable">
430 3de94477 Ermal Lu?i
							<?php if (!isset($id)): ?>
431 e30001cf Matthew Grooms
								<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
432 3de94477 Ermal Lu?i
							<?php else: ?>
433
                                                                <strong><?=$pconfig[name];?></strong>
434
                                                                <input name='name' type='hidden' id='name' value="<?=htmlspecialchars($pconfig['name']);?>"/>
435
                                                                <?php endif; ?>
436 e30001cf Matthew Grooms
							</td>
437
						</tr>
438
						<tr>
439
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Type");?></td>
440
							<td width="78%" class="vtable">
441
								<?php if (!isset($id)): ?>
442
								<select name='type' id='type' class="formselect" onchange='server_typechange()'>
443
								<?php
444
									foreach ($auth_server_types as $typename => $typedesc ):
445
										$selected = "";
446
										if ($pconfig['type'] == $typename)
447
											$selected = "selected";
448
								?>
449
									<option value="<?=$typename;?>" <?=$selected;?>><?=$typedesc;?></option>
450
								<?php endforeach; ?>
451
								</select>
452
								<?php else: ?>
453
								<strong><?=$auth_server_types[$pconfig['type']];?></strong>
454
								<input name='type' type='hidden' id='type' value="<?=htmlspecialchars($pconfig['type']);?>"/>
455
								<?php endif; ?>
456
							</td>
457
						</tr>
458
					</table>
459
460 be934aad Ermal Lu?i
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="ldap" style="display:none">
461 e30001cf Matthew Grooms
						<tr>
462
							<td colspan="2" class="list" height="12"></td>
463
						</tr>
464
						<tr>
465 257705ca Renato Botelho
							<td colspan="2" valign="top" class="listtopic"><?=gettext("LDAP Server Settings");?></td>
466 e30001cf Matthew Grooms
						</tr>
467
						<tr>
468
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP address");?></td>
469
							<td width="78%" class="vtable">
470
								<input name="ldap_host" type="text" class="formfld unknown" id="ldap_host" size="20" value="<?=htmlspecialchars($pconfig['ldap_host']);?>"/>
471
							</td>
472
						</tr>
473
						<tr>
474
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Port value");?></td>
475
							<td width="78%" class="vtable">
476
								<input name="ldap_port" type="text" class="formfld unknown" id="ldap_port" size="5" value="<?=htmlspecialchars($pconfig['ldap_port']);?>"/>
477
							</td>
478
						</tr>
479
						<tr>
480
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Transport");?></td>
481
							<td width="78%" class="vtable">
482
								<select name='ldap_urltype' id='ldap_urltype' class="formselect" onchange='ldap_urlchange()'>
483
								<?php
484
									foreach ($ldap_urltypes as $urltype => $urlport):
485
										$selected = "";
486
										if ($pconfig['ldap_urltype'] == $urltype)
487
											$selected = "selected";
488
								?>
489
									<option value="<?=$urltype;?>" <?=$selected;?>><?=$urltype;?></option>
490
								<?php endforeach; ?>
491
								</select>
492
							</td>
493
						</tr>
494
						<tr>
495
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Protocol version");?></td>
496
							<td width="78%" class="vtable">
497
								<select name='ldap_protver' id='ldap_protver' class="formselect">
498
								<?php
499
									foreach ($ldap_protvers as $version):
500
										$selected = "";
501
										if ($pconfig['ldap_protver'] == $version)
502
											$selected = "selected";
503
								?>
504
									<option value="<?=$version;?>" <?=$selected;?>><?=$version;?></option>
505
								<?php endforeach; ?>
506
								</select>
507
							</td>
508
						</tr>
509
						<tr>
510
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Search scope");?></td>
511
							<td width="78%" class="vtable">
512
								<table border="0" cellspacing="0" cellpadding="2">
513
									<tr>
514 ea53e38f Renato Botelho
										<td><?=gettext("Level:");?> &nbsp;</td>
515 e30001cf Matthew Grooms
										<td>
516
											<select name='ldap_scope' id='ldap_scope' class="formselect">
517
											<?php
518
												foreach ($ldap_scopes as $scopename => $scopedesc):
519
													$selected = "";
520
													if ($pconfig['ldap_scope'] == $scopename)
521
														$selected = "selected";
522
											?>
523
												<option value="<?=$scopename;?>" <?=$selected;?>><?=$scopedesc;?></option>
524
											<?php endforeach; ?>
525
											</select>
526
										</td>
527
									</tr>
528
									<tr>
529 ea53e38f Renato Botelho
										<td><?=gettext("Base DN:");?> &nbsp;</td>
530 e30001cf Matthew Grooms
										<td>
531
											<input name="ldap_basedn" type="text" class="formfld unknown" id="ldap_basedn" size="40" value="<?=htmlspecialchars($pconfig['ldap_basedn']);?>"/>
532
										</td>
533
									</tr>
534
								</table>
535
536
							</td>
537
						</tr>
538 c61e4626 Ermal Lu?i
						<tr>
539 6d78607d Renato Botelho
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication containers");?></td>
540
							<td width="78%" class="vtable">
541
								<table border="0" cellspacing="0" cellpadding="2">
542
									<tr>
543 ea53e38f Renato Botelho
										<td><?=gettext("Containers:");?> &nbsp;</td>
544 6d78607d Renato Botelho
										<td>
545
											<input name="ldapauthcontainers" type="text" class="formfld unknown" id="ldapauthcontainers" size="40" value="<?=htmlspecialchars($pconfig['ldap_authcn']);?>"/>
546 257705ca Renato Botelho
											<input type="button" onClick="select_clicked();" value="<?=gettext("Select");?>">
547
											<br /><?=gettext("NOTE: Semi-Colon separated. This will be prepended to the search base dn above or you can specify full container path.");?>
548
											<br /><?=gettext("EXAMPLE: CN=Users;DC=example");?>
549
											<br /><?=gettext("EXAMPLE: CN=Users,DC=example,DC=com;OU=OtherUsers,DC=example,DC=com ");?>
550 6d78607d Renato Botelho
										</td>
551
									</tr>
552
								</table>
553
							</td>
554
						</tr>
555 e30001cf Matthew Grooms
						<tr>
556
							<td width="22%" valign="top" class="vncell"><?=gettext("Bind credentials");?></td>
557
							<td width="78%" class="vtable">
558
								<table border="0" cellspacing="0" cellpadding="2">
559
									<tr>
560
										<td>
561
											<input name="ldap_anon" type="checkbox" id="ldap_anon" value="yes" <?php if ($pconfig['ldap_anon']) echo "checked"; ?> onClick="ldap_bindchange()">
562
										</td>
563
										<td>
564 257705ca Renato Botelho
											<?=gettext("Use anonymous binds to resolve distinguished names");?>
565 e30001cf Matthew Grooms
										</td>
566
									</tr>
567
								</table>
568
								<table border="0" cellspacing="0" cellpadding="2" id="ldap_bind">
569
									<tr>
570
										<td colspan="2"></td>
571
									</tr>
572
									<tr>
573 ea53e38f Renato Botelho
										<td><?=gettext("User DN:");?> &nbsp;</td>
574 e30001cf Matthew Grooms
										<td>
575
											<input name="ldap_binddn" type="text" class="formfld unknown" id="ldap_binddn" size="40" value="<?=htmlspecialchars($pconfig['ldap_binddn']);?>"/><br/>
576
										</td>
577
									</tr>
578
									<tr>
579 ea53e38f Renato Botelho
										<td><?=gettext("Password:");?> &nbsp;</td>
580 e30001cf Matthew Grooms
										<td>
581
											<input name="ldap_bindpw" type="password" class="formfld pwd" id="ldap_bindpw" size="20" value="<?=htmlspecialchars($pconfig['ldap_bindpw']);?>"/><br/>
582
										</td>
583
									</tr>
584
								</table>
585
							</td>
586
						</tr>
587
						<?php if (!isset($id)): ?>
588
						<tr>
589
							<td width="22%" valign="top" class="vncell"><?=gettext("Initial Template");?></td>
590
							<td width="78%" class="vtable">
591
								<select name='ldap_tmpltype' id='ldap_tmpltype' class="formselect" onchange='ldap_tmplchange()'>
592
								<?php
593
									foreach ($ldap_templates as $tmplname => $tmpldata):
594
										$selected = "";
595
										if ($pconfig['ldap_template'] == $tmplname)
596
											$selected = "selected";
597
								?>
598
									<option value="<?=$tmplname;?>" <?=$selected;?>><?=$tmpldata['desc'];?></option>
599
								<?php endforeach; ?>
600
								</select>
601
							</td>
602
						</tr>
603
						<?php endif; ?>
604
						<tr>
605
							<td width="22%" valign="top" class="vncell"><?=gettext("User naming attribute");?></td>
606
							<td width="78%" class="vtable">
607
								<input name="ldap_attr_user" type="text" class="formfld unknown" id="ldap_attr_user" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_user']);?>"/>
608
							</td>
609
						</tr>
610
						<tr>
611
							<td width="22%" valign="top" class="vncell"><?=gettext("Group naming attribute");?></td>
612
							<td width="78%" class="vtable">
613
								<input name="ldap_attr_group" type="text" class="formfld unknown" id="ldap_attr_group" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_group']);?>"/>
614
							</td>
615
						</tr>
616
						<tr>
617
							<td width="22%" valign="top" class="vncell"><?=gettext("Group member attribute");?></td>
618
							<td width="78%" class="vtable">
619
								<input name="ldap_attr_member" type="text" class="formfld unknown" id="ldap_attr_member" size="20" value="<?=htmlspecialchars($pconfig['ldap_attr_member']);?>"/>
620
							</td>
621
						</tr>
622
					</table>
623
624 be934aad Ermal Lu?i
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="radius" style="display:none">
625 e30001cf Matthew Grooms
						<tr>
626
							<td colspan="2" class="list" height="12"></td>
627
						</tr>
628
						<tr>
629 257705ca Renato Botelho
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Radius Server Settings");?></td>
630 e30001cf Matthew Grooms
						</tr>
631
						<tr>
632
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Hostname or IP address");?></td>
633
							<td width="78%" class="vtable">
634
								<input name="radius_host" type="text" class="formfld unknown" id="radius_host" size="20" value="<?=htmlspecialchars($pconfig['radius_host']);?>"/>
635
							</td>
636
						</tr>
637
						<tr>
638
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Shared Secret");?></td>
639
							<td width="78%" class="vtable">
640
								<input name="radius_secret" type="password" class="formfld pwd" id="radius_secret" size="20" value="<?=htmlspecialchars($pconfig['radius_secret']);?>"/>
641
							</td>
642
						</tr>
643
						<tr>
644
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Services offered");?></td>
645
							<td width="78%" class="vtable">
646
								<select name='radius_srvcs' id='radius_srvcs' class="formselect" onchange='radius_srvcschange()'>
647
								<?php
648
									foreach ($radius_srvcs as $srvcname => $srvcdesc):
649
										$selected = "";
650
										if ($pconfig['radius_srvcs'] == $srvcname)
651
											$selected = "selected";
652
								?>
653
									<option value="<?=$srvcname;?>" <?=$selected;?>><?=$srvcdesc;?></option>
654
								<?php endforeach; ?>
655
								</select>
656
							</td>
657
						</tr>
658
						<tr id="radius_auth">
659
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Authentication port value");?></td>
660
							<td width="78%" class="vtable">
661
								<input name="radius_auth_port" type="text" class="formfld unknown" id="radius_auth_port" size="5" value="<?=htmlspecialchars($pconfig['radius_auth_port']);?>"/>
662
							</td>
663
						</tr>
664
						<tr id="radius_acct">
665
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Accounting port value");?></td>
666
							<td width="78%" class="vtable">
667
								<input name="radius_acct_port" type="text" class="formfld unknown" id="radius_acct_port" size="5" value="<?=htmlspecialchars($pconfig['radius_acct_port']);?>"/>
668
							</td>
669
						</tr>
670
					</table>
671
672
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
673
						<tr>
674
							<td width="22%" valign="top">&nbsp;</td>
675
							<td width="78%">
676 257705ca Renato Botelho
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
677 e30001cf Matthew Grooms
								<?php if (isset($id) && $a_server[$id]): ?>
678
								<input name="id" type="hidden" value="<?=$id;?>" />
679
								<?php endif;?>
680
							</td>
681
						</tr>
682
					</table>
683
				</form>
684
685
				<?php else: ?>
686
687
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
688 fbf672cb Matthew Grooms
					<tr>
689 257705ca Renato Botelho
						<td width="25%" class="listhdrr"><?=gettext("Server Name");?></td>
690
						<td width="25%" class="listhdrr"><?=gettext("Type");?></td>
691
						<td width="35%" class="listhdrr"><?=gettext("Host Name");?></td>
692 e30001cf Matthew Grooms
						<td width="10%" class="list"></td>
693 fbf672cb Matthew Grooms
					</tr>
694 e30001cf Matthew Grooms
					<?php
695
						$i = 0;
696
						foreach($a_server as $server):
697
							$name = htmlspecialchars($server['name']);
698
							$type = htmlspecialchars($auth_server_types[$server['type']]);
699
							$host = htmlspecialchars($server['host']);
700
					?>
701 6306b5dd Ermal Lu?i
					<tr <?php if ($i < (count($a_server) - 1)): ?> ondblclick="document.location='system_authservers.php?act=edit&id=<?=$i;?>'" <?php endif; ?>>
702 e30001cf Matthew Grooms
						<td class="listlr"><?=$name?>&nbsp;</td>
703
						<td class="listr"><?=$type;?>&nbsp;</td>
704
						<td class="listr"><?=$host;?>&nbsp;</td>
705
						<td valign="middle" nowrap class="list">
706 6306b5dd Ermal Lu?i
						<?php if ($i < (count($a_server) - 1)): ?>
707 e30001cf Matthew Grooms
							<a href="system_authservers.php?act=edit&id=<?=$i;?>">
708 257705ca Renato Botelho
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit server");?>" alt="<?=gettext("edit server");?>" width="17" height="17" border="0" />
709 e30001cf Matthew Grooms
							</a>
710
							&nbsp;
711
							<a href="system_authservers.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Server?");?>')">
712 257705ca Renato Botelho
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete server");?>" alt="<?=gettext("delete server");?>" width="17" height="17" border="0" />
713 e30001cf Matthew Grooms
							</a>
714 6306b5dd Ermal Lu?i
						<?php endif; ?>
715 fbf672cb Matthew Grooms
						</td>
716
					</tr>
717 e30001cf Matthew Grooms
					<?php
718 6306b5dd Ermal Lu?i
						$i++; endforeach;
719 e30001cf Matthew Grooms
					?>
720 fbf672cb Matthew Grooms
					<tr>
721 e30001cf Matthew Grooms
						<td class="list" colspan="3"></td>
722
						<td class="list">
723
							<a href="system_authservers.php?act=new">
724 257705ca Renato Botelho
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add server");?>" alt="<?=gettext("add server");?>" width="17" height="17" border="0" />
725 e30001cf Matthew Grooms
							</a>
726 fbf672cb Matthew Grooms
						</td>
727
					</tr>
728
					<tr>
729 e30001cf Matthew Grooms
						<td colspan="3">
730
							<p>
731
								<?=gettext("Additional authentication servers can be added here.");?>
732
							</p>
733 fbf672cb Matthew Grooms
						</td>
734
					</tr>
735
				</table>
736
737 e30001cf Matthew Grooms
				<?php endif; ?>
738 fbf672cb Matthew Grooms
739 e30001cf Matthew Grooms
			</div>
740 fbf672cb Matthew Grooms
		</td>
741
	</tr>
742
</table>
743 be934aad Ermal Lu?i
<?php include("fend.inc"); ?>
744 fbf672cb Matthew Grooms
<script type="text/javascript">
745
<!--
746
server_typechange('<?=$pconfig['type'];?>');
747
<?php if (!isset($id) || $pconfig['type'] == "ldap"): ?>
748
ldap_bindchange();
749
ldap_urlchange();
750 6306b5dd Ermal Lu?i
<?php if (!isset($id)): ?>
751 fbf672cb Matthew Grooms
ldap_tmplchange();
752 ee9933b6 Renato Botelho
<?php endif; ?>
753
<?php endif; ?>
754 fbf672cb Matthew Grooms
<?php if (!isset($id) || $pconfig['type'] == "radius"): ?>
755
radius_srvcschange();
756 ee9933b6 Renato Botelho
<?php endif; ?>
757 fbf672cb Matthew Grooms
//-->
758
</script>
759
</body>