[turba] Re: problem with duplicate dn with LDAP backend

andreas oster aoster at novanetwork.de
Wed Apr 14 00:56:30 PDT 2004


andreas oster wrote:
> hello list,
> 
> I have run into a little problem with turba. I have set up a shared LDAp
> addressbook. I use a modified mozilla-schema and changed the appropriate
> settings in the attributes.php and sources.php file and everything works
> like a charm. Only the possibility of running into duplicate dn-problems
> gives me a headache. I would like to use 'uid' created from sn and  some
> numer (Date?) in the dn. Is this possible ? How can I do this. I tried
> some things but unfortunately my PHP skills are only rudimental, and 
> therefor didn't get very far :(
> 
> Can somebody help me with this problem/task ?
> 
> Thanks for your kind help
> 
> Andreas
> 

Hello List,

ok, now, with some modification of lib/ldap.php i am able to add new
ldap entries with a unique uid, constructed from givenname, sn and
date. I know this code is crap, but unfortunately it is the best I was
able to accomplish :) I have also constructed the cn field from
givenname and sn, and used a 'name' composite field for display in the
web frontend.

here are the changes I have made to the lib/ldap.php

<--snip

function addObject($attributes)
{
  if (empty($attributes['dn'])) {
       return PEAR::raiseError('Tried to add an object with no dn:
		 [' . serialize($attributes) . '].');
         } elseif (empty($this->_params['objectclass'])) {
             return PEAR::raiseError('Tried to add an object with no 
objectclass: [' . serialize($attributes) . '].');
         }

// Construct uid from givenname, sn and date

$uid = $attributes['givenName'] . $attributes['sn'] .  date("dmyG");
$attributes['uid'] = $uid;

// Construct new dn from uid and root

$dn = "uid=" . $uid . "," . $this->_params['root'];
unset($attributes['dn']);

// Construct new cn from givenname and sn

$attributes['cn'] = $attributes['givenName'] . " " . $attributes['sn'];

-->snip end

The new ldap entries are created properly, but there is one problem 
left. After adding, a search for the entry is performed. Because the
search code hase no knowledge of my self-generated uid it always 
responds with an error message stating that the entry could not be 
found. I need a way to inject my uid back to the attributes form the
conf/sources.php ore directly into the search code.

Can someone help me with this task ? Is this possible ?

best regards

Andreas



More information about the turba mailing list