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
	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

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

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

    
63
if ($_POST) {
64
	unset($input_errors);
65

    
66
	conf_mount_rw();
67

    
68
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
69

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

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

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

    
82
	if (!$input_errors) {
83

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

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

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

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

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

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

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

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

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

    
133
		write_config();
134

    
135
	}
136

    
137
	conf_mount_ro();
138

    
139
}
140

    
141
include("head.inc");
142
?>
143

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

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

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

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

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

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

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