LDAP: reset resource on failed bind

check for resource
This commit is contained in:
Arthur Schiwon 2012-07-02 14:03:16 +02:00
parent 90331a3fa1
commit 515adceace
1 changed files with 4 additions and 4 deletions

View File

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