Project

General

Profile

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

    
40

    
41

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

    
45
require("guiconfig.inc");
46

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

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

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

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

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

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

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

    
78
	if (!$input_errors) {
79

    
80
		if($_POST['session_timeout'] && $_POST['session_timeout'] != "0")
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

    
134
include("head.inc");
135
?>
136

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

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

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

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

    
227
/* Default to pfsense backend type if none is defined */
228
if(!$pconfig['backend'])
229
	$pconfig['backend'] = "pfsense";
230

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

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

    
(187-187/210)