[horde] Retrieving logged in user
Paul Gargan
pgargan at nexgenfs.com
Thu Apr 22 10:53:38 PDT 2004
Hi,
I'm running Horde 2.2.5 and IMP 3.2.3 under PHP 4.3.4, Apache 1.3.29
Horde is using IMP as a login manager, via config/registry.php:
$this->registry['auth']['login'] = 'imp';
$this->registry['auth']['logout'] = 'imp';
I'm trying to use an OpenLDAP backend as a preferences container.
To do this, I'm editing config/horde.php and filling in the required values:
$conf['prefs']['driver'] = 'ldap';
$conf['prefs']['params']['hostspec'] = 'ldap.example.com';
// and so on.
IMP is authenticating against our IMAP server (login IDs are in the form
username at example.com). However, the DNs used for binding to the LDAP
server to store preferences are a bit different.
So, in config/horde.php, I'm trying to define a function to retrieve the
logged-in username via Auth::getAuth() and munge it accordingly. I have:
require_once HORDE_BASE . '/lib/Auth.php';
if (!function_exists('mungeIt')) {
function mungeIt($email) {
/* Do stuff that munges $email */
return $email;
}
}
$conf['prefs']['driver'] = 'ldap';
$conf['prefs']['params']['hostspec'] = 'ldap.example.com';
$conf['prefs']['params']['port'] = '389';
$conf['prefs']['params']['basedn'] = 'dc=example,dc=com';
$conf['prefs']['params']['uid'] = 'cn';
$conf['prefs']['params']['username'] = mungeIt(Auth::getAuth());
$conf['prefs']['params']['password'] =
Auth::getCredential('password');
However, when this runs, Auth::getAuth() is returning false:
The actual code in the Auth class is as follows:
function getAuth() {
if (isset($_SESSION['__auth'])) {
if (!empty($_SESSION['__auth']['authenticated']) &&
!empty($_SESSION['__auth']['userID'])) {
return $_SESSION['__auth']['userID'];
}
}
// Try transparent authentication now.
global $conf;
$auth = &Auth::singleton($conf['auth']['driver'],
$conf['auth']['params']);
if ($auth->hasCapability('transparent') &&
$auth->transparent()) {
return $_SESSION['__auth']['userID'];
}
return false;
}
Debugging statements I included suggest that $_SESSION isn't being set
at all.
So, question:
What is the correct way to retrieve the username of the currently logged
in user, for use with code snippets in various config files?
Thanks in advance.
Paul.
More information about the horde
mailing list