[horde] Can't get authusername hook to work correctly

John H. Bennett III bennettj at thebennetthome.com
Wed Nov 19 04:52:37 UTC 2014


Hello,

I must once again rely on this community for some help.  I'm trying to  
use the authusername hook to always convert userids to lowercase, no  
matter what's typed in the login box.  I looked at horde.php.dist, and  
this didn't seem to be very hard, but try as I might, I can't get it  
to work.  I'm actually trying to get it to append the domain, and  
convert userid to lowercase.  The domain appending piece is working  
fine.

This is what I've got:

class Horde_Hooks
{
       public function authusername($userId, $toHorde)
       {
           $vdomain = getenv('HTTP_HOST');
           $vdomain = Horde_String::lower($vdomain);
           $vdomain = substr($vdomain,strpos($vdomain,".")+1);
           $userId = Horde_String::lower($userId);
              if ($toHorde) {
                  return $userId . '@' . $vdomain;
              } else {
                   return (substr($userId, -strlen($vdomain)) == $vdomain)
                   ? substr($userId, 0, -strlen($vdomain)-1)
                   : $userId;
              }
       }
}

I've tried moving $userId = Horde_String::lower($userId); to before  
the first and second return statements.  No matter what I try, if I  
type a username in mixed case, i.e. User1, I can't login, and will see  
this in my log:


Nov 18 22:44:38 www HORDE: [imp] [login] Authentication failed. [pid  
29870 on line 730 of "/home/httpd/html/horde/imp/lib/Imap.php"]
Nov 18 22:44:38 www HORDE: [horde] FAILED LOGIN for User1 to horde  
(10.10.10.125) [pid 29870 on line 199 of  
"/home/httpd/html/horde/login.php"

If I use all lowercase to login, I'm able to login just fine:

Nov 18 22:45:41 www HORDE: [horde] Login success for user1 at mytest.com  
to horde (10.10.10.125) [pid 2620 on line 164 of  
"/home/httpd/html/horde/login.php"]
Nov 18 22:45:41 www HORDE: [imp] Login success for user1 (Horde user  
user1 at mytest.com) (10.10.10.125) to {imap://localhost/} [pid 2620 on  
line 157 of "/home/httpd/html/horde/imp/lib/Auth.php"]

I'm not a coder, but I tried following the example as best I could.   
I'd really appreciate someone letting me know where I've gone astray.

My horde versions are stable as of today.

Thank you,

John Bennett




More information about the horde mailing list