Support array of fields in kolab_auth_name/kolab_auth_email config,
use first non-empty value (#1012). Fix lost kolab_auth_email handling.
This commit is contained in:
parent
ad9a89eece
commit
a7c06ff2fd
3 changed files with 26 additions and 10 deletions
|
@ -10,9 +10,11 @@ $rcmail_config['kolab_auth_filter'] = '(&(objectClass=kolabInetOrgPerson)(|(uid=
|
|||
// Use this fields (from fieldmap configuration) to get authentication ID
|
||||
$rcmail_config['kolab_auth_login'] = 'email';
|
||||
|
||||
// Use this fields (from fieldmap configuration) for default identity
|
||||
$rcmail_config['kolab_auth_name'] = 'name';
|
||||
$rcmail_config['kolab_auth_email'] = 'email';
|
||||
// Use this fields (from fieldmap configuration) for default identity.
|
||||
// Note: These aren't LDAP attributes, but field names in config
|
||||
// If the value array contains more than one field, first non-empty will be used
|
||||
$rcmail_config['kolab_auth_name'] = array('name', 'cn');
|
||||
$rcmail_config['kolab_auth_email'] = array('email');
|
||||
|
||||
// Login and password of the admin user. Enables "Login As" feature.
|
||||
$rcmail_config['kolab_auth_admin_login'] = '';
|
||||
|
|
|
@ -261,6 +261,7 @@ class kolab_auth extends rcube_plugin
|
|||
$admin_pass = $rcmail->config->get('kolab_auth_admin_password');
|
||||
$login_attr = $rcmail->config->get('kolab_auth_login');
|
||||
$name_attr = $rcmail->config->get('kolab_auth_name');
|
||||
$email_attr = $rcmail->config->get('kolab_auth_email');
|
||||
|
||||
// get username and host
|
||||
$host = rcube_parse_host($args['host']);
|
||||
|
@ -357,18 +358,31 @@ class kolab_auth extends rcube_plugin
|
|||
// Store UID in session for use by other plugins
|
||||
$_SESSION['kolab_uid'] = is_array($record['uid']) ? $record['uid'][0] : $record['uid'];
|
||||
|
||||
// Set credentials
|
||||
// Set user login
|
||||
if ($login_attr) {
|
||||
$this->data['user_login'] = is_array($record[$login_attr]) ? $record[$login_attr][0] : $record[$login_attr];
|
||||
}
|
||||
if ($name_attr) {
|
||||
$this->data['user_name'] = is_array($record[$name_attr]) ? $record[$name_attr][0] : $record[$name_attr];
|
||||
}
|
||||
|
||||
if ($this->data['user_login']) {
|
||||
$args['user'] = $this->data['user_login'];
|
||||
}
|
||||
|
||||
// User name for identity (first log in)
|
||||
foreach ((array)$name_attr as $field) {
|
||||
$name = is_array($record[$field]) ? $record[$field][0] : $record[$field];
|
||||
if (!empty($name)) {
|
||||
$this->data['user_name'] = $name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// User email for identity (first log in)
|
||||
foreach ((array)$email_attr as $field) {
|
||||
$email = is_array($record[$field]) ? $record[$field][0] : $record[$field];
|
||||
if (!empty($email)) {
|
||||
$this->data['user_email'] = $email;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Log "Login As" usage
|
||||
if (!empty($origname)) {
|
||||
write_log('userlogins', sprintf('Admin login for %s by %s from %s',
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
<email>machniak@kolabsys.com</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2012-02-29</date>
|
||||
<date>2012-10-08</date>
|
||||
<version>
|
||||
<release>0.2</release>
|
||||
<release>0.3</release>
|
||||
<api>0.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
|
|
Loading…
Add table
Reference in a new issue