[horde] Can't get authusername hook to work correctly
Michael M Slusarz
slusarz at horde.org
Wed Nov 19 05:22:58 UTC 2014
Quoting John H. Bennett III <bennettj at thebennetthome.com>:
> 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"
authusername converts between an authentication username and a Horde
username (meaning the username Horde is using internally). Key in
that statement: it doesn't change the authentication username.
If the original authentication username isn't valid for your
authentication backend (i.e. an IMAP server), this doesn't work.
You probably want the preauthenticate hook instead.
michael
___________________________________
Michael Slusarz [slusarz at horde.org]
More information about the horde
mailing list