diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2012-05-01 12:17:33 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2012-05-01 12:17:33 +0200 |
commit | 54854b2e3dcd036ba6a9b22a3ebccde7f287b01c (patch) | |
tree | c54e817ea53db4d42869ed00c85ee137a4d8b6b1 | |
parent | 11314c81d9a3977364058957d03a6126262b1bd9 (diff) | |
download | nextcloud-server-54854b2e3dcd036ba6a9b22a3ebccde7f287b01c.tar.gz nextcloud-server-54854b2e3dcd036ba6a9b22a3ebccde7f287b01c.zip |
LDAP: decent behaviour and log message when there is no connection to the LDAP server
-rw-r--r-- | apps/user_ldap/lib_ldap.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index 4efcf0c5a0d..55ef44c5d9a 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -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; } |