[horde] feeding LDAP user address to default identity

Chris Flav chris.flav at yahoo.ca
Wed Nov 24 23:10:44 UTC 2010


Hello,

I am upgrading a old server that currently has a mechanism to retreive the 
user's email address from a LDAP server using the following function;

in conf.php there is;

// If this is set to a function name, that function will be used
// to get the user's email address to use when sending mail.  See
// the 'imp_expand_fromaddress' function below for an example.
$conf['hooks']['from'] = 'imp_expand_fromaddress';


and lower down there is a function;

/* This is another example how to get the from address from an ldap server. */
if (!function_exists('imp_expand_fromaddress')) {
     function imp_expand_fromaddress($imp) {
        global $_SERVER;
        $SERVER="localhost";
        $ROOTDN="uid=root,dc=example,dc=com";
        $ROOTPW=$_SERVER['PW'];
        $BASEDN="dc=example,dc=com";
        $ds = ldap_connect($SERVER);
        ldap_bind($ds,$ROOTDN, $ROOTPW);
         $searchResult = @ldap_search($ds, $BASEDN, 'uid=' . $imp['user']);
         $information = @ldap_get_entries($ds, $searchResult);
         $name = $information[0]['maillocaladdress'][0];
         ldap_close($ds);
         return (empty($name) ? $imp['user'] : $name);
     }
 }


this retreives the first email address configured on a LDAP dn.  I don't find 
this hook anywhere in the latest version of IMP, is there anyone that could give 
me a hint where I could add this to duplicate this functionality? 


Thanks,

C. Flav




More information about the horde mailing list