summaryrefslogtreecommitdiff
path: root/plugins/LdapAuthentication/LdapAuthenticationPlugin.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-22 08:53:50 -0800
committerEvan Prodromou <evan@status.net>2009-12-22 08:53:50 -0800
commita2cb0a033fa6777d824dc40e759294287bd83939 (patch)
tree96b6947fd9aa7a76c1888a127e21e34319334f9b /plugins/LdapAuthentication/LdapAuthenticationPlugin.php
parentf17016470170401e1ad1b869c740063a578cb4cd (diff)
parentc9c316db7f003e018202e6c9f39770c208aecc05 (diff)
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'plugins/LdapAuthentication/LdapAuthenticationPlugin.php')
-rw-r--r--plugins/LdapAuthentication/LdapAuthenticationPlugin.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/plugins/LdapAuthentication/LdapAuthenticationPlugin.php b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php
index 8caacff46..39967fe42 100644
--- a/plugins/LdapAuthentication/LdapAuthenticationPlugin.php
+++ b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php
@@ -67,6 +67,18 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
throw new Exception("if password_changeable is set, the password attribute and password_encoding must also be specified");
}
}
+
+ function onAutoload($cls)
+ {
+ switch ($cls)
+ {
+ case 'MemcacheSchemaCache':
+ require_once(INSTALLDIR.'/plugins/LdapAuthentication/MemcacheSchemaCache.php');
+ return false;
+ default:
+ return parent::onAutoload($cls);
+ }
+ }
//---interface implementation---//
@@ -174,6 +186,14 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
return false;
}
if($config == null) $this->default_ldap=$ldap;
+
+ $c = common_memcache();
+ if (!empty($c)) {
+ $cacheObj = new MemcacheSchemaCache(
+ array('c'=>$c,
+ 'cacheKey' => common_cache_key('ldap_schema:' . crc32(serialize($config)))));
+ $ldap->registerSchemaCache($cacheObj);
+ }
return $ldap;
}
@@ -192,20 +212,21 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
$options = array(
'attributes' => $attributes
);
- $search = $ldap->search(null,$filter,$options);
+ $search = $ldap->search($this->basedn, $filter, $options);
if (PEAR::isError($search)) {
common_log(LOG_WARNING, 'Error while getting DN for user: '.$search->getMessage());
return false;
}
- if($search->count()==0){
+ $searchcount = $search->count();
+ if($searchcount == 0) {
return false;
- }else if($search->count()==1){
+ }else if($searchcount == 1) {
$entry = $search->shiftEntry();
return $entry;
}else{
- common_log(LOG_WARNING, 'Found ' . $search->count() . ' ldap user with the username: ' . $username);
+ common_log(LOG_WARNING, 'Found ' . $searchcount . ' ldap user with the username: ' . $username);
return false;
}
}