[turba] LDAP Driver

Edwin Culp eculp@encontacto.net
Wed, 12 Jun 2002 16:59:47 -0700


Quoting Lee <lee@disinfo.com>:

| Has anyone implemented a per user address book for turba using ldap? I
| see a default shared address book in sources.php, but nothing for per
| user (private) ldap.
| 
| Thanks,
| Lee 
Lee,

I do it with my ldap directory structure and horde/turba/config/sources.php
configuration. 

My ldap tree for this is 
o=my.org
  ou=people,o=my.org
    mail=name@my.org,ou=people,o=my.org  /* This builds my corp. addrBook.*/
  ou=addressbook,o=my.org
    mail=name@my.org,ou=addressbook,o=my.org
      mail=aPersonInMyAddressBook@theirDomain.com,mail=name@my.org,\
      ou=addressbook,o=my.org      /*This is the personal addressbook.*/

I have two definitions in sources.php on for the corporate addressbook
and the other for the personal addressbook.  This works for me for
virtual users and domains. I've probably made it too complicated so
feedback/suggestions for simplification, improvements, scalability, 
etc. would be appreciated.

My sources.php should be self explanatory.  It basically configures itself
based on the url.

I hope this helps,

ed

--------------------------sources.php Follows -----------------------
<?php

/*     Sources.php      */

$vdomain = strtolower(preg_replace('|^mail\.|i', '', $_SERVER['HTTP_HOST']));
$usermail=Auth::getAuth();
$uid = preg_replace('|@.*|i', '', $usermail);
$pass=Auth::getCredential('password');

/*         PRIVATE ADDRESS BOOK      */

$cfgSources['private'] = array(
    'title' => 'Personal directory for ' . $uid,
    'type' => 'ldap',
    'params' => array(
        'server' => 'localhost',
        'port' => 389,
        'root' => 'mail=' . $usermail . ',ou=addressbook,o=my.org',

/*        BIND AS USER NOT AS ROOT    */

        'bind_dn' => 'mail=' . $usermail . ',ou=people,o=my.org',
        'bind_password' => $pass,
        'dn' => array('mail'),
        'objectclass' => array( 'hordePerson'),
        'filter' =>  ''
    ),
    'map' => array(
        '__key' => 'dn',
        'name' => 'cn',
        'email' => 'mail',
        'alias' => 'givenname'
    ),
    'search' => array(
        'name',
        'email',
        'alias'
    ),

    'strict' => array(
        'dn'
    ),

    'public' => true,
    'readonly' => false,
    'admin' => array(),
    'export' => true
);

/*    Corporate/Domain Address Book      */

$cfgSources['corporate'] = array(
    'title' => 'Our ' . $vdomain . ' Directory',
    'type' => 'ldap',
    'params' => array(
        'server' => 'localhost',
        'port' => 389,
        'root' => 'ou=people,o=worldinternet.org',

/*        BIND AS USER NOT AS ROOT        */

        'bind_dn' => 'mail=' . $usermail . ',ou=people,o=my.org',
        'bind_password' => $pass,
        'dn' => array('cn'),
        'objectclass' => array( 'hordePerson'),
        'filter' => ''
    ),
    'map' => array(
        '__key' => 'dn',
        'name' => 'cn',
        'email' => 'mail',
        'sirname' => 'sn',
        'title' => 'title',
        'company' => 'o',
        'businesscategory' => 'businesscategory',
        'companyaddress' => 'postaladdress',
        'zip' => 'postalcode',
        'workphone' => 'telephonenumber',
        'fax' => 'facsimiletelephonenumber',
        'homeaddress' => 'homepostaladdress',
        'city' => 'l',
        'state' => 'st',
        'homephone' => 'homephone',
        'cellphone' => 'mobile',
        'alias' => 'givenname',
        'notes' => 'description',
        'pgpPublicKey' => 'object_pgppublickey'
    ),
    'search' => array(
        'name',
        'email',
        'company',
        'alias',
        'sirname',
        'homephone',
        'workphone',
        'cellphone',
        'homeaddress'
    ),
    'public' => true,
    'readonly' => false,
    'admin' => array('eculp@' .  $vdomain ),
    'export' => true
);

Hope this helps,

ed