Project

General

Profile

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