aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/user_ldap/lib/access.php8
-rw-r--r--apps/user_ldap/lib/connection.php9
-rw-r--r--apps/user_ldap/lib/ldap.php10
3 files changed, 19 insertions, 8 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index d09571a8a66..6cdeff36677 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -54,14 +54,14 @@ abstract class Access extends BackendBase {
return false;
}
$cr = $this->connection->getConnectionResource();
- if(!is_resource($cr)) {
+ if(!$this->ldap->isResource($cr)) {
//LDAP not available
\OCP\Util::writeLog('user_ldap', 'LDAP resource not available.', \OCP\Util::DEBUG);
return false;
}
$dn = $this->DNasBaseParameter($dn);
$rr = @$this->ldap->read($cr, $dn, $filter, array($attr));
- if(!is_resource($rr)) {
+ if(!$this->ldap->isResource($rr)) {
if(!empty($attr)) {
//do not throw this message on userExists check, irritates
\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, \OCP\Util::DEBUG);
@@ -74,7 +74,7 @@ abstract class Access extends BackendBase {
return array();
}
$er = $this->ldap->first_entry($cr, $rr);
- if(!is_resource($er)) {
+ if(!$this->ldap->isResource($er)) {
//did not match the filter, return false
return false;
}
@@ -653,7 +653,7 @@ abstract class Access extends BackendBase {
// See if we have a resource, in case not cancel with message
$link_resource = $this->connection->getConnectionResource();
- if(!is_resource($link_resource)) {
+ if(!$this->ldap->isResource($link_resource)) {
// Seems like we didn't find any resource.
// Return an empty array just like before.
\OCP\Util::writeLog('user_ldap', 'Could not search, because resource is missing.', \OCP\Util::DEBUG);
diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index 42139274666..6a0d00405c0 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -92,7 +92,8 @@ class Connection extends BackendBase {
}
public function __destruct() {
- if(!$this->dontDestruct && is_resource($this->ldapConnectionRes)) {
+ if(!$this->dontDestruct &&
+ $this->ldap->isResource($this->ldapConnectionRes)) {
@$this->ldap->unbind($this->ldapConnectionRes);
};
}
@@ -149,7 +150,7 @@ class Connection extends BackendBase {
public function getConnectionResource() {
if(!$this->ldapConnectionRes) {
$this->init();
- } else if(!is_resource($this->ldapConnectionRes)) {
+ } else if(!$this->ldap->isResource($this->ldapConnectionRes)) {
$this->ldapConnectionRes = null;
$this->establishConnection();
}
@@ -624,7 +625,7 @@ class Connection extends BackendBase {
if(!$this->config['ldapOverrideMainServer'] && !$this->getFromCache('overrideMainServer')) {
$this->doConnect($this->config['ldapHost'], $this->config['ldapPort']);
$bindStatus = $this->bind();
- $error = is_resource($this->ldapConnectionRes) ? ldap_errno($this->ldapConnectionRes) : -1;
+ $error = $this->ldap->isResource($this->ldapConnectionRes) ? ldap_errno($this->ldapConnectionRes) : -1;
} else {
$bindStatus = false;
$error = null;
@@ -679,7 +680,7 @@ class Connection extends BackendBase {
$getConnectionResourceAttempt = true;
$cr = $this->getConnectionResource();
$getConnectionResourceAttempt = false;
- if(!is_resource($cr)) {
+ if(!$this->ldap->isResource($cr)) {
return false;
}
$ldapLogin = @$this->ldap->bind($cr, $this->config['ldapAgentName'], $this->config['ldapAgentPassword']);
diff --git a/apps/user_ldap/lib/ldap.php b/apps/user_ldap/lib/ldap.php
index 86c57c37d8a..1de901aec12 100644
--- a/apps/user_ldap/lib/ldap.php
+++ b/apps/user_ldap/lib/ldap.php
@@ -58,6 +58,16 @@ class LDAP {
return $hasSupport;
}
+ /**
+ * Checks whether the submitted parameter is a resource
+ *
+ * @param $resource the resource variable to check
+ * @return true if it is a resource, false otherwise
+ */
+ public function isResource($resource) {
+ return is_resource($resource);
+ }
+
private function preFunctionCall($functionName, $args) {
$this->curFunc = $functionName;
$this->curArgs = $args;