mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-23 22:01:47 +01:00
improve search for best auth Method, if you try one, the server is not suporting
This commit is contained in:
parent
cfbe85603f
commit
582a136219
@ -110,7 +110,10 @@ class Net_IMAP extends Net_IMAPProtocol {
|
||||
*/
|
||||
function login($user, $pass, $useauthenticate = true, $selectMailbox=true)
|
||||
{
|
||||
//error_log(__METHOD__.':'.$user.','.$pass.','.$useauthenticate.','.$selectMailbox);
|
||||
if ( $useauthenticate ){
|
||||
//$useauthenticate = 'LOGIN';
|
||||
//error_log(__METHOD__.':'.'about to authenticate');
|
||||
//$useauthenticate is a string if the user hardcodes an AUTHMethod
|
||||
// (the user calls $imap->login("user","password","CRAM-MD5"); for example!
|
||||
|
||||
@ -125,6 +128,7 @@ class Net_IMAP extends Net_IMAPProtocol {
|
||||
$this->_serverAuthMethods=null;
|
||||
}
|
||||
if($this->_serverAuthMethods == null || count($commonMethods) == 0 || $this->supportedAuthMethods == null ){
|
||||
//error_log(__METHOD__.":The server does not have any auth method, so I try LOGIN");
|
||||
// The server does not have any auth method, so I try LOGIN
|
||||
if ( PEAR::isError( $ret = $this->cmdLogin( $user, $pass ) ) ) {
|
||||
return $ret;
|
||||
@ -137,6 +141,7 @@ class Net_IMAP extends Net_IMAPProtocol {
|
||||
return new PEAR_Error($ret["RESPONSE"]["CODE"] . ", " . $ret["RESPONSE"]["STR_CODE"]);
|
||||
}
|
||||
}else{
|
||||
//error_log(__METHOD__.':'.'about to use plain login');
|
||||
//The user request "PLAIN" auth, we use the login command
|
||||
if ( PEAR::isError( $ret = $this->cmdLogin( $user, $pass ) ) ) {
|
||||
return $ret;
|
||||
|
@ -716,15 +716,25 @@ class Net_IMAPProtocol {
|
||||
}else{
|
||||
$methods = $this->supportedAuthMethods;
|
||||
}
|
||||
|
||||
//error_log(__METHOD__.' Supported Methods:'.array2string($methods).' Server methods:'.array2string($this->_serverAuthMethods));
|
||||
if( ($methods != null) && ($this->_serverAuthMethods != null)){
|
||||
foreach ( $methods as $method ) {
|
||||
if ( in_array( $method , $this->_serverAuthMethods ) ) {
|
||||
//error_log(__METHOD__.' choose:'.$method);
|
||||
return $method;
|
||||
}
|
||||
}
|
||||
$serverMethods=implode(',' ,$this->_serverAuthMethods);
|
||||
$myMethods=implode(',' ,$this->supportedAuthMethods);
|
||||
if (!empty($userMethod) && !in_array($userMethod,$this->_serverAuthMethods))
|
||||
{
|
||||
foreach ( $this->supportedAuthMethods as $method ) {
|
||||
if ( in_array( $method , $this->_serverAuthMethods ) ) {
|
||||
if ($this->_debug) error_log(__METHOD__." UserMethod $userMethod not supported by server; trying best ServerMethod $method");
|
||||
return $method;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new PEAR_Error("$method NOT supported authentication method!. This IMAP server " .
|
||||
"supports these methods: $serverMethods, but I support $myMethods");
|
||||
}else{
|
||||
@ -739,7 +749,6 @@ class Net_IMAPProtocol {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to disconnect from the iMAP server.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user