[turba] problem w/ turba/lib/Driver/ldap.php read() function

Gary Windham windhamg at email.arizona.edu
Fri Dec 5 15:36:19 PST 2003


Chuck Hagenbuch wrote:
> Quoting Gary Windham <windhamg at email.arizona.edu>:
> 
> 
>>It appears that the read() method in the Turba LDAP driver doesn't work
>>properly when passed an array of DNs.  I stumbled across this while
>>trying to add a client link to a Nag task from an LDAP address book
>>source.  If the $dn argument is an array, the read() method attempts to
>>construct a search filter comprised of the array values, logically ORed.
>>  The 'dn' attribute, at least in the various LDAP servers I've dealt
>>with, is not a real, "searchable" attribute--to retrieve a single DN
>>entry, one needs to set the search base to the desired entry's DN.
>>
>>I've attached a patch for turba/lib/Driver/ldap.php that seems to
>>resolve this issue.
> 
> 
> Committed, thanks!
> 
> -chuck
> 
> --
> Charles Hagenbuch, <chuck at horde.org>
> "I'm really... I'm not too fascinated by green food." - Average Joe
> 

Chuck,

When you committed my patch, you changed the line that read:

   $results = array_merge($results, $result);

to

   $results[] = $result;

This screws-up the output of the read() method, as $results is now a 
3-dimensional array, rather than a 2-dimensional array (the 
Turba_Driver_ldap::getResults() method returns a 2-dimensional array).

If you don't want to use array_merge(), you could say something like, 
"$results += $result;".  I've attached a patch that does just this, and 
restores the correct output from the read() method. :)

Thanks,
--Gary

-- 
Gary Windham
Systems Programmer, Principal
The University of Arizona, CCIT
-------------- next part --------------
--- ldap.php	Fri Dec  5 16:29:05 2003
+++ ldap.php.new	Fri Dec  5 16:29:44 2003
@@ -195,7 +195,7 @@
                 $res = @ldap_read($this->_ds, $d, $filter, $attr);
                 if ($res) {
                     if (!is_a($result = $this->getResults($fields, $res), 'PEAR_Error')) {
-                        $results[] = $result;
+                        $results += $result;
                     } else {
                         return $result;
                     }


More information about the turba mailing list