Merge resource error-suppressing fix

This commit is contained in:
Bart Visscher 2012-06-22 22:54:25 +02:00
commit ea3a6d9fcf
1 changed files with 17 additions and 5 deletions

View File

@ -471,11 +471,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();
}