diff options
author | Benjamin Diele <benjamin@diele.be> | 2012-05-28 17:54:38 +0400 |
---|---|---|
committer | Benjamin Diele <benjamin@diele.be> | 2012-05-28 17:54:38 +0400 |
commit | 7b8664bbe5145509a0e38b6291212165931cead9 (patch) | |
tree | 69943d93f16245a19bba1ce40f24e987cc7f2ad9 /apps/user_ldap | |
parent | 817f9ff57d127e4f3b4402c05a8628ff8ab6f513 (diff) | |
download | nextcloud-server-7b8664bbe5145509a0e38b6291212165931cead9.tar.gz nextcloud-server-7b8664bbe5145509a0e38b6291212165931cead9.zip |
Check for valid LDAP-resource before querying.
Check if we have get valid link identifier from
self::getConnectionResource() before using ldap_search() and
ldap_get_entries(), otherwise return an empty array.
Signed-off-by: Benjamin Diele <benjamin@diele.be>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/lib_ldap.php | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php index 5cd7e0241bf..6a6d744a0f1 100644 --- a/apps/user_ldap/lib_ldap.php +++ b/apps/user_ldap/lib_ldap.php @@ -469,11 +469,23 @@ 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 ); - // 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)) { + + // See if we have a resource, that way we can get rid of the + // error-supressing. + $link_resource = self::getConnectionResource(); + if($link_resource) + { + $sr = ldap_search($link_resource, $base, $filter, $attr); + $findings = ldap_get_entries($link_resource, $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(); + } + } else + { + // Seems like we didn't find any resource. + // Return an empty array just like before. return array(); } |