/**
* Constructor.
*
- * The usual way of getting Horde_Ldap to work is to call
- * something like:
- * <code>$ldap = Horde_Ldap::connect($ldap_config);</code>
- *
* @see $_config
*
* @param array $config Configuration array.
$this->_host_list = array($this->_config['hostspec']);
} else {
$this->_host_list = array();
- /* This will cause an error in performConnect(), so
+ /* This will cause an error in _connect(), so
* the user is notified about the failure. */
}
}
$oldpw = $this->_config['searchpw'];
/* Overwrite bind credentials in config so
- * performConnect() knows about them. */
+ * _connect() knows about them. */
$this->_config['searchdn'] = $dn;
$this->_config['searchpw'] = $password;
/* Try to connect with provided credentials. */
- $msg = $this->performConnect();
+ $msg = $this->_connect();
/* Reset to previous config. */
$this->_config['searchdn'] = $olddn;
*
* @throws Horde_Ldap_Exception
*/
- protected function performConnect()
+ protected function _connect()
{
/* Connecting is briefly described in RFC1777. Basicly it works like
* this:
* In case the connection to the LDAP service has dropped out for some
* reason, this function will reconnect, and re-bind if a bind has been
* attempted in the past. It is probably most useful when the server list
- * provided to the new() or connect() function is an array rather than a
+ * provided to the new() or _connect() function is an array rather than a
* single host name, because in that case it will be able to connect to a
* failover or secondary server in case the primary server goes down.
*
*
* @throws Horde_Ldap_Exception
*/
- protected function performReconnect()
+ protected function _reconnect()
{
/* Return if we are already connected. */
if ($this->_link) {
$this->_down_host_list = array();
try {
- $this->performConnect();
+ $this->_connect();
} catch (Horde_Ldap_Exception $e) {
$this->_config['current_backoff'] *= 2;
if ($this->_config['current_backoff'] > $this->_config['max_backoff']) {
}
/* $this->_config['hostspec'] should have had the last connected
- * host stored in it by performConnect(). Since we are unable to
+ * host stored in it by _connect(). Since we are unable to
* bind to that host we can safely assume that it is down or has
* some other problem. */
$this->_down_host_list[] = $this->_config['hostspec'];
}
/**
+ * Closes the LDAP connection.
+ */
+ public function disconnect()
+ {
+ @ldap_close($this->_link);
+ }
+
+ /**
* Starts an encrypted session.
*
* @throws Horde_Ldap_Exception
}
/**
- * Closes the LDAP connection.
- */
- public function disconnect()
- {
- @ldap_close($this->_link);
- }
-
- /**
* Adds a new entry to the directory.
*
* This also links the entry to the connection used for the add, if it was
/* The server has disconnected before trying the operation. We
* should try again, possibly with a different server. */
$this->_link = false;
- $this->performReconnect();
+ $this->_reconnect();
}
}
/* The server has disconnected before trying the operation. We
* should try again, possibly with a different server. */
$this->_link = false;
- $this->performReconnect();
+ $this->_reconnect();
} elseif ($error_code == 66) {
/* Subentries present, server refused to delete.
* Deleting subentries is the clients responsibility, but since
* We should try again, possibly with a different
* server. */
$this->_link = false;
- $this->performReconnect();
+ $this->_reconnect();
}
}
}
/* Errorcode 1 = LDAP_OPERATIONS_ERROR but we can try a
* reconnect. */
$this->_link = false;
- $this->performReconnect();
+ $this->_reconnect();
} else {
$msg = "\nParameters:\nBase: $base\nFilter: $filter\nScope: $scope";
throw new Horde_Ldap_Exception($this->errorMessage($err) . $msg, $err);
if ($this->_link) {
return $this->_link;
}
- $this->performReconnect();
+ $this->_reconnect();
}
}
return $this->_link;