summaryrefslogtreecommitdiffstats
path: root/etc/inc/auth.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2007-12-30 23:18:36 +0000
committerScott Ullrich <sullrich@pfsense.org>2007-12-30 23:18:36 +0000
commit4848bc7529bc24da71d914256d50b04748d77b13 (patch)
treec71b18f101f7533bd63ef642f690fdb1496f7655 /etc/inc/auth.inc
parentffe2f910c4e3fb005e91f4f04357b68ecae8acc9 (diff)
downloadpfsense-4848bc7529bc24da71d914256d50b04748d77b13.zip
pfsense-4848bc7529bc24da71d914256d50b04748d77b13.tar.gz
Add LDAP test functions to verify that the LDAP settings are correct.
Return the OU's and show to the user after test completion.
Diffstat (limited to 'etc/inc/auth.inc')
-rw-r--r--etc/inc/auth.inc46
1 files changed, 43 insertions, 3 deletions
diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc
index 73c9a71..67b1566 100644
--- a/etc/inc/auth.inc
+++ b/etc/inc/auth.inc
@@ -608,7 +608,42 @@ function passwd_backed($username, $passwd) {
return false;
}
-function ldap_get_user_ous() {
+function ldap_test_connection() {
+ global $config, $g;
+
+ $ldapserver = $config['system']['webgui']['ldapserver'];
+ $ldapbindun = $config['system']['webgui']['ldapbindun'];
+ $ldapbindpw = $config['system']['webgui']['ldapbindpw'];
+
+ if (!($ldap = ldap_connect($ldapserver))) {
+ return false;
+ }
+
+ return true;
+}
+
+function ldap_test_bind() {
+ global $config, $g;
+
+ $ldapserver = $config['system']['webgui']['ldapserver'];
+ $ldapbindun = $config['system']['webgui']['ldapbindun'];
+ $ldapbindpw = $config['system']['webgui']['ldapbindpw'];
+
+ if (!($ldap = ldap_connect($ldapserver))) {
+ return false;
+ }
+
+ ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
+ ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
+
+ if (!($res = @ldap_bind($ldap, $ldapbindun, $ldapbindpw))) {
+ return false;
+ }
+
+ return true;
+}
+
+function ldap_get_user_ous($show_complete_ou=false) {
global $config, $g;
$ldapserver = $config['system']['webgui']['ldapserver'];
@@ -640,11 +675,16 @@ function ldap_get_user_ous() {
$ous = array();
foreach($info as $inf) {
+ if(!$show_complete_ou) {
$inf_split = split(",", $inf['dn']);
$ou = $inf_split[0];
$ou = str_replace("OU=","", $ou);
- if($ou)
- $ous[] = $ou;
+ } else {
+ if($inf)
+ $ou = $inf['dn'];
+ }
+ if($ou)
+ $ous[] = $ou;
}
return $ous;
OpenPOWER on IntegriCloud