[horde] *SOLVED* Setting the user domain in authusername hook (was Migration issues - database)
Carlos Cristóbal Sabroe Yde
cris at uti.unrc.edu.ar
Fri Sep 23 12:47:33 UTC 2011
> >> > >>>>> Hi, I've made a fresh install of Horde Groupware Webmail Edition
4.
> > I
> >> > >>>>> have
> >> > >>>>> Horde GWE 1.2.9 running on another server. I'm using several IMAP
> >> > >>>>> servers so
> >> > >>>>> the users select the server to which they want to login.
> >> > >>>>>
> >> > >>>>> I tried to migrate the database part only (mysql) to the new
> > install.
> >> > >>>> Apparently everything goes well except for one thing I notice: on
the
> >> > >>>>> new
> >> > >>>>> version every information is identified by the user without
> > including
> >> > >>>>> it's
> >> > >>>>> domain (contacts, preferences, etc.). I need to teel horde to use
> > the
> >> > >>>>> full
> >> > >>>>> user id (user at domain) in the db so I can recover the previous
info.
> >> > >>>>> Can
> >> > >>>>> anybody tell me where to look to change this?
> >> > >>>
> >> > >>>> Depends on how you did
> >> > >>>> this in your old Horde version, i.e. if user? login WITHOUT the
> >> > >>>> domain part, you have to add it. Either through? the 'maildomain'
> >> > >>>> setting in imp/config/backends.local.php or by
> >> > >>>> using? a user name hook.
> >> > >>>>
> >> > >>>> Jan.
> >> > >>>
> >> > >>> Thanks Jan for your reply. It's true that users login without the
> >> > >>> domain part. I've set up the corresponding 'maildomain' for each
> >> > >>> server in imp/config/servers.php.
> >> > >>> I'm not using a hook.
> >> > >>>
> >> > >>> I'm not at the new server right now, but I'm pretty sure I've set
the
> >> > >>> "maildomain" setting in the new version as well.
> >> > >>>
> >> > >>> Cris
> >> > >>
> >> > >> I've just check my new setup and as I said, I've set the
> >> > >> 'maildomain' setting
> >> > >> as well in imp/config/backends.local.php.
> >> > >>
> >> > >> $servers['xxx'] = array(
> >> > >> 'disabled' => false,
> >> > >> 'preferred' => '',
> >> > >> 'name' => 'Descripcion',
> >> > >> 'hostspec' => 'imap.uti.unrc.edu.ar',
> >> > >> 'maildomain' => 'uti.unrc.edu.ar',
> >> > >> 'realm' => 'uti.unrc.edu.ar',
> >> > >> 'hordeauth' => 'full',
> >> > >> 'protocol' => 'imap',
> >> > >> 'port' => 143,
> >> > >> 'secure' => 'tls',
> >> > >> 'smtphost' => 'mail.uti.unrc.edu.ar.',
> >> > >> 'smtpport' => 465,
> >> > >> # 'debug' => '/tmp/imaplog',
> >> > >> 'quota' => array(
> >> > >> 'driver' => 'imap',
> >> > >> 'params' => array(
> >> > >> 'hide_when_unlimited' => true,
> >> > >> 'unit' => 'MB'
> >> > >> )
> >> > >> ),
> >> > >> 'acl' => false,
> >> > >> 'cache' => true,
> >> > >> );
> >> > >>
> >> > >>
> >> > >> What else should I look?
> >> > >
> >> > > Nothing. This works perfectly. UNLESS this isn't the backend
> >> > > configuration that's actually being used. Did you disable the
> >> > > default backend?
> >>
> >> Yes, I did
> >>
> >> >
> >> > Nevermind, the maildomain setting is just for creating default From:
> >> > addresses. You need to set up a user name hook. See
> >> > horde/config/hooks.php.dist.
> >> >
> >> > Jan.
> >> >
> >> Ok, so the behaviour has changed from previous releases.
> >> I'll adapt the example hook. How do I get the domain value to use it
there?
> >>
> >> Thanks Jan
> >>
> > I've been trying to make such hook based on the authusername
> > function, but I
> > don't know how can I get the server info to which the user will login, so
I
> > can fix the domain used. Can anybody help me?
>
> $registry->mail->server()
>
> See http://dev.horde.org/api/imp/IMP/IMP_Api.html#server
>
> Jan.
>
Thanks Jan. I've made this solution that works for me (maybe for someone else
as well):
All my servers are defined in imp/config/backends.local idetified by their
domain (we have one server for each domain we maintain):
---------------------------------------------------------------------------------
$servers['rec.unrc.edu.ar'] = array(
'disabled' => false,
'preferred' => '',
'name' => 'Area Central',
[...]
$servers['uti.unrc.edu.ar'] = array(
'disabled' => false,
'preferred' => '',
'name' => 'UTI',
[...]
I've defined this hook in config/hooks.conf:
----------------------------------------------------------------------------------
##
## 2011.09.21: Cris - Hook to add the domain part to the userId acording to
the server selection in the login page.
##
public function authusername($userId, $toHorde)
{
$domain = $GLOBALS['auth_params']['imp_server_key'];
if ($toHorde) {
return ltrim(rtrim(Horde_String::lower($userId))) . '@' . $domain;
} else {
return (substr($userId, -strlen($domain)) == $domain)
? substr(ltrim(rtrim(Horde_String::lower($userId))), 0, -
strlen($domain))
: ltrim(rtrim(Horde_String::lower($userId)));
}
}
Thanks again for your help.
Cristóbal.
More information about the horde
mailing list