[imp] figured it out :)

Jeremy Gault jeremy@pointlessmedia.org
Wed, 12 Jun 2002 13:24:06 -0400


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi everyone,

	Well, after some more hair pulling and some lunch, I was finally
able to make it do what I wanted.  (The beauty of Open Source.)  Since
it wasn't exactly easy to figure out, I'm posting it here for everyone's
benefit/future reference/etc. :)

	It came down to the fact that I needed to use the vinfo hooks,
which I had experimented with before (using the example function) and
had no luck.  So, I decided to roll my own function based off of the
example there.  It comes out something like this:

if(!function_exists('imp_get_vinfo')) {
  function imp_get_vinfo ($type = 'username') {
    global $conf, $imp, $server, $servers;
    include IMP_BASE . '/config/servers.php';
    if($type == 'username') {
      if(!empty($servers[$server]['realm'])) {
        $vinfo_return_user = $imp['user'] . '@' .
          $servers[$server]['realm'];
      } else {
        $vinfo_return_user = $imp['user]';
      }
      return $vinfo_return_user;
    } elseif {$type == "vdomain") {
      return $vdomain;
    } else {
      return new PEAR_Error('invalid type: ' . $type);
    }
  }
}

	It's not as clean as I would like it to be, but so far it does
appear to get the job done.  I had to include the servers.php file in
order to get the $servers array in, so that I can find out if the said
server has a realm.  (As you can see, I tried adding $servers to the
global line, and it didn't work.)  The $server variable is the server
the user is trying to log into.

	Basically, this little gem checks to see if a realm is set for
the server they're using.  If so, it creates a user@realm and returns it
back for authentication purposes.  If there is no realm set, it just
returns the username.

	One other slight modification was required to make this work.
In the lib/IMP.php file, one must move some code around.  There are two
lines a bit below the vinfo calls (in IMP.php) that read:

$server = Horde::getFormData('server', '');
$realm = Horde::getFormData('relam', '');

	The first line (to define $server) needs to be moved UP a bit,
so that it is BEFORE the call to the vinfo functions.  (That way, the
$server variable can be made available to the function, which is
important that it is.)

	So far, it seems to work well.  I can authenticate onto virtual
domains and standard ones, by either defining or not defining a realm.

	Either this is the way it should have been done, or I just
reinvented the wheel... :)

		Jeremy

- -- 
Jeremy Gault            <jeremy@pointlessmedia.org>
Operations Manager, Pointless Media Group
- ------------------------------------------------------
 Finagle's Fourth Law - Once a job is fouled up, anything done to improve
 it only makes it worose.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9B4O2zvEyOctGzUcRAk8ZAJ9WrxKV5Kb3f+Te5toz5Dg4NyfP+QCeKss/
x2VJCq4KCok3JqKyCpR4njo=
=wo1C
-----END PGP SIGNATURE-----