[horde] Re: Hook question

Craig White craigwhite at azapple.com
Sun Mar 6 16:01:20 PST 2005


On Sun, 2005-03-06 at 17:28 -0500, AJ wrote:
> Hi,
>   I am trying to enable the fullname and from_addr hooks from the wiki.
> I copied everything over, and made sure that hook => true in
> horde/config/prefs.php, but the hooks just never fire.  I also cleared out the
> prefs, so that it emulates the first login.  Does anyone know why these hooks
> are not firing?  Any help w/ this would be great.  I am using the LDAP examples
> from the wiki.
----
'hook' => 'true',

^^^^^^^^^^^^^^^^ I think this is literally how it must be.

You may be able to omit the single quotes around the word true

You would have to change $searchBase to the ou which contains your user
entries...

as long as you can do this...

ldapsearch -x -h localhost -D "uid=YOUR_USER_NAME,$searchBase" -b
"$searchbase" -W "(uid=YOUR_USER_NAME)"

it will work...

lastly, I did modify my setup some since the wiki (I should change
that). The difference should be obvious.

if (!function_exists('_prefs_hook_from_addr')) {

   function _prefs_hook_from_addr($user = null)
     {

       $domain_name = 'azapple.com';
       $ldapServer = 'localhost';
       $ldapPort = '389';
       $searchBase = 'ou=People,dc=azapple,dc=com';
       $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);
       }

       $information = @ldap_get_entries($ds, $searchResult);

        // derive the email address if possible
        if ($information[0]['mail'][0] != '') {
           $emailname = $information[0]['mail'][0];
        } else {
           $emailname = $information[0]['uid'][0] . '@' . $domain_name;
        }

         ldap_close($ds);

         return $emailname;
     }
}


Craig





More information about the horde mailing list