[horde] Hooks.php code fails to get user information after upgrade

Elyse Salberg elyse.salberg at tufts.edu
Thu Apr 5 22:53:20 UTC 2007


I apologize in advance if I'm sending this to the wrong list (and ask  
for direction to the proper place to ask for assistance if that is  
the case).  I was unclear if this should go to the Horde or IMP list,  
or which list, but thought that starting here would be easiest.

We're working on upgrading our current Horde 3.0.12 / IMP 4.0.5 /  
Ingo / Turba (PHP 4.3.11 / PEAR 1.3.5 / Apache 1.3.33 / MySQL  
(prefs) / LDAP (auth) ) environment on Solaris 9 to Horde 3.1.4 / IMP  
4.1.4 / PHP 4.4.2 / PEAR 1.5.0 (to cover the relevant version changes).

In the process, I've run into an issue in which it appears the hooks  
we have for getting certain user information (fullname, from address,  
ldap attributes) are failing.  I've not been able to determine why -  
it appears that for some reason, Horde is not able to get the user's  
login information, and thus passes nothing to LDAP.  The user is  
authenticated successfully to our LDAP store and does gain access to  
the correct mailbox (however, our MySQL preferences database  
currently is pre-populated - I'm not sure what would happen if we  
removed the user's preferences information, as we're in the process  
of testing that).


I have included samples of the errors and hooks.php code that we have  
below, and would greatly appreciate if anyone can help with the  
following questions or provide other suggestions:

1) The hooks were written by a consultant quite a while ago and have  
not been modified between our current production environment and the  
proposed new one.  Were there changes that would require them to be  
rewritten?


2) In looking at the failure to get $user within the hooks code, it  
appears to me that there are two primary possibilities:
a. Auth::getAuth() is failing for some reason - whether this has to  
do with PHP  / PEAR being setup incorrectly, or something else.

We did try investigating whether we were missing a PEAR auth module,  
especially with the PEAR changes between 1.3.5 and 1.5.0.  While  
"pear list" does not show any auth modules installed on our current  
production servers, "pear list-all" did show some available, while  
initially on the upgraded systems, "pear list-all" did not show any  
auth modules.  However, since then we believe that we have installed  
auth modules on the upgraded system just in case, and it doesn't seem  
to have made a difference.

-- What exactly is Auth::getAuth() doing - is it using PHP / PEAR, or  
Apache, or something in Horde?  Any ideas why it might be failing (or  
if it's fine and something else is the issue)?

b. The hook is running at the wrong time (it's configured in the  
preferences in the same way as our current working production  
environment, albeit running with older code versions).

-- Any other reasons that the hook would not be getting the username  
of the user logging in (e.g. as entered into the login page - as I'm  
assuming that's what the hook would be using to get the user's  
information)?


A sample of the errors in the imp log (further lines can be provided  
as needed) - I believe these are from a single login, as they all  
occur between 11:53:10-11:53:11 and this is a limited-user system  
(I'm scrubbed them to remove identifying information):

HORDE[13664]: [ID 800047 local4.info] [imp] Fullname hook was called  
for user  [on line 1059 of "/usr/local/apache/htdocs/horde/config/ 
hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] Fullname hook was called  
for user  and uid= [on line 1068 of "/usr/local/apache/htdocs/horde/ 
config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
variable: user in /usr/local/apache/htdocs/horde/config/hooks.php on  
line 968
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr hook  
was called for user  and uid= [on line 969 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] LDAP bind completed [on  
line 973 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.error] [imp] LDAP get_entries  
returned more than one entry for  [on line 996 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
offset:  0 in /usr/local/apache/htdocs/horde/config/hooks.php on line  
1000
HORDE[13664]: [ID 800047 local4.info] [imp] Hook _fullname couldn't  
get LDAP attribute and is defaulting to the uid [on line 1074 of "/ 
usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] Hook _fullname returns   
[on line 1079 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] _from_addr hook was  
called for user  and uid= [on line 1017 of "/usr/local/apache/htdocs/ 
horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
variable: user in /usr/local/apache/htdocs/horde/config/hooks.php on  
line 968
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr hook  
was called for user  and uid= [on line 969 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] LDAP bind completed [on  
line 973 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.error] [imp] LDAP get_entries  
returned more than one entry for  [on line 996 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
offset:  0 in /usr/local/apache/htdocs/horde/config/hooks.php on line  
1000
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
variable: user in /usr/local/apache/htdocs/horde/config/hooks.php on  
line 968
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr hook  
was called for user  and uid= [on line 969 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] LDAP bind completed [on  
line 973 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.error] [imp] LDAP get_entries  
returned more than one entry for  [on line 996 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
offset:  0 in /usr/local/apache/htdocs/horde/config/hooks.php on line  
1000
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr for  
mailhost is , setting to ldap.server.edu [on line 1041 of "/usr/local/ 
apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] _from_addr hook couldn't  
find mail attr, sending mailhostattr @ldap.server.edu instead [on  
line 1045 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] _from_addr hook returns / 
@ldap.server.edu/ for user   and uid= [on line 1049 of "/usr/local/ 
apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] Fullname hook was called  
for user  [on line 1059 of "/usr/local/apache/htdocs/horde/config/ 
hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] Fullname hook was called  
for user  and uid= [on line 1068 of "/usr/local/apache/htdocs/horde/ 
config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
variable:  user in /usr/local/apache/htdocs/horde/config/hooks.php on  
line 968
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr hook  
was called for user  and uid= [on line 969 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] LDAP bind completed [on  
line 973 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.error] [imp] LDAP get_entries  
returned more than one entry for  [on line 996 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
offset:  0 in /usr/local/apache/htdocs/horde/config/hooks.php on line  
1000
HORDE[13664]: [ID 800047 local4.info] [imp] Hook _fullname couldn't  
get LDAP attribute and is defaulting to the uid [on line 1074 of "/ 
usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] Hook _fullname returns   
[on line 1079 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] Fullname hook was called  
for user  [on line 1059 of "/usr/local/apache/htdocs/horde/config/ 
hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] Fullname hook was called  
for user  and uid= [on line 1068 of "/usr/local/apache/htdocs/horde/ 
config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
variable:  user in /usr/local/apache/htdocs/horde/config/hooks.php on  
line 968
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr hook  
was called for user  and uid= [on line 969 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] LDAP bind completed [on  
line 973 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.error] [imp] LDAP get_entries  
returned more than one entry for  [on line 996 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
offset:  0 in /usr/local/apache/htdocs/horde/config/hooks.php on line  
1000
HORDE[13664]: [ID 800047 local4.info] [imp] Hook _fullname couldn't  
get LDAP attribute and is defaulting to the uid [on line 1074 of "/ 
usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] Hook _fullname returns   
[on line 1079 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] _from_addr hook was  
called for user  and uid= [on line 1017 of "/usr/local/apache/htdocs/ 
horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
variable:  user in /usr/local/apache/htdocs/horde/config/hooks.php on  
line 968
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr hook  
was called for user  and uid= [on line 969 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] LDAP bind completed [on  
line 973 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.error] [imp] LDAP get_entries  
returned more than one entry for  [on line 996 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
offset:  0 in /usr/local/apache/htdocs/horde/config/hooks.php on line  
1000
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
variable:  user in /usr/local/apache/htdocs/horde/config/hooks.php on  
line 968
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr hook  
was called for user  and uid= [on line 969 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] LDAP bind completed [on  
line 973 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.error] [imp] LDAP get_entries  
returned more than one entry for  [on line 996 of "/usr/local/apache/ 
htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.notice] PHP Notice:  Undefined  
offset:  0 in /usr/local/apache/htdocs/horde/config/hooks.php on line  
1000
HORDE[13664]: [ID 800047 local4.info] [imp] _t_fetch_ldap_attr for  
mailhost is , setting to ldap.server.edu [on line 1041 of "/usr/local/ 
apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] _from_addr hook couldn't  
find mail attr, sending mailhostattr @ldap.server.edu instead [on  
line 1045 of "/usr/local/apache/htdocs/horde/config/hooks.php"]
HORDE[13664]: [ID 800047 local4.info] [imp] _from_addr hook returns / 
@ldap.server.edu/ for user  and uid= [on line 1049 of "/usr/local/ 
apache/htdocs/horde/config/hooks.php"]


The code for the fullname hook (as that's the first failing hook -  
the rest can be provided as well) is:
if (!function_exists('_prefs_hook_fullname')) {
    function _prefs_hook_fullname($user = null)
    {
        $entry="Fullname hook was called for user $user";
        Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO);

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

        $uid = Auth::getBareAuth();

        $entry="Fullname hook was called for user $user and uid=$uid";
        Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO);

        $name = _t_fetch_ldap_attr($uid,"cn");

        if (empty($name)) {
          $entry="Hook _fullname couldn't get LDAP attribute and is  
defaulting to the
uid";
          Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO);
          $name = $uid;
        }

        $entry="Hook _fullname returns $name";
        Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO);

        return $name;
    }


Elyse Salberg
System Administrator
Tufts University Systems Group



More information about the horde mailing list