From 7048f58c1d56fcc53438fc900281c7660196715a Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 21 Jul 2007 08:27:13 +0000 Subject: [PATCH] reduced LDAP connects --- lam/lib/ldap.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lam/lib/ldap.inc b/lam/lib/ldap.inc index 8d6a4084..a2226a75 100644 --- a/lam/lib/ldap.inc +++ b/lam/lib/ldap.inc @@ -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();