Support Organization field in default identity (#1189)
This commit is contained in:
parent
3d2f1cfac4
commit
035bd6fc3b
3 changed files with 40 additions and 19 deletions
|
@ -14,8 +14,9 @@ $rcmail_config['kolab_auth_login'] = 'email';
|
|||
// If the value array contains more than one field, first non-empty will be used
|
||||
// Note: These aren't LDAP attributes, but field names in config
|
||||
// Note: If there's more than one email address, as many identities will be created
|
||||
$rcmail_config['kolab_auth_name'] = array('name', 'cn');
|
||||
$rcmail_config['kolab_auth_email'] = array('email');
|
||||
$rcmail_config['kolab_auth_name'] = array('name', 'cn');
|
||||
$rcmail_config['kolab_auth_email'] = array('email');
|
||||
$rcmail_config['kolab_auth_organization'] = array('organization');
|
||||
|
||||
// Login and password of the admin user. Enables "Login As" feature.
|
||||
$rcmail_config['kolab_auth_admin_login'] = '';
|
||||
|
|
|
@ -208,7 +208,19 @@ class kolab_auth extends rcube_plugin
|
|||
if (!empty($this->data['user_email'])) {
|
||||
// addresses list is supported
|
||||
if (array_key_exists('email_list', $args)) {
|
||||
$args['email_list'] = array_unique($this->data['user_email']);
|
||||
$email_list = array_unique($this->data['user_email']);
|
||||
|
||||
// add organization to the list
|
||||
if (!empty($this->data['user_organization'])) {
|
||||
foreach ($email_list as $idx => $email) {
|
||||
$email_list[$idx] = array(
|
||||
'organization' => $this->data['user_organization'],
|
||||
'email' => $email,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$args['email_list'] = $email_list;
|
||||
}
|
||||
else {
|
||||
$args['user_email'] = $this->data['user_email'][0];
|
||||
|
@ -256,19 +268,6 @@ class kolab_auth extends rcube_plugin
|
|||
*/
|
||||
public function authenticate($args)
|
||||
{
|
||||
$ldap = self::ldap();
|
||||
if (!$ldap || !$ldap->ready) {
|
||||
$args['abort'] = true;
|
||||
return $args;
|
||||
}
|
||||
|
||||
$rcmail = rcube::get_instance();
|
||||
$admin_login = $rcmail->config->get('kolab_auth_admin_login');
|
||||
$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 = $args['host'];
|
||||
$user = $args['user'];
|
||||
|
@ -280,6 +279,12 @@ class kolab_auth extends rcube_plugin
|
|||
return $args;
|
||||
}
|
||||
|
||||
$ldap = self::ldap();
|
||||
if (!$ldap || !$ldap->ready) {
|
||||
$args['abort'] = true;
|
||||
return $args;
|
||||
}
|
||||
|
||||
// Find user record in LDAP
|
||||
$record = $this->get_user_record($user, $host);
|
||||
|
||||
|
@ -288,7 +293,14 @@ class kolab_auth extends rcube_plugin
|
|||
return $args;
|
||||
}
|
||||
|
||||
$role_attr = $rcmail->config->get('kolab_auth_role');
|
||||
$rcmail = rcube::get_instance();
|
||||
$admin_login = $rcmail->config->get('kolab_auth_admin_login');
|
||||
$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');
|
||||
$org_attr = $rcmail->config->get('kolab_auth_organization');
|
||||
$role_attr = $rcmail->config->get('kolab_auth_role');
|
||||
|
||||
if (!empty($role_attr) && !empty($record[$role_attr])) {
|
||||
$_SESSION['user_roledns'] = (array)($record[$role_attr]);
|
||||
|
@ -389,6 +401,14 @@ class kolab_auth extends rcube_plugin
|
|||
$this->data['user_email'] = array_merge((array)$this->data['user_email'], (array)$email);
|
||||
}
|
||||
}
|
||||
// Organization name for identity (first log in)
|
||||
foreach ((array)$org_attr as $field) {
|
||||
$organization = is_array($record[$field]) ? $record[$field][0] : $record[$field];
|
||||
if (!empty($organization)) {
|
||||
$this->data['user_organization'] = $organization;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Log "Login As" usage
|
||||
if (!empty($origname)) {
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
<email>machniak@kolabsys.com</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2012-12-04</date>
|
||||
<date>2012-12-19</date>
|
||||
<version>
|
||||
<release>0.5</release>
|
||||
<release>0.6</release>
|
||||
<api>0.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
|
|
Loading…
Add table
Reference in a new issue