Project

General

Profile

Download (15.4 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    part of pfSense (http://www.pfsense.org/)
5

    
6
	Copyright (C) 2007 Scott Ullrich <sullrich@gmail.com>
7
	All rights reserved.
8

    
9
    Copyright (C) 2007 Bill Marquette <bill.marquette@gmail.com>
10
    All rights reserved.
11

    
12
    Redistribution and use in source and binary forms, with or without
13
    modification, are permitted provided that the following conditions are met:
14

    
15
    1. Redistributions of source code must retain the above copyright notice,
16
       this list of conditions and the following disclaimer.
17

    
18
    2. Redistributions in binary form must reproduce the above copyright
19
       notice, this list of conditions and the following disclaimer in the
20
       documentation and/or other materials provided with the distribution.
21

    
22
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
    POSSIBILITY OF SUCH DAMAGE.
32
*/
33
/*
34
	pfSense_MODULE:	auth
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-system-usermanager-settings
39
##|*NAME=System: User manager: settings page
40
##|*DESCR=Allow access to the 'System: User manager: settings' page.
41
##|*MATCH=system_usermanager_settings.php*
42
##|-PRIV
43

    
44
if($_POST['savetest'])
45
	$save_and_test = true;
46

    
47
require("guiconfig.inc");
48
require("priv.defs.inc");
49
require("priv.inc");
50

    
51
$pconfig['session_timeout'] = &$config['system']['webgui']['session_timeout'];
52
$pconfig['ldapserver'] = &$config['system']['webgui']['ldapserver'];
53
$pconfig['backend'] = &$config['system']['webgui']['backend'];
54
$pconfig['ldapbindun'] = &$config['system']['webgui']['ldapbindun'];
55
$pconfig['ldapbindpw'] = &$config['system']['webgui']['ldapbindpw'];
56
$pconfig['ldapfilter'] = &$config['system']['webgui']['ldapfilter'];
57
$pconfig['ldapsearchbase'] = &$config['system']['webgui']['ldapsearchbase'];
58
$pconfig['ldapauthcontainers'] = &$config['system']['webgui']['ldapauthcontainers'];
59
$pconfig['ldapgroupattribute'] = &$config['system']['webgui']['ldapgroupattribute'];
60
$pconfig['ldapnameattribute'] = &$config['system']['webgui']['ldapnameattribute'];
61

    
62
// Page title for main admin
63
$pgtitle = array("System","User manager settings");
64

    
65
if ($_POST) {
66
	unset($input_errors);
67

    
68
	conf_mount_rw();
69

    
70
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
71

    
72
	if($_POST['session_timeout']) {
73
		$timeout = intval($_POST['session_timeout']);
74
		if ($timeout != "" && !is_numeric($timeout))
75
			$input_errors[] = gettext("Session timeout must be an integer with value 1 or greater.");
76

    
77
		if ($timeout < 1)
78
			$input_errors[] = gettext("Session timeout must be an integer with value 1 or greater.");
79

    
80
		if ($timeout > 999)
81
			$input_errors[] = gettext("Session timeout must be an integer with value 1 or greater.");
82
	}
83

    
84
	if (!$input_errors) {
85

    
86
		if($_POST['session_timeout'] && $_POST['session_timeout'] != "0")
87
			$pconfig['session_timeout'] = intval($_POST['session_timeout']);
88
		else
89
			unset($config['system']['webgui']['session_timeout']);
90

    
91
		if($_POST['ldapserver'])
92
			$pconfig['ldapserver'] = $_POST['ldapserver'];
93
		else
94
			unset($pconfig['ldapserver']);
95

    
96
		if($_POST['backend'])
97
			$pconfig['backend'] = $_POST['backend'];
98
		else
99
			unset($pconfig['backend']);
100

    
101
		if($_POST['ldapbindun'])
102
			$pconfig['ldapbindun'] = $_POST['ldapbindun'];
103
		else
104
			unset($pconfig['ldapbindun']);
105

    
106
		if($_POST['ldapbindpw'])
107
			$pconfig['ldapbindpw'] = $_POST['ldapbindpw'];
108
		else
109
			unset($pconfig['ldapbindpw']);
110

    
111
		if($_POST['ldapfilter'])
112
			$pconfig['ldapfilter'] = $_POST['ldapfilter'];
113
		else
114
			unset($pconfig['ldapfilter']);
115

    
116
		if($_POST['ldapsearchbase'])
117
			$pconfig['ldapsearchbase'] = $_POST['ldapsearchbase'];
118
		else
119
			unset($pconfig['ldapsearchbase']);
120

    
121
		if($_POST['ldapauthcontainers'])
122
			$pconfig['ldapauthcontainers'] = $_POST['ldapauthcontainers'];
123
		else
124
			unset($pconfig['ldapauthcontainers']);
125

    
126
		if($_POST['ldapgroupattribute'])
127
			$pconfig['ldapgroupattribute'] = $_POST['ldapgroupattribute'];
128
		else
129
			unset($pconfig['ldapgroupattribute']);
130
		if($_POST['ldapnameattribute'])
131
			$pconfig['ldapnameattribute'] = $_POST['ldapnameattribute'];
132
		else
133
			unset($pconfig['ldapgroupattribute']);
134

    
135
		write_config();
136

    
137
	}
138

    
139
	conf_mount_ro();
140

    
141
}
142

    
143
include("head.inc");
144
?>
145

    
146
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
147
<?php include("fbegin.inc");?>
148
<?php if ($input_errors) print_input_errors($input_errors);?>
149
<?php if ($savemsg) print_info_box($savemsg);?>
150

    
151
<?php
152
	if($save_and_test) {
153
		echo "<script language='javascript'>\n";
154
		echo "myRef = window.open('system_usermanager_settings_test.php','mywin', ";
155
		echo "'left=20,top=20,width=700,height=550,toolbar=1,resizable=0');\n";
156
		echo "</script>\n";
157
	}
158
?>
159

    
160
<script language="javascript">
161
	function show_ldapfilter() {
162
		document.getElementById("filteradv").innerHTML='';
163
		aodiv = document.getElementById('filteradvdiv');
164
		aodiv.style.display = "block";		
165
	}
166
	function show_ldapnaming(){
167
		document.getElementById("namingattribute").innerHTML='';
168
		aodiv = document.getElementById('ldapnamingdiv');
169
		aodiv.style.display = "block";		
170
	}
171
	function show_groupmembership() {
172
		document.getElementById("groupmembership").innerHTML='';
173
		aodiv = document.getElementById('groupmembershipdiv');
174
		aodiv.style.display = "block";		
175
	}
176
	function ldap_typechange() {
177
        switch (document.iform.backend.selectedIndex) {
178
            case 0:
179
            	/* pfSense backend, disable all options */
180
                document.iform.ldapfilter.disabled = 1;
181
                document.iform.ldapnameattribute.disabled = 1;
182
                document.iform.ldapgroupattribute.disabled = 1;
183
                document.iform.ldapsearchbase.disabled = 1;
184
                document.iform.ldapauthcontainers.disabled = 1;
185
				document.iform.ldapserver.disabled = 1;
186
				document.iform.ldapbindun.disabled = 1;
187
				document.iform.ldapbindpw.disabled = 1;
188
				document.iform.ldapfilter.value = "";
189
				document.iform.ldapnameattribute.value = "";	
190
				document.iform.ldapgroupattribute.value = "";
191
				document.iform.ldapauthcontainers.value = "";
192
				break;
193
            case 1:
194
            	/* A/D */
195
                document.iform.ldapfilter.disabled = 0;
196
                document.iform.ldapnameattribute.disabled = 0;
197
                document.iform.ldapgroupattribute.disabled = 0;
198
                document.iform.ldapsearchbase.disabled = 0;
199
                document.iform.ldapauthcontainers.disabled = 0;
200
				document.iform.ldapserver.disabled = 0;
201
				document.iform.ldapbindun.disabled = 0;
202
				document.iform.ldapbindpw.disabled = 0;
203
				document.iform.ldapfilter.value = "(samaccountname=$username)";
204
				document.iform.ldapnameattribute.value = "samaccountname";	
205
				document.iform.ldapgroupattribute.value = "memberOf";
206
				break;							
207
            case 2:
208
            	/* eDir */
209
                document.iform.ldapfilter.disabled = 0;
210
                document.iform.ldapnameattribute.disabled = 0;
211
                document.iform.ldapgroupattribute.disabled = 0;
212
                document.iform.ldapsearchbase.disabled = 0;
213
                document.iform.ldapauthcontainers.disabled = 0;
214
				document.iform.ldapserver.disabled = 0;
215
				document.iform.ldapbindun.disabled = 0;
216
				document.iform.ldapbindpw.disabled = 0;
217
				document.iform.ldapfilter.value = "(cn=$username)";		
218
				document.iform.ldapnameattribute.value = "CN";
219
				document.iform.ldapgroupattribute.value = "groupMembership";
220
				break;				
221
		}
222
	}
223
</script>
224

    
225
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
226
    <tr>
227
      <td class="tabnavtbl">
228
<?php
229
    $tab_array = array();
230
    $tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
231
    $tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
232
    $tab_array[] = array(gettext("Settings"), true, "system_usermanager_settings.php");
233
	$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
234
    display_top_tabs($tab_array);
235

    
236
/* Default to pfsense backend type if none is defined */
237
if(!$pconfig['backend'])
238
	$pconfig['backend'] = "pfsense";
239

    
240
?>
241
      </td>
242
    <tr>
243
       <td>
244
            <div id="mainarea">
245
            <form id="iform" name="iform" action="system_usermanager_settings.php" method="post">
246
              <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
247
					<tr>
248
                        <td width="22%" valign="top" class="vncell">Session Timeout</td>
249
                        <td width="78%" class="vtable">
250
							<input name="session_timeout" id="session_timeout" type="text" size="8" value="<?=htmlspecialchars($pconfig['session_timeout']);?>" />
251
                          <br />
252
                          <?=gettext("Time in minutes to expire idle management sessions.");?><br />
253
						</td>
254
                      </tr>
255
					<tr>
256
                        <td width="22%" valign="top" class="vncell">Authentication primary backend</td>
257
                        <td width="78%" class="vtable">
258
							<select name='backend' id='backend' onchange='ldap_typechange()'>
259
								<option value="pfsense"<?php if ($pconfig['backend'] == "pfsense") echo " SELECTED";?>>Local User Database</option>
260
								<option value="ldap"<?php if ($pconfig['backend'] == "ldap") echo " SELECTED";?>>LDAP (Active Directory)</option>
261
								<option value="ldapother"<?php if ($pconfig['backend'] == "ldapother") echo " SELECTED";?>>LDAP OTHER (eDir, etc)</option>
262
							</select>
263
							<br/>NOTE: login failures or server not available issues will fall back to pfSense internal users/group authentication.
264
						</td>
265
					</tr>
266
					<tr>
267
                        <td width="22%" valign="top" class="vncell">LDAP Server:port</td>
268
                        <td width="78%" class="vtable">
269
							<input name="ldapserver" id="ldapserver" size="65" value="<?=htmlspecialchars($pconfig['ldapserver']);?>">
270
							<br/>Example: ldaps://ldap.example.org:389 or ldap://ldap.example.org:389
271
						</td>
272
					</tr>
273
					<tr>
274
                        <td width="22%" valign="top" class="vncell">LDAP Binding username</td>
275
                        <td width="78%" class="vtable">
276
							<input name="ldapbindun" id="ldapbindun" size="65" value="<?=htmlspecialchars($pconfig['ldapbindun']);?>">
277
							<br/>This account must have read access to the user objects and be able to retrieve groups.
278
							<br/>Example: For Active Directory you would want to use format DOMAIN\username or username@domain.
279
							<br/>Example: eDirectory you would want to use format cn=username,ou=orgunit,o=org.
280
						</td>
281
					</tr>
282
					<tr>
283
                        <td width="22%" valign="top" class="vncell">LDAP Binding password</td>
284
                        <td width="78%" class="vtable">
285
							<input name="ldapbindpw" id="ldapbindpw" type="password" size="65" value="<?=htmlspecialchars($pconfig['ldapbindpw']);?>">
286
						</td>
287
					</tr>
288
					<tr>
289
                        <td width="22%" valign="top" class="vncell">LDAP Filter</td>
290
                        <td width="78%" class="vtable">
291
							<div id="filteradv" name="filteradv">
292
								<input type="button" onClick="show_ldapfilter();" value="Advanced"> - Show advanced options
293
							</div>
294
							<div id="filteradvdiv" name="filteradvdiv" style="display:none">	
295
								<input name="ldapfilter" id="ldapfilter" size="65" value="<?=htmlspecialchars($pconfig['ldapfilter']);?>">
296
								<br/>Example: For Active Directory you would want to use (samaccountname=$username)
297
								<br/>Example: For eDirectory you would want to use (cn=$username)
298
							</div>
299
						</td>
300
					</tr>
301
					<tr>
302
                        <td width="22%" valign="top" class="vncell">LDAP Naming Attribute</td>
303
                        <td width="78%" class="vtable">
304
							<div id="namingattribute" name="namingattribute">
305
								<input type="button" onClick="show_ldapnaming();" value="Advanced"> - Show advanced options
306
							</div>
307
							<div id="ldapnamingdiv" name="ldapnamingdiv" style="display:none">	
308
								<input name="ldapnameattribute" id="ldapnameattribute" size="65" value="<?=htmlspecialchars($pconfig['ldapnameattribute']);?>">
309
								<br/>Example: For Active Directory you would want to use samaccountname.
310
								<br/>Example: For eDirectory you would want to use CN.
311
							</div>
312
						</td>
313
					</tr>
314
					<tr>
315
                        <td width="22%" valign="top" class="vncell">Group Membership Attribute Name</td>
316
                        <td width="78%" class="vtable">
317
							<div id="groupmembership" name="groupmembership">
318
								<input type="button" onClick="show_groupmembership();" value="Advanced"> - Show advanced options
319
							</div>
320
							<div id="groupmembershipdiv" name="groupmembershipdiv" style="display:none">
321
								<input name="ldapgroupattribute" id="ldapgroupattribute" size="65" value="<?=htmlspecialchars($pconfig['ldapgroupattribute']);?>">
322
								<br/>Example: For Active Directory you would want to use memberOf.
323
								<br/>Example: For eDirectory you would want to use groupMembership.
324
							</div>
325
						</td>
326
					</tr>
327

    
328
					<tr>
329
                        <td width="22%" valign="top" class="vncell">LDAP Search base</td>
330
                        <td width="78%" class="vtable">
331
							<input name="ldapsearchbase" size="65" value="<?=htmlspecialchars($pconfig['ldapsearchbase']);?>">
332
							<br/>Example: DC=example,DC=com
333
						</td>
334
					</tr>
335
					<tr>
336
                        <td width="22%" valign="top" class="vncell">LDAP Authentication container</td>
337
                        <td width="78%" class="vtable">
338
							<input name="ldapauthcontainers" id="ldapauthcontainers" size="65" value="<?=htmlspecialchars($pconfig['ldapauthcontainers']);?>">
339
							<input type="button" onClick="javascript:if(openwindow('system_usermanager_settings_ldapacpicker.php') == false) alert('Popup blocker detected.  Action aborted.');" value="Select"> 
340
							<br/>NOTE: Semi-Colon separated.
341
							<br/>EXAMPLE: CN=Users,DC=example,DC=com;CN=OtherUsers,DC=example,DC=com
342
						</td>
343
					</tr>
344
                	<tr>
345
                  		<td width="22%" valign="top">&nbsp;</td>
346
                  		<td width="78%">
347
							<input id="submit" name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
348
	     					<input id="savetest" name="savetest" type="submit" class="formbtn" value="<?=gettext("Save and Test");?>" />
349
						</td>
350
                	</tr>
351
              </table>
352
            </form>
353
            </div>
354
      </td>
355
    </tr>
356
  </table>
357
<?php include("fend.inc");?>
358
</body>
359
</html>
360
<script language="javascript">
361
	function openwindow(url) {
362
	        var oWin = window.open(url,"pfSensePop","width=620,height=400,top=150,left=150");
363
	        if (oWin==null || typeof(oWin)=="undefined") {
364
	                return false;
365
	        } else {
366
	                return true;
367
	        }
368
	}
369
</script>
(192-192/215)