From: hickert Date: Wed, 5 Mar 2008 10:32:23 +0000 (+0000) Subject: Updated ldap class X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cad6106c1221bf946508f0e54a3cec9be0431c5c;p=gosa.git Updated ldap class -Added a warning if the last result wasn't fetched completely git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9341 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 4e0b82ac9..10e7b96e2 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -46,6 +46,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; @@ -198,13 +200,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, LDAP::fix($this->basedn), $filter, $attrs); $this->error = @ldap_error($this->cid); @@ -231,6 +251,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; @@ -264,6 +289,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(); $filter = "(objectclass=*)"; $this->sr = @ldap_read($this->cid, LDAP::fix($dn), $filter,$attrs);