Is there anyone using multiple IMAP servers with Horde4/IMP5?

I have to find a way to authenticate to the IMAP server with a bare username, but store preferences in the Horde database with a domain/realm.

        Andy

On Mon, 13 Aug 2012, Andrew Morgan wrote:

On Mon, 13 Aug 2012, Andrew Morgan wrote:

On Wed, 8 Aug 2012, Andrew Morgan wrote:

On Wed, 8 Aug 2012, Michael M Slusarz wrote:

Quoting Andrew Morgan <[email protected]>:

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 "[email protected]" 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 ([email protected]), then make an authusername hook to strip the domain off for authentication.

Okay, after flailing around for an hour, I've discovered that I should be using the 'authusername' hook, like Michael said. I tried playing with preauthenticate and postauthenticate hooks, but that just left me unable to login whenever I appended the realm.

If I hardcode a realm in authusername, I can make things work the way I want:

    public function authusername($userId, $toHorde)
    {
     if ($toHorde) {
               Horde::logMessage("toHorde userId: $userId", 'NOTICE');
             return $userId . '@onid.orst.edu';
     } else {
             // strip the domain off
               $userId = substr($userId, 0, strpos($userId, '@'));
               Horde::logMessage("toHorde userId: $userId", 'NOTICE');
             return $userId;
     }
   }


However, what I really need to do is lookup the realm on the fly. Is there some session parameter I can use as a key to lookup the $servers entry?

I really need the ability to qualify usernames with realms!

Thanks,
        Andy
--
imp mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]

--
imp mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]

Reply via email to