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
|
@ -16,6 +16,7 @@ $rcmail_config['kolab_auth_login'] = 'email';
|
||||||
// Note: If there's more than one email address, as many identities will be created
|
// 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_name'] = array('name', 'cn');
|
||||||
$rcmail_config['kolab_auth_email'] = array('email');
|
$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.
|
// Login and password of the admin user. Enables "Login As" feature.
|
||||||
$rcmail_config['kolab_auth_admin_login'] = '';
|
$rcmail_config['kolab_auth_admin_login'] = '';
|
||||||
|
|
|
@ -208,7 +208,19 @@ class kolab_auth extends rcube_plugin
|
||||||
if (!empty($this->data['user_email'])) {
|
if (!empty($this->data['user_email'])) {
|
||||||
// addresses list is supported
|
// addresses list is supported
|
||||||
if (array_key_exists('email_list', $args)) {
|
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 {
|
else {
|
||||||
$args['user_email'] = $this->data['user_email'][0];
|
$args['user_email'] = $this->data['user_email'][0];
|
||||||
|
@ -256,19 +268,6 @@ class kolab_auth extends rcube_plugin
|
||||||
*/
|
*/
|
||||||
public function authenticate($args)
|
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
|
// get username and host
|
||||||
$host = $args['host'];
|
$host = $args['host'];
|
||||||
$user = $args['user'];
|
$user = $args['user'];
|
||||||
|
@ -280,6 +279,12 @@ class kolab_auth extends rcube_plugin
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ldap = self::ldap();
|
||||||
|
if (!$ldap || !$ldap->ready) {
|
||||||
|
$args['abort'] = true;
|
||||||
|
return $args;
|
||||||
|
}
|
||||||
|
|
||||||
// Find user record in LDAP
|
// Find user record in LDAP
|
||||||
$record = $this->get_user_record($user, $host);
|
$record = $this->get_user_record($user, $host);
|
||||||
|
|
||||||
|
@ -288,6 +293,13 @@ class kolab_auth extends rcube_plugin
|
||||||
return $args;
|
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');
|
||||||
|
$org_attr = $rcmail->config->get('kolab_auth_organization');
|
||||||
$role_attr = $rcmail->config->get('kolab_auth_role');
|
$role_attr = $rcmail->config->get('kolab_auth_role');
|
||||||
|
|
||||||
if (!empty($role_attr) && !empty($record[$role_attr])) {
|
if (!empty($role_attr) && !empty($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);
|
$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
|
// Log "Login As" usage
|
||||||
if (!empty($origname)) {
|
if (!empty($origname)) {
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
<email>machniak@kolabsys.com</email>
|
<email>machniak@kolabsys.com</email>
|
||||||
<active>yes</active>
|
<active>yes</active>
|
||||||
</lead>
|
</lead>
|
||||||
<date>2012-12-04</date>
|
<date>2012-12-19</date>
|
||||||
<version>
|
<version>
|
||||||
<release>0.5</release>
|
<release>0.6</release>
|
||||||
<api>0.1</api>
|
<api>0.1</api>
|
||||||
</version>
|
</version>
|
||||||
<stability>
|
<stability>
|
||||||
|
|
Loading…
Add table
Reference in a new issue