[imp] default identity

carole gimenez gimenez at cict.fr
Fri Jun 24 06:02:10 PDT 2005


OK, i tried the two methods following but it doesn't work. I have always 
uid at xxx.fr as default identity:

1. if (!function_exists('_prefs_hook_from_addr')) {
     function _prefs_hook_from_addr($user = null)
     {
         $ldapServer = 'x.x.x.x';
         $ldapPort = '389';
         $searchBase = 'dc=ups-tlse,dc=fr';

         $ds = @ldap_connect($ldapServer, $ldapPort);

         if (is_null($user)) {
             $user = Auth::getAuth();
         }

         // You will probably need to replace cn= with uid=; this
         // syntax is for Netware 5.1 nldap.
         $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $user);
         $information = @ldap_get_entries($ds, $searchResult);
         if ($information[0]['mail'][0] != '') {
             $name = $information[0]['mail'][0];
         }
        //else {
        //     $name = $information[0]['cn'][0];
        // }

        ldap_close($ds);
        return (empty($name) ? $user : $name);
     }
 }


2. if (!function_exists('_prefs_hook_from_addr')) {
     function _prefs_hook_from_addr($user = null)
     {
         $ldapServer = 'x.x.x.x';
         $ldapPort = '389';
         $searchBase = 'dc=ups-tlse,dc=fr';

         $ds = @ldap_connect($ldapServer, $ldapPort);

         if (is_null($user)) {
             $user = Auth::getAuth();
         }

        $uid = Auth::getBareAuth();
        $binddn = 'uid=' . $uid . ',' . $searchBase;
        $bindpw = Auth::getCredential('password');

        if (@ldap_bind($ds, $binddn, $bindpw)) {
                $searchResult = @ldap_search($ds, $searchBase, 'uid=' . 
$uid);
        }

         // You will probably need to replace cn= with uid=; this
         // syntax is for Netware 5.1 nldap.
        // $searchResult = @ldap_search($ds, $searchBase, 'uid=' . $user);
         $information = @ldap_get_entries($ds, $searchResult);
         if ($information[0]['mail'][0] != '') {
             $emailname = $information[0]['mail'][0];
         }
        //else {
         //    $emailname = $information[0]['cn'][0];
         //}

        ldap_close($ds);
        return $emailname;
     }
 }


I have well modified horde/config/prefs.php to add 'hook' => true


Is there another things or files to be modified?


Carole.


Nicolas Schmitz wrote:

>One of the great thing of imp : custom hook. Edit horde/config/hooks.php
>and configure something like that :
>
> if (!function_exists('_prefs_hook_from_addr')) {
>     function _prefs_hook_from_addr($user = null)
>     {
>     $ldapServer = 'XXX';
>     $ldapPort = '389';
>    $ldapUser = 'XXX';
>    $ldapPass = 'XXX';
>    $searchBase = 'XXX';
>      $ldapconn = ldap_connect($ldapServer, $ldapPort);
>     $ds = ldap_bind($ldapconn, $ldapUser, $ldapPass);
>         $searchResult = ldap_search($ldapconn, $searchBase, 'uid=' . 
>$user);
>            $information = ldap_get_entries($ldapconn, $searchResult);
>            $name = $information[0]['mail'][0];
>                   ldap_close($ldapconn);
>       return (empty($name) ? $imp['user'] : $name);
>     }
> }
>
>then edit horde/config/prefs.php :
>
>// user preferred email address for From: line
>// If you lock this preference, you must specify a value or a hook for it in
>// horde/config/hooks.php.
>$_prefs['from_addr'] = array(
>    'value' => '',
>    'locked' => true,
>    'shared' => true,
>    'type' => 'text',
>    'desc' =>  _("Your From: address:"),
>     'hook' => true
>);
>
>
>You can do that for a lot of prefs.
>
>
>
>carole gimenez a écrit :
>
>  
>
>>Hi,
>>
>>I installed horde-3.0.3 and imp-h3-4.0.2 on a linux server.
>>
>>The authentification is realized through the cyrus-imap server which 
>>questions our ldap directory.
>>
>>The user gives as login his uid, unique ldap attribute, for example 
>>'vrc4952a'.
>>
>>The problem is that when this user wants send a mail, his default 
>>identity is uid at domain, here for example vrc4952a at xxx.fr.
>>
>>However we would like rather than his default identity is his mail 
>>attribute in ldap directory, here verdon at xxx.fr.
>>
>>Is that possible to do? and if yes, how?
>>
>>
>>Can someone help me on this subject, please?
>>
>>
>>Thanks for advance.
>>
>>
>>Carole.
>>
>> 
>>
>>    
>>
>
>
>  
>



More information about the imp mailing list