Project

General

Profile

Download (14.9 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 value.");
76
	}
77

    
78
	if (!$input_errors) {
79

    
80
		if($_POST['session_timeout'])
81
			$pconfig['session_timeout'] = intval($_POST['session_timeout']);
82
		else
83
			unset($config['system']['webgui']['session_timeout']);
84

    
85
		if($_POST['ldapserver'])
86
			$pconfig['ldapserver'] = $_POST['ldapserver'];
87
		else
88
			unset($pconfig['ldapserver']);
89

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

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

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

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

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

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

    
120
		if($_POST['ldapgroupattribute'])
121
			$pconfig['ldapgroupattribute'] = $_POST['ldapgroupattribute'];
122
		else
123
			unset($pconfig['ldapgroupattribute']);
124
		if($_POST['ldapnameattribute'])
125
			$pconfig['ldapnameattribute'] = $_POST['ldapnameattribute'];
126
		else
127
			unset($pconfig['ldapgroupattribute']);
128

    
129
		write_config();
130

    
131
	}
132

    
133
	conf_mount_ro();
134

    
135
}
136

    
137
include("head.inc");
138
?>
139

    
140
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
141
<?php include("fbegin.inc");?>
142
<?php if ($input_errors) print_input_errors($input_errors);?>
143
<?php if ($savemsg) print_info_box($savemsg);?>
144

    
145
<?php
146
	if($save_and_test) {
147
		echo "<script language='javascript'>\n";
148
		echo "myRef = window.open('system_usermanager_settings_test.php','mywin', ";
149
		echo "'left=20,top=20,width=700,height=550,toolbar=1,resizable=0');\n";
150
		echo "</script>\n";
151
	}
152
?>
153

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

    
219
  <table width="100%" border="0" cellpadding="0" cellspacing="0">
220
    <tr>
221
      <td class="tabnavtbl">
222
<?php
223
    $tab_array = array();
224
    $tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
225
    $tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
226
    $tab_array[] = array(gettext("Settings"), true, "system_usermanager_settings.php");
227
	$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
228
    display_top_tabs($tab_array);
229

    
230
/* Default to pfsense backend type if none is defined */
231
if(!$pconfig['backend'])
232
	$pconfig['backend'] = "pfsense";
233

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

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