[turba] PATCH: ldap sizelimit

Andrew Morgan morgan at orst.edu
Thu Mar 13 13:07:38 PST 2003



On Mon, 24 Feb 2003, Chuck Hagenbuch wrote:

> Quoting Andrew Morgan <morgan at orst.edu>:
>
> > Are you interested in the two patches attached to this email, which add
> > support for limiting the size of the ldap query?  These were against
> > Turba 1.1, but they look like they will apply cleanly to 1.2rc2 except
> > maybe the offset.
>
> They won't go in for 1.2 (no testing time), but if you submit them against
> HEAD we'll look at them and possibly merge them in for 1.3.
>
> -chuck

A little slow, but it comes eventually...  Attached is patch against head
which adds sizelimit support in ldap queries to Turba.  It's a simple
patch.

I'm not sure what the behavior of:

       return PEAR::raiseError($this->errstr);

will be for this error message versus the original statement (return
array();).  I don't have an installation of Turba head to test this with,
and adding the PEAR::raiseError didn't do anything on Turba 1.2.

	Andy
-------------- next part --------------
diff -ur turba.orig/config/sources.php.dist turba/config/sources.php.dist
--- turba.orig/config/sources.php.dist	Thu Mar 13 12:55:05 2003
+++ turba/config/sources.php.dist	Thu Mar 13 12:55:18 2003
@@ -209,6 +209,7 @@
         'root' => 'dc=example,dc=com',
         'bind_dn' => 'cn=admin,ou=users,dc=example,dc=com',
         'bind_password' => '********',
+        'sizelimit' => 200,
         'dn' => array('cn'),
         'objectclass' => 'person',
         'charset' => 'iso-8859-1',
diff -ur turba.orig/lib/Driver/ldap.php turba/lib/Driver/ldap.php
--- turba.orig/lib/Driver/ldap.php	Thu Mar 13 12:44:05 2003
+++ turba/lib/Driver/ldap.php	Thu Mar 13 12:54:14 2003
@@ -158,13 +158,22 @@
             $attr[] = 'sn';
         }
 
+        /*
+         * Add a sizelimit, if specified. Default is 0, which means no limit.
+         * Note: You cannot override a server-side limit with this.
+         */
+        $sizelimit = 0;
+        if (!empty($this->params['sizelimit'])) {
+            $sizelimit = $this->params['sizelimit'];
+        }
+
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('LDAP search by %s: root = %s (%s); filter = "%s"; attributes = "%s"',
-                                  Auth::getAuth(), $this->root, $this->server, $filter, implode(', ', $attr)),
+        Horde::logMessage(sprintf('LDAP search by %s: root = %s (%s); filter = "%s"; attributes = "%s"; sizelimit = %d',
+                                  Auth::getAuth(), $this->root, $this->server, $filter, implode(', ', $attr), $sizelimit),
                           __FILE__, __LINE__, LOG_DEBUG);
 
         /* Send the query to the LDAP server and fetch the matching entries. */
-        if (!($res = @ldap_search($this->ds, $this->root, $filter, $attr))) {
+        if (!($res = @ldap_search($this->ds, $this->root, $filter, $attr, 0, $sizelimit))) {
             $this->errno = ldap_errno($this->ds);
             $this->errstr = ldap_error($this->ds);
             return PEAR::raiseError($this->errstr);


More information about the turba mailing list