* Mail: implement Exchange login-type "domain/username"

This commit is contained in:
ralf 2023-12-15 17:12:47 +02:00
parent 3fcea5b925
commit 3dbb579239
5 changed files with 19 additions and 6 deletions

View File

@ -129,6 +129,7 @@ class admin_mail
//'admin' => 'Username/Password defined by admin', //'admin' => 'Username/Password defined by admin',
'uidNumber' => 'UserId@domain eg. u1234@domain', 'uidNumber' => 'UserId@domain eg. u1234@domain',
'email' => 'EMail-address from account', 'email' => 'EMail-address from account',
'domain/username' => 'Exchange: domain/username',
); );
/** /**

View File

@ -60,7 +60,7 @@ use Horde_Mail_Transport_Smtphorde;
* @property-read string $acc_smtp_pw_enc Credentials::(CLEARTEXT|USER|SYSTEM) * @property-read string $acc_smtp_pw_enc Credentials::(CLEARTEXT|USER|SYSTEM)
* @property-read string $acc_smtp_type smtp class to use, default Smtp * @property-read string $acc_smtp_type smtp class to use, default Smtp
* @property-read string $acc_imap_type imap class to use, default Imap * @property-read string $acc_imap_type imap class to use, default Imap
* @property-read string $acc_imap_logintype how to construct login-name standard, vmailmgr, admin, uidNumber * @property-read string $acc_imap_logintype how to construct login-name standard, vmailmgr, admin, uidNumber, domain/username
* @property-read string $acc_domain domain name * @property-read string $acc_domain domain name
* @property-read boolean $acc_imap_administration enable administration * @property-read boolean $acc_imap_administration enable administration
* @property-read string $acc_imap_admin_username * @property-read string $acc_imap_admin_username

View File

@ -336,6 +336,10 @@ class Credentials
$username = 'u'.$GLOBALS['egw_info']['user']['account_id'].'@'.$data['acc_domain']; $username = 'u'.$GLOBALS['egw_info']['user']['account_id'].'@'.$data['acc_domain'];
break; break;
case 'domain/username':
$username = $data['acc_domain'].'/'.$GLOBALS['egw_info']['user']['account_lid'];
break;
case 'admin': case 'admin':
// data should have been stored in credentials table // data should have been stored in credentials table
throw new Api\Exception\AssertionFailed('data[acc_imap_logintype]=admin and no stored username/password for data[acc_id]='.$data['acc_id'].'!'); throw new Api\Exception\AssertionFailed('data[acc_imap_logintype]=admin and no stored username/password for data[acc_id]='.$data['acc_id'].'!');

View File

@ -47,7 +47,7 @@ use Horde_Imap_Client_Mailbox_List;
* @property-read string $acc_folder_template template folder * @property-read string $acc_folder_template template folder
* @property-read string $acc_folder_junk junk/spam folder * @property-read string $acc_folder_junk junk/spam folder
* @property-read string $acc_imap_type imap class to use, default Imap * @property-read string $acc_imap_type imap class to use, default Imap
* @property-read string $acc_imap_logintype how to construct login-name standard, vmailmgr, admin, uidNumber * @property-read string $acc_imap_logintype how to construct login-name standard, vmailmgr, admin, uidNumber, domain/username
* @property-read string $acc_domain domain name * @property-read string $acc_domain domain name
* @property-read boolean $acc_imap_administration enable administration * @property-read boolean $acc_imap_administration enable administration
* @property-read string $acc_imap_admin_username * @property-read string $acc_imap_admin_username
@ -67,7 +67,7 @@ class Imap extends Horde_Imap_Client_Socket implements Imap\PushIface
* @var array * @var array
*/ */
static public $default_params = array( static public $default_params = array(
//'debug' => '/tmp/imap.log', // uncomment to log communication with IMAP server 'debug' => '/var/lib/egroupware/imap.log', // uncomment to log communication with IMAP server
//'debug_literal' => true, // uncomment to log mail contents returned by IMAP server //'debug_literal' => true, // uncomment to log mail contents returned by IMAP server
'cache' => true, // default caching via Cache / Api\Cache 'cache' => true, // default caching via Cache / Api\Cache
); );
@ -100,7 +100,7 @@ class Imap extends Horde_Imap_Client_Socket implements Imap\PushIface
protected $mbAvailable; protected $mbAvailable;
/** /**
* Login type: 'uid', 'vmailmgr', 'uidNumber', 'email' * Login type: 'uid', 'vmailmgr', 'uidNumber', 'email', 'domain/username'
* *
* @var string * @var string
*/ */
@ -1164,6 +1164,10 @@ class Imap extends Horde_Imap_Client_Socket implements Imap\PushIface
$_username = 'u'.$accountID; $_username = 'u'.$accountID;
break; break;
case 'domain/username':
$_username = $this->acc_domain.'/'.$_username;
break;
default: default:
if (empty($this->loginType)) if (empty($this->loginType))
{ {

View File

@ -229,7 +229,7 @@ class Smtp
* *
* @param int|array $account account_id or whole account array with values for keys * @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 $domain=null domain, default use $this->defaultDomain
* @param string $mail_login_type=null standard(uid), vmailmgr(uid@domain), email or uidNumber, * @param string $mail_login_type=null standard(uid), vmailmgr(uid@domain), email, uidNumber or domain/username,
* default use $this->loginType * default use $this->loginType
* @return string * @return string
*/ */
@ -245,7 +245,7 @@ class Smtp
* *
* @param int|array $account account_id or whole account array with values for keys * @param int|array $account account_id or whole account array with values for keys
* @param string $domain|null domain * @param string $domain|null domain
* @param string $mail_login_type=null standard(uid), vmailmgr(uid@domain), email or uidNumber * @param string $mail_login_type=null standard(uid), vmailmgr(uid@domain), email, uidNumber or domain/username
* @return string|null null if no domain given but required by $mail_login_type * @return string|null null if no domain given but required by $mail_login_type
*/ */
static public function mailbox_address($account, string $domain=null, string $mail_login_type=null) static public function mailbox_address($account, string $domain=null, string $mail_login_type=null)
@ -266,6 +266,10 @@ class Smtp
$mbox = is_array($account) ? $account['account_lid'] : $GLOBALS['egw']->accounts->id2name($account); $mbox = is_array($account) ? $account['account_lid'] : $GLOBALS['egw']->accounts->id2name($account);
break; break;
case 'domain/username':
$mbox = $domain.'/'.(is_array($account) ? $account['account_lid'] : $GLOBALS['egw']->accounts->id2name($account));
break;
case 'vmailmgr': case 'vmailmgr':
default: default:
if (empty($domain)) return null; if (empty($domain)) return null;