From 5baf8c0c981e9d63e9ce052cac119b74c806c4c3 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 5 Mar 2008 10:33:57 +0000 Subject: [PATCH] Updated ldap class. -Added warning , if there is still unfetched data. git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@9342 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_ldap.inc | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/include/class_ldap.inc b/include/class_ldap.inc index 0e1e909b5..6ca1b49c5 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -32,6 +32,8 @@ class LDAP{ var $referrals= array(); var $max_ldap_query_time = 0; // 0, empty or negative values will disable this check + var $re = NULL; + function LDAP($binddn,$bindpw, $hostname, $follow_referral= FALSE, $tls= FALSE) { global $config; @@ -187,13 +189,31 @@ class LDAP{ return(ereg_replace("[^,]*[,]*[ ]*(.*)", "\\1", $basedn)); } + + /* Checks if there is still unfetched data + */ + function checkResult() + { + /* Check if we have started a search before */ + if(is_resource(@ldap_first_entry($this->cid, $this->sr))){ + + /* Check if there are still unfetched elements */ + if(is_resource(@ldap_next_entry($this->cid, $this->re))){ + trigger_error("A new search was initiated while the an older search wasn't fetched completely."); + } + } + } + function search($filter, $attrs= array()) { if($this->hascon){ if ($this->reconnect) $this->connect(); + /* Check if there are still unfetched objects from last search + */ + $this->checkResult(); + $start = microtime(); - $this->clearResult(); $this->sr = @ldap_search($this->cid, $this->fix($this->basedn), $filter, $attrs); $this->error = @ldap_error($this->cid); @@ -221,6 +241,11 @@ class LDAP{ { if($this->hascon){ if ($this->reconnect) $this->connect(); + + /* Check if there are still unfetched objects from last search + */ + $this->checkResult(); + $this->clearResult(); if ($basedn == "") $basedn = $this->basedn; @@ -255,6 +280,11 @@ class LDAP{ { if($this->hascon){ if ($this->reconnect) $this->connect(); + + /* Check if there are still unfetched objects from last search + */ + $this->checkResult(); + $start = microtime(); $this->clearResult(); $filter = "(objectclass=*)"; -- 2.30.2