[horde] USERNAME Hook - help required.

Jan Schneider jan at horde.org
Fri Aug 16 08:57:44 UTC 2013


Zitat von ANANT S ATHAVALE <asa at isac.gov.in>:

> ----- Message from Jan Schneider <jan at horde.org> ---------
>    Date: Fri, 16 Aug 2013 09:44:46 +0200
>    From: Jan Schneider <jan at horde.org>
> Subject: Re: [horde] USERNAME Hook - help required.
>      To: horde at lists.horde.org
>
>
>> Zitat von ANANT S ATHAVALE <asa at isac.gov.in>:
>>
>>> Dear List,
>>>
>>> My authentication is based on LDAP which is case insensitive.  I  
>>> want username to be always lower case and also if there any blank  
>>> space (either at starting or trailing to be trimmed)
>>>
>>> I have written the hook as below.  Please suggest, if it is wrong:
>>>
>>>   public function authusername($userId, $toHorde)
>>>   {
>>>       return $toHorde
>>>           ? trim(Horde_String::lower($userId) . '@isac.gov.in')
>>>           : trim($userId) . '@isac.gov.in';
>>>   }
>>>
>>> I want basically that the preferences to be stored with  
>>> username at isac.gov.in, where username should be always in lower  
>>> case and it should not have any space characters.
>>>
>>> Please suggest.
>>
>> It also adds the domain part, not sure if this is intended.
>
> This is intended as in my Horde 3 setup, all users preferences are  
> already stored in the form 'username at domain'.
>
>>
>> More important though is the reverse direction, which you have  
>> wrong. The trim() is no longer necessary because you already  
>> trimmed in the other direction. And you have to *remove* the domain  
>> part, not add them another time.
>
> OK.
>
> Will the following hook be OK?
>
>     public function authusername($userId, $toHorde)
>     {
>         return $toHorde
>             ? trim(Horde_String::lower($userId)) . '@isac.gov.in'
>             : $userId;
>     }

Not quite, you still need to strip the domain part from the name in  
the 2nd case. See the examples in hooks.php.dist how to do this.
-- 
Jan Schneider
The Horde Project
http://www.horde.org/



More information about the horde mailing list