[dev] selecting IMAP server based on username

Aleksandar Milivojevic alex at milivojevic.org
Tue Aug 30 12:55:04 PDT 2005


Quoting Jan Schneider <jan at horde.org>:

> Zitat von Aleksandar Milivojevic <alex at milivojevic.org>:
>
>> Quoting Aleksandar Milivojevic <alex at milivojevic.org>:
>>
>>> I've patched horde/config/conf.xml and horde/imp/lib/IMP.php files.  In
>>> conf.xml, I've added configuration option $conf[hooks][imapserver]
>>> to support
>>> custom _hook_imp_imapserver function.  Then, I placed call to it at
>>> the start
>>> of IMP::getAutoLoginServer() (see attached diff).
>>
>> Forgot to include diffs...
>
> Try this instead, doesn't even require a code change:
> http://wiki.horde.org/ImapSelect

My first idea was exactly the same.  Use preauthenticate hook.

However, it does not work.

It does not work because IMP_Session::CreateSession() is called after
pre/post-authenticate hooks.  It will overwrite whatever values you place in
$_SESSION['imp'] with what it thinks is correct server (or the caller function
thinks is correct server).  Most likely it will be the value returned by
IMP::getAutoLoginServer(), which is exactly where I placed call to my 
new hook.

It might work if Horde is configured to use IMP for authentication (haven't
tested that case, I'm having Horde perform its own auth, and set hordeauth to
true in imp/config/servers.php).

IMHO, the "right" way of doing it is to make sure IMP_Session::createSession()
is called with correct $server argument in the first place.

If change of code to accomodate this functionality is a big no-no, another
possibility to investigate would be calling IMP_Session::createSession() from
the preauthenticate hook, however I'm not sure what consequences is this going
have (also, I'd need to include imp/lib/Session.php and define IMP_BASE inside
the hook, hopefully not going to break anything down the road).  There's also
$args parameter for IMP_Session::createSession() which I have no idea what to
set to (esp when called from pre/post-auth hooks).  Is there going to be
subsequent call to IMP_Session::createSession() from somewhere else in
Horde/IMP code that might overwrite data from the first call (from my 
hook)? The createSession isn't checking if any values in 
$_SESSION['imp'] are already
set, and if anything calls it later on, most likely the values would get
overwritten with (incorrect) defaults.  Which is basically the reason I did it
the way I did it, making sure createSession is passed the correct server in
$server.

Alex

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




More information about the dev mailing list