[imp] adding realm in IMP5

Andrew Morgan morgan at orst.edu
Mon Aug 13 17:50:55 UTC 2012


On Wed, 8 Aug 2012, Andrew Morgan wrote:

> On Wed, 8 Aug 2012, Michael M Slusarz wrote:
>
>> Quoting Andrew Morgan <morgan at orst.edu>:
>> 
>>> Is there a recommended way to replicate/replace the old "realm" parameter 
>>> in IMP5?  I have 2 issues I am trying to solve:
>>> 
>>> 1. I have 8 different IMAP servers.  2 of them are different IMAP servers, 
>>> but I want to share user preferences between them (we are migrating slowly 
>>> over time from an old IMAP server to a new IMAP server)
>>> 
>>> 2. Username is not unique between all 8 IMAP servers, so in the 
>>> preferences backend (MySQL) I need to have a realm/domain appended to the 
>>> username. For example, pref_uid should contain "morgan at orst.edu" instead 
>>> of "morgan".
>>> 
>>> In IMP4, I used the realm parameter to accomplish both goals.  I have been 
>>> reading the backends.php and hooks.php files, but I don't see how to get a 
>>> realm/domain appended to the pref_uid.
>> 
>> Preferences are stored by the current Horde username.  This can be altered 
>> from the authentication username by using the 'authusername' hook.
>
> Is the 'authusername' hook only in Horde or is it available in IMP as well?
>
> How can I determine which IMAP server the user selected from within the 
> 'authusername' hook?  Does $credentials['server'] contain it?  Once I have 
> the server, can I access the backends.local.php $server['foo'] values?

I have been playing around with this some more.  I found the $credentials 
array passed to IMP's preauthenticate hook contains:

'password' => (the user's password)
'mode' => 'traditional'
'imp_server_key' => 'onid'

"onid" is the key in my backends.local.php file for one of my IMAP 
servers.

However, I can't seem to access the $servers array.  I tried just logging 
it:

   Horde::logMessage("IMP Server Realm: " .
     $servers[$credentials['imp_server_key']]['realm'], 'NOTICE');

Which produced an error in the log:

   HORDE: [horde] PHP ERROR: Undefined variable: servers [pid 1217 on line
     36 of "/var/www-test/horde/imp/config/hooks.php"]

I don't know enough about the structure of IMP.  Is there a way to access 
the $servers array or some API call I can make to access it?


My intention is to make the Horde ID be a fully-qualified name 
(user at example.com), then make an authusername hook to strip the domain off 
for authentication.

Thanks,
 	Andy


More information about the imp mailing list