reduced LDAP connects

This commit is contained in:
Roland Gruber 2007-07-21 08:27:13 +00:00
parent 70700205a9
commit 7048f58c1d
1 changed files with 8 additions and 2 deletions

View File

@ -56,6 +56,8 @@ class Ldap{
/** Server handle */
private $server;
private $is_connected = false;
/** LDAP username used for bind */
private $username;
@ -293,6 +295,11 @@ class Ldap{
* @return object connection handle
*/
function server() {
if (!$this->is_connected) {
$data = $this->decrypt_login();
$this->connect($data[0], $data[1]);
$this->is_connected = true;
}
return $this->server;
}
@ -306,8 +313,7 @@ class Ldap{
/** Reconnects to LDAP server when deserialized */
function __wakeup() {
$data = $this->decrypt_login();
$this->connect($data[0], $data[1]);
$this->is_connected = false;
// change random number
mt_srand($this->rand + (microtime() * 1000000));
$this->rand = mt_rand();