an other imap login type: uidNumber using eg. u123@domain AND setting it, if ldap schema supports mailbox-attribute

This commit is contained in:
Ralf Becker 2010-08-31 10:15:24 +00:00
parent 6b474b08e2
commit be5bffcc01
3 changed files with 58 additions and 17 deletions

View File

@ -337,20 +337,26 @@ class defaultimap extends Net_IMAP
*/
function getMailBoxUserName($_username)
{
if ($this->loginType == 'email')
switch ($this->loginType)
{
$_username = $_username;
$accountID = $GLOBALS['egw']->accounts->name2id($_username);
$accountemail = $GLOBALS['egw']->accounts->id2name($accountID,'account_email');
//$accountemail = $GLOBALS['egw']->accounts->read($GLOBALS['egw']->accounts->name2id($_username,'account_email'));
if (!empty($accountemail))
{
list($lusername,$domain) = explode('@',$accountemail,2);
if (strtolower($domain) == strtolower($this->domainName) && !empty($lusername))
case 'email':
$_username = $_username;
$accountID = $GLOBALS['egw']->accounts->name2id($_username);
$accountemail = $GLOBALS['egw']->accounts->id2name($accountID,'account_email');
//$accountemail = $GLOBALS['egw']->accounts->read($GLOBALS['egw']->accounts->name2id($_username,'account_email'));
if (!empty($accountemail))
{
$_username = $lusername;
list($lusername,$domain) = explode('@',$accountemail,2);
if (strtolower($domain) == strtolower($this->domainName) && !empty($lusername))
{
$_username = $lusername;
}
}
}
break;
case 'uidNumber':
$_username = 'u'.$GLOBALS['egw']->accounts->name2id($_username);
break;
}
return $_username;
}
@ -370,7 +376,7 @@ class defaultimap extends Net_IMAP
}
$_username = $this->getMailBoxUserName($_username);
if($this->loginType == 'vmailmgr' || $this->loginType == 'email') {
if($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber') {
$_username .= '@'. $this->domainName;
}

View File

@ -141,10 +141,10 @@ class emailadmin_smtp_ldap extends defaultsmtp
{
$newData[$this->config['mail_enable_attr']] = $this->config['mail_enabled'];
}
// does schema support an explicit mailbox name --> set it with $uid@$domain
// does schema support an explicit mailbox name --> set it
if ($this->config['mailbox_attr'])
{
$newData[$this->config['mailbox_attr']] = $_hookValues['account_lid'].'@'.$this->defaultDomain;
$newData[$this->config['mailbox_attr']] = self::mailbox_addr($_hookValues);
}
if (!($ret = ldap_mod_replace($ds, $accountDN, $newData)) || $this->debug)
@ -419,4 +419,38 @@ class emailadmin_smtp_ldap extends defaultsmtp
return ldap_modify ($ds, $allValues[0]['dn'], $newData);
}
}
/**
* Build mailbox address for given account and mail_addr_type
*
* @param int|array $account account_id or whole account array with values for keys
* @param string $domain=null domain, default use $this->defaultDomain
* @param string $mail_login_type=null standard(uid), vmailmgr(uid@domain), email or uidNumber,
* default use $GLOBALS['egw_info']['server']['mail_login_type']
* @return string
*/
static public function mailbox_addr($account,$domain=null,$mail_login_type=null)
{
if (is_null($domain)) $domain = $this->domain;
if (is_null($mail_login_type)) $mail_login_type = $GLOBALS['egw_info']['server']['mail_login_type'];
switch($mail_login_type)
{
case 'email':
return is_array($account) ? $account['account_email'] : $GLOBALS['egw']->accounts->id2name($account,'account_email');
case 'uidNumber':
if (is_array($account)) $account = $account['account_id'];
return 'u'.$account.'@'.$domain;
case 'standard':
if (is_array($account)) $account = $account['account_id'];
return $GLOBALS['egw']->accounts->id2name($account);
case 'vmailmgr':
default:
if (is_array($account)) $account = $account['account_id'];
return $GLOBALS['egw']->accounts->id2name($account).'@'.$domain;
}
}
}

View File

@ -233,9 +233,10 @@ class emailadmin_ui extends emailadmin_bo
{
//error_log(__METHOD__.' called with:'.$serverclass." with capabilities:".parent::$IMAPServerType[$serverclass]['imapcapabilities']);
$returnval = array(
'standard' =>lang('username (standard)'),
'vmailmgr' =>lang('username@domainname (Virtual MAIL ManaGeR)'),
'admin' =>lang('Username/Password defined by admin'),
'standard' => lang('username (standard)'),
'vmailmgr' => lang('username@domainname (Virtual MAIL ManaGeR)'),
'admin' => lang('Username/Password defined by admin'),
'uidNumber' => lang('UserId@domain eg. u1234@domain'),
);
if (!empty($serverclass) && stripos(constant($serverclass.'::CAPABILITIES'),'logintypeemail') !== false)
{