From 073115bc29529db2bb9b407f861861d3debe64a4 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Mon, 31 Dec 2007 03:13:31 +0000 Subject: [PATCH] Adding LDAP Authentication container picker. Work sponsored-by: Centipede Networks --- etc/inc/auth.inc | 2 + usr/local/www/system_usermanager_settings.php | 13 ++- ...stem_usermanager_settings_ldapacpicker.php | 85 +++++++++++++++++++ .../www/system_usermanager_settings_test.php | 2 +- 4 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 usr/local/www/system_usermanager_settings_ldapacpicker.php diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index bf2785907d..55759e87cf 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -743,6 +743,8 @@ function ldap_get_groups($username) { $info = ldap_get_entries($ldap, $search); + $memberof = array(); + if(is_array($info[0]['memberof'])) { foreach($info[0]['memberof'] as $member) { if(strstr($member, "CN=") !== false) { diff --git a/usr/local/www/system_usermanager_settings.php b/usr/local/www/system_usermanager_settings.php index 8255b5df0d..a4f7a8eae8 100755 --- a/usr/local/www/system_usermanager_settings.php +++ b/usr/local/www/system_usermanager_settings.php @@ -212,7 +212,8 @@ if(!$pconfig['backend']) LDAP Authentication containers - + + Select
NOTE: Comma separated.
EXAMPLE: CN=Users,DC=pfsense,DC=com;CN=OtherUsers,DC=pfsense,DC=com @@ -233,3 +234,13 @@ if(!$pconfig['backend']) + diff --git a/usr/local/www/system_usermanager_settings_ldapacpicker.php b/usr/local/www/system_usermanager_settings_ldapacpicker.php new file mode 100644 index 0000000000..783f836320 --- /dev/null +++ b/usr/local/www/system_usermanager_settings_ldapacpicker.php @@ -0,0 +1,85 @@ + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require("guiconfig.inc"); + +if($_POST) { + print_r($_POST); + $ous = ldap_get_user_ous(true); + $values = ""; + $isfirst = true; + foreach($ous as $ou) { + if(in_array($ou, $_POST['ou'])) { + if($isfirst == false) + $values .= ";"; + $isfirst = false; + $values .= $ou; + } + } + echo "\n"; +} + +?> + + + "> +
+ Please select which containers to Authenticate against: +

+ + + + +
+ {$ou}
\n"; + } +?> +
+ +

+ + + + + + diff --git a/usr/local/www/system_usermanager_settings_test.php b/usr/local/www/system_usermanager_settings_test.php index 4e32f2d3fa..796f642959 100755 --- a/usr/local/www/system_usermanager_settings_test.php +++ b/usr/local/www/system_usermanager_settings_test.php @@ -33,8 +33,8 @@ require("guiconfig.inc"); $ldapserver = $config['system']['webgui']['ldapserver']; $ldapbindun = $config['system']['webgui']['ldapbindun']; $ldapbindpw = $config['system']['webgui']['ldapbindpw']; - $ldapfilter = $config['system']['webgui']['ldapfilter']; + ?>