[imp] Forcing username to lowercase with IMP 5.x

Joe Besko jbesko at msu.edu
Thu Oct 13 18:58:04 UTC 2011


Quoting Joe Besko <jbesko at msu.edu>:

> Quoting Michael M Slusarz <slusarz at horde.org>:
>
>> Quoting Joe Besko <jbesko at msu.edu>:
>>
>>> We're running a production version on Webmail Edition 1.2.x and  
>>> have gotten the usernames to be forced to lowercase using the  
>>> _imp_hook_vinfo hook.
>>>
>>> I've installed a test version of Webmail Edition 4.0.x for a  
>>> simulated upgrade of the production system.  I see there is a way  
>>> to force the username to lowercase for the authentication, but I  
>>> am uncertain how to get this to work.  I've tried uncommenting the  
>>> section of code (example #2) in the horde/config/hooks.php for  
>>> authusername, but wondered if there is some other configuration  
>>> flag I need to set to enable this functionality.
>>
>> Do usernames need to be all lowercase for authentication purposes?
>
> Yes.
>
>> If so, you want the 'preauthenticate' hook.  See  
>> horde/config/hooks.php for more info.
>
> Thanks.
>
>> authusername is used to convert between an authentication username  
>> and a Horde username.  That doesn't sound like what you want.
>
> This is not what I want to do.

For documentation purposes, here's what I did to get this to work:

1. In the horde/imp/config/hooks.php file, I added the following function:
     This was copied from the hooks.php.dist file

      public function preauthenticate($userId, $credentials)
      {
          return true;
      }

2. Copied horde/config/hooks.php.dist to horde/config/hooks.local.php
3. In the horde/config/hooks.local.php file, uncommented the  
"preauthenticate" function.
4. Within the "preauthenticate" function, added the following code to  
force the username to lowercase:

         return array(
                 'userId' => Horde_String::lower($userId),
                 'credentials' => $credentials
         );

Hopefully this saves some folks some time in the future.


-- 

Joe Besko                      Phone:        517.432.5335
Systems Programmer             Fax:          517.353.9847
Michigan State University      E-mail:       jbesko(a)msu.edu
313 Computer Center
East Lansing, MI 48824-1042





More information about the imp mailing list