Project

General

Profile

Download (15.3 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
##|+PRIV
35
##|*IDENT=page-system-usermanager-settings
36
##|*NAME=System: User manager: settings page
37
##|*DESCR=Allow access to the 'System: User manager: settings' page.
38
##|*MATCH=system_usermanager_settings.php*
39
##|-PRIV
40

    
41
if($_POST['savetest'])
42
	$save_and_test = true;
43

    
44
require("guiconfig.inc");
45

    
46
$pconfig['session_timeout'] = &$config['system']['webgui']['session_timeout'];
47
$pconfig['ldapserver'] = &$config['system']['webgui']['ldapserver'];
48
$pconfig['backend'] = &$config['system']['webgui']['backend'];
49
$pconfig['ldapbindun'] = &$config['system']['webgui']['ldapbindun'];
50
$pconfig['ldapbindpw'] = &$config['system']['webgui']['ldapbindpw'];
51
$pconfig['ldapfilter'] = &$config['system']['webgui']['ldapfilter'];
52
$pconfig['ldapsearchbase'] = &$config['system']['webgui']['ldapsearchbase'];
53
$pconfig['ldapauthcontainers'] = &$config['system']['webgui']['ldapauthcontainers'];
54
$pconfig['ldapgroupattribute'] = &$config['system']['webgui']['ldapgroupattribute'];
55
$pconfig['ldapnameattribute'] = &$config['system']['webgui']['ldapnameattribute'];
56

    
57
// Page title for main admin
58
$pgtitle = array("System","User manager settings");
59

    
60
if ($_POST) {
61
	unset($input_errors);
62

    
63
	conf_mount_rw();
64

    
65
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
66

    
67
	if($_POST['session_timeout']) {
68
		$timeout = intval($_POST['session_timeout']);
69
		if ($timeout != "" && !is_numeric($timeout))
70
			$input_errors[] = gettext("Session timeout must be an integer with value 1 or greater.");
71

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

    
75
		if ($timeout > 999)
76
			$input_errors[] = gettext("Session timeout must be an integer with value 1 or greater.");
77
	}
78

    
79
	if (!$input_errors) {
80

    
81
		if($_POST['session_timeout'] && $_POST['session_timeout'] != "0")
82
			$pconfig['session_timeout'] = intval($_POST['session_timeout']);
83
		else
84
			unset($config['system']['webgui']['session_timeout']);
85

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

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

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

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

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

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

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

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

    
130
		write_config();
131

    
132
	}
133

    
134
	conf_mount_ro();
135

    
136
}
137

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

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

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

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

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

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

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

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