]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: reset resource on failed bind
authorArthur Schiwon <blizzz@owncloud.com>
Mon, 2 Jul 2012 12:03:16 +0000 (14:03 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Mon, 2 Jul 2012 12:03:29 +0000 (14:03 +0200)
check for resource

apps/user_ldap/lib_ldap.php

index 21c4e57e2933eacbbd2763a6c6995989b09fddcd..152977ff7f76f2509bacc431b491ebef52195435 100644 (file)
@@ -474,17 +474,16 @@ class OC_LDAP {
 
                // See if we have a resource
                $link_resource = self::getConnectionResource();
-               if($link_resource)
-               {
+               if(is_resource($link_resource)) {
                        $sr = ldap_search($link_resource, $base, $filter, $attr);
                        $findings = ldap_get_entries($link_resource, $sr );
+
                        // if we're here, probably no connection resource is returned.
                        // to make ownCloud behave nicely, we simply give back an empty array.
                        if(is_null($findings)) {
                                return array();
                        }
-               } else
-               {
+               } else {
                        // Seems like we didn't find any resource.
                        // Return an empty array just like before.
                        return array();
@@ -690,6 +689,7 @@ class OC_LDAP {
                        $ldapLogin = @ldap_bind(self::$ldapConnectionRes, self::$ldapAgentName, self::$ldapAgentPassword );
                        if(!$ldapLogin) {
                                OCP\Util::writeLog('ldap', 'Bind failed: ' . ldap_errno(self::$ldapConnectionRes) . ': ' . ldap_error(self::$ldapConnectionRes), OCP\Util::ERROR);
+                               self::$ldapConnectionRes = null;
                                return false;
                        }
                }