[turba] Re: problem with duplicate dn with LDAP backend (andreas oster)

Ed Murray mail at avenuedesign.net
Fri Apr 16 23:41:10 PDT 2004


Additional notes on the turba hack.


> Andreas,
> 	I have been trying to set up an LDAP address book with turba for some
> time now and this seems to be an answer to some of the problems I have
> come up against.
> 
> Having built a LDAP address book in Java I understand the importance of
> having a unique DN.
> 
> I am not a PHP programmer but I have been looking at your alterations
> for turba. 
> 
> There are a couple of problems which arise from the uid not being
> defined in the sources.php map:
> 
There is one more problem that I have noticed see 3 below.

> 1. The one that you mentioned about the error coming up after having
> added an entry. 
> 
> 2. With updating an entry. The setObject function is calling the makeKey
> function which is trying to assemble a dn from the fields attributes. It
> is unable to do this for the above reasons. To work around this I have
> commented out the code responsible for the renaming of the dn. This
> doesn't seem to be a major problem albeit a bit of a hack.
> 
> 
3. When adding an addressbook entry from a email it is not passing
seperate givenName  and sn attributes and therefore not working. Here is
a very rough hack. That will enable it to work.

replace the last line of the following function in  turba/lib/api.php

function _turba_add($name = '', $address = '', $addressbook = '')

with the following lines

//** return $driver->addObject(array('name' => $name, 'email' ...
    $lastname = Turba::guessLastname($name);
    $firstname = preg_replace("|\s+$lastname|", '', $name);
    return $driver->addObject(array('name' => $name, 'email' => 
$address, '__owner' => Auth::getAuth(), 'firstname' => $firstname,
'lastname' => $lastname));


> btw i am using TURBA 2.0 Alpha.
> 
> The new composite fields are a heaven sent and answer some problems but
> I thinks there is still another issue with specifying the DN. How are
> people currently using  composite fields in conjunction with a dn. The
> way I see it you would have to choose either of the sn or givenNmae
> fields which by themselves would not go anyway close to being a good
> unique identifier. Is there currently another option?
> 
> N.B: Can anybody tell me if it is possible for Turba 2.0 to be used in
> conjunction with IMP and HORDE stable?
> 
> 
> On Fri, 2004-04-16 at 16:35, andreas oster wrote:
> > Ed Murray wrote:
> > > Hi Andreas,
> > > 	I am very interested in your code. There appears to be a line that has
> > > been chopped off. Could you repost again please. Take note of the line
> > > that starts with:
> > > 
> > > $this->driver->makeKey(
> > > 
> > > 
> > > turba/lib/Source.php
> > > 
> > >      /**
> > >       * Adds a new entry to the contact source.
> > >       *
> > >       * @param array $attributes  The attributes of the new object to
> > > add.
> > >       *
> > >       * @return mixed             The new __key value on success, or a
> > >       *                           PEAR_Error object on failure.
> > >       */
> > >      function addObject($attributes)
> > >      {
> > >          if ($this->readonly) {
> > >              return false;
> > >          }
> > > 
> > >          // Always generate a new key.
> > >          $attributes['__key'] = 
> > > $this->driver->makeKey($this->toDriverKeys($attri
> > > 
> > >          if (!isset($attributes['__type'])) {
> > >              $attributes['__type'] = 'Object';
> > >          }
> > > 
> > Dear Ed,
> > 
> > this is actually from the original code, I have only posted the whole
> > function for better finding :) The only changes in Sources.php is the
> > line
> >        $key = $result;
> > 




More information about the turba mailing list