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