[turba] question/problem about multi-valued ldap mail attribute

COMBES Julien - CETE Lyon/DI/ET/PAMELA julien.combes at i-carre.net
Wed Feb 8 02:59:15 PST 2006


Le 04.02.2006 23:27, Sébastien RENON a écrit  :
> Hi julien

Hi

> I've the same problem. You've found a solution by creating a hook function. Could you post this function in this mailing list?

here an answer I have done to someone who asked to me the same question ;-)

-----------------------------------------------------------------------
As I use the Debian's packages, the config files are in 
/etc/horde/[horde3|turba2|...]/ and all the horde's files are in 
/usr/share/horde3 (with a symbolic link of /usr/share/horde3/config on 
/etc/horde/horde3 and /usr/share/horde3/turba2/config on 
/etc/horde/turba2/). I don't know where they should be exactly when you 
use the horde sources (perhaps in /usr/local/horde/ and configuration's 
file in /usr/local/horde/config). I will give you the path on a Debian, 
I think it won't be difficult to retrive the path on a standard horde 
tree (the file names are identical, only the path may change a little).

The principe, as I have understood it with the help of Chuck Hagenbuch 
on the turba list and afterwards with the reading of the file 
/usr/share/horde3/turba/lib/AbstractObject.php near lines 70 to 88, is 
that it's possible to add a function named '_turba_hook_decode_<ATTRIBUTE>'
with <ATTRIBUTE> which corresponds in the name of an attribute defined 
in /etc/horde/turba2/sources.php.

This function takes one parameter which contain the return of turba 
traitement (in the case of email addresses : emails are separated by 
commas) and have to return the value which will be used by turba.

In the file '/etc/horde/turba2/sources.php', I have defined :
$cfgSources['localldap'] = array(
     'title' => _("Ldap directory"),
     'type' => 'ldap',
     'params' => array(
         'server' => 'ldap.my.domain',
         'port' => 389,
         'tls' => false,
         'root' => 'ou=organisation,dc=my,dc=domain',
         'sizelimit' => 200,
         'dn' => array('cn'),
         'objectclass' => array( ),
     'charset' => 'utf8',
     'checkrequired' => false,
     'checkrequired_string' => ' ',
         'version' => 3
     'map' => array(
         '__key' => 'dn',
         '__uid' => 'uid',
         'name' => 'cn',
         'lastname' => 'sn',
         'firstname' => 'givenname',
         'service' => 'departmentNumber',
         'email' => 'mail',
         'workPhone' => 'telephonenumber',
         'cellPhone' => 'mobiletelephonenumber',
         'office' => 'physicaldeliveryofficename',
         'workAddress' => 'street',
         'workCity' => 'l',
         'workPostalCode' => 'postalcode',
         'description' => 'description',
         'freebusyUrl' => 'calFBURL',
     ),
     'search' => array(
         'name',
         'email',
         'lastname',
         'firstname',
     ),
     'strict' => array(
         'dn',
     ),
     'public' => true,
     'readonly' => true,
     'admin' => array(),
     'export' => true
);

As you can see, the email addresses are in the attribute 'mail'  in my 
ldap directory and it correponds to email in turba's name (it's that 
name that we have to use in the function name).

In the file '/etc/horde/horde3/hooks.php', I added a function named 
'_turba_hook_decode_email' :
if (!function_exists('_turba_hook_decode_email')) {
     function _turba_hook_decode_email($emails)
     {
       list($first_email) = split(',', $emails);

       return $first_email;
     }
}

In $emails, there is the email addresses separated by commas. In my 
case, I just take the first email addresse but you can do any traitement 
as you like. I thinks that it may be possible to use globale variables 
defined in horde and turba if you need.
-----------------------------------------------------------------------

I hope that that can help you.

Julien


More information about the turba mailing list