]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: decent behaviour and log message when there is no connection to the LDAP server
authorArthur Schiwon <blizzz@owncloud.com>
Tue, 1 May 2012 10:17:33 +0000 (12:17 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Tue, 1 May 2012 10:17:33 +0000 (12:17 +0200)
apps/user_ldap/lib_ldap.php

index 4efcf0c5a0d332707480fc2128bb38bf3a255584..55ef44c5d9a91aad7bffc05f79fc6eb46445175a 100644 (file)
@@ -437,8 +437,14 @@ class OC_LDAP {
                if(!is_null($attr) && !is_array($attr)) {
                        $attr = array(strtolower($attr));
                }
-               $sr = ldap_search(self::getConnectionResource(), $base, $filter, $attr);
-               $findings = ldap_get_entries(self::getConnectionResource(), $sr );
+
+               $sr = @ldap_search(self::getConnectionResource(), $base, $filter, $attr);
+               $findings = @ldap_get_entries(self::getConnectionResource(), $sr );
+               // if we're here, probably no connection ressource is returned.
+               // to make ownCloud behave nicely, we simply give back an empty array.
+               if(is_null($findings)) {
+                       return array();
+               }
 
                if(!is_null($attr)) {
                        $selection = array();
@@ -522,6 +528,9 @@ class OC_LDAP {
                if(!self::$ldapConnectionRes) {
                        self::init();
                }
+               if(is_null(self::$ldapConnectionRes)) {
+                       OCP\Util::writeLog('ldap', 'Connection could not be established', OC_Log::INFO);
+               }
                return self::$ldapConnectionRes;
        }