[horde] Composite authentication driver not invoking hooks calls?
Kevin M. Myer
kevin_myer at iu13.org
Thu Feb 9 13:48:49 PST 2006
Hello,
I have recently been testing the composite authentication driver and
using the browser select toggle to switch between a full Horde portal
for desktop browsers, and just MIMP for mobile browsers. The toggle is
between LDAP (full Horde) and letting just MIMP handle logins (mobile
browser). This works well, with one exception: I am using a hook to
set the from_addr preference. Using LDAP as the authentication driver,
the from_addr value gets set properly. If I switch to using the
composite driver, the from_addr value no longer gets set properly, and
IMP shows "INVALID_ADDRESS at .SYNTAX-ERROR." for the address, despite the
fact that after the browser detection is done, the authentication
driver values are essentially the same under the composite driver, as
they were using just the LDAP driver.
So why does using the composite driver not generate a hook call to
lookup the from_addr, but using the LDAP driver does?
I've verified this behavior in both Horde 3.0.9 and HEAD.
Here is my composite config:
$conf['auth']['driver'] = 'composite';
/* CONFIG END. DO NOT CHANGE ANYTHING IN OR BEFORE THIS LINE. */
$conf['auth']['params']['drivers'] = array(
'ldap' => array('driver' => 'ldap',
'params' => array('hostspec' =>
'directory2.example.com directory1.example.com',
'basedn' =>
'ou=People,dc=example,dc=com',
'version' => '3',
'uid' => 'mail',
'objectclass' => array('person'),
'filter_type' => 'objectclass')),
'mimp' => array('driver' => 'application',
'params' => array('app' => 'mimp')));
$conf['auth']['params']['loginscreen_switch'] = '_horde_select_loginscreen';
if (!function_exists('_horde_select_loginscreen')) {
function _horde_select_loginscreen()
{
require_once 'Horde/Browser.php';
$browser = new Browser();
if ($browser->isMobile()) {
return 'mimp';
}
return 'ldap';
}
}
With those settings, a full browser gets a full portal and a mobile
browser gets just mimp. But from_addr is not set properly.
With the following settings, from_addr is properly set by the hook:
$conf['auth']['params']['hostspec'] = 'directory2.example.com
directory1.example.com';
$conf['auth']['params']['basedn'] = 'ou=People,dc=iu13,dc=example,dc=com';
$conf['auth']['params']['version'] = '3';
$conf['auth']['params']['uid'] = 'mail';
$conf['auth']['params']['objectclass'] = array('person');
$conf['auth']['params']['filter_type'] = 'objectclass';
$conf['auth']['driver'] = 'ldap';
The horde/config/pref.php setting for from_addr:
// user preferred email address for From: line
$_prefs['from_addr'] = array(
'value' => '',
'locked' => true,
'shared' => true,
'type' => 'text',
'desc' => _("Your From: address:"),
'hook' => true
);
The hook for setting from_addr:
if (!function_exists('_prefs_hook_from_addr')) {
function _prefs_hook_from_addr($uid = null)
{
global $conf;
$domain_name = 'example.com';
$ldapServer = 'directory2.example.com directory1.example.com';
$ldapPort = '389';
$searchBase = 'ou=People,dc=example,dc=com';
$ds = @ldap_connect($ldapServer, $ldapPort);
if (is_null($uid)) {
$uid = Auth::getAuth();
}
if (@ldap_bind($ds)) {
$searchResult = @ldap_list($ds, $searchBase,
$conf['auth']['params']['uid'] . '=' . $uid);
}
$information = @ldap_get_entries($ds, $searchResult);
// derive the email address if possible
if ($information[0]['mail'][0] != '') {
$emailname = $information[0]['mail'][0];
} else {
$emailname = $information[0]['uid'][0] . '@' . $domain_name;
}
ldap_close($ds);
return $emailname;
}
}
Kevin
--
Kevin M. Myer
Senior Systems Administrator
Lancaster-Lebanon Intermediate Unit 13 http://www.iu13.org
More information about the horde
mailing list