From 6b538cd9b31ffa25d2046e16d47a0cde26d0398f Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 23 Mar 2010 21:50:31 -0400 Subject: Fix some regressions caused by refactor of LDAP plugin --- .../LdapAuthenticationPlugin.php | 2 +- plugins/LdapCommon/LdapCommon.php | 24 +++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/plugins/LdapAuthentication/LdapAuthenticationPlugin.php b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php index a55c45ff5..2e01738ec 100644 --- a/plugins/LdapAuthentication/LdapAuthenticationPlugin.php +++ b/plugins/LdapAuthentication/LdapAuthenticationPlugin.php @@ -118,7 +118,7 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin function suggestNicknameForUsername($username) { - $entry = $this->ldap_get_user($username, $this->attributes); + $entry = $this->ldapCommon->get_user($username, $this->attributes); if(!$entry){ //this really shouldn't happen $nickname = $username; diff --git a/plugins/LdapCommon/LdapCommon.php b/plugins/LdapCommon/LdapCommon.php index 39d872df5..e2ca569f3 100644 --- a/plugins/LdapCommon/LdapCommon.php +++ b/plugins/LdapCommon/LdapCommon.php @@ -47,7 +47,7 @@ class LdapCommon public $uniqueMember_attribute = null; public $attributes=array(); public $password_encoding=null; - + public function __construct($config) { Event::addHandler('Autoload',array($this,'onAutoload')); @@ -68,7 +68,7 @@ class LdapCommon } function onAutoload($cls) - { + { switch ($cls) { case 'MemcacheSchemaCache': @@ -77,6 +77,15 @@ class LdapCommon case 'Net_LDAP2': require_once 'Net/LDAP2.php'; return false; + case 'Net_LDAP2_Filter': + require_once 'Net/LDAP2/Filter.php'; + return false; + case 'Net_LDAP2_Filter': + require_once 'Net/LDAP2/Filter.php'; + return false; + case 'Net_LDAP2_Entry': + require_once 'Net/LDAP2/Entry.php'; + return false; } } @@ -97,8 +106,9 @@ class LdapCommon $config = $this->ldap_config; } $config_id = crc32(serialize($config)); - $ldap = self::$ldap_connections[$config_id]; - if(! isset($ldap)) { + if(array_key_exists($config_id,self::$ldap_connections)) { + $ldap = self::$ldap_connections[$config_id]; + } else { //cannot use Net_LDAP2::connect() as StatusNet uses //PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError'); //PEAR handling can be overridden on instance objects, so we do that. @@ -197,10 +207,10 @@ class LdapCommon return false; } } - + /** * get an LDAP entry for a user with a given username - * + * * @param string $username * $param array $attributes LDAP attributes to retrieve * @return string DN @@ -212,7 +222,7 @@ class LdapCommon 'attributes' => $attributes ); $search = $ldap->search(null,$filter,$options); - + if (PEAR::isError($search)) { common_log(LOG_WARNING, 'Error while getting DN for user: '.$search->getMessage()); return false; -- cgit v1.2.3-54-g00ecf