diff -up evolution-ews-3.18.5/src/addressbook/e-book-backend-ews.c.ntlm-auth-test-failure evolution-ews-3.18.5/src/addressbook/e-book-backend-ews.c --- evolution-ews-3.18.5/src/addressbook/e-book-backend-ews.c.ntlm-auth-test-failure 2015-09-21 11:59:31.000000000 +0200 +++ evolution-ews-3.18.5/src/addressbook/e-book-backend-ews.c 2016-04-20 22:54:21.031556789 +0200 @@ -4170,6 +4170,13 @@ e_book_backend_ews_authenticate_sync (EB } else { ews_backend->priv->is_writable = FALSE; e_backend_set_online (backend, FALSE); + + if (e_ews_connection_utils_get_without_password (ews_settings) && + result == E_SOURCE_AUTHENTICATION_REJECTED && + !e_named_parameters_exists (credentials, E_SOURCE_CREDENTIAL_PASSWORD)) { + e_ews_connection_utils_force_off_ntlm_auth_check (); + result = E_SOURCE_AUTHENTICATION_REQUIRED; + } } e_book_backend_set_writable (E_BOOK_BACKEND (backend), ews_backend->priv->is_writable); diff -up evolution-ews-3.18.5/src/calendar/e-cal-backend-ews.c.ntlm-auth-test-failure evolution-ews-3.18.5/src/calendar/e-cal-backend-ews.c --- evolution-ews-3.18.5/src/calendar/e-cal-backend-ews.c.ntlm-auth-test-failure 2015-09-21 11:59:31.000000000 +0200 +++ evolution-ews-3.18.5/src/calendar/e-cal-backend-ews.c 2016-04-20 22:54:21.032556789 +0200 @@ -4341,6 +4341,11 @@ e_cal_backend_ews_authenticate_sync (EBa ews_start_sync (cal_backend); cbews_listen_notifications_cb (cal_backend, NULL, ews_settings); + } else if (e_ews_connection_utils_get_without_password (ews_settings) && + result == E_SOURCE_AUTHENTICATION_REJECTED && + !e_named_parameters_exists (credentials, E_SOURCE_CREDENTIAL_PASSWORD)) { + e_ews_connection_utils_force_off_ntlm_auth_check (); + result = E_SOURCE_AUTHENTICATION_REQUIRED; } g_object_unref (connection); diff -up evolution-ews-3.18.5/src/collection/e-ews-backend.c.ntlm-auth-test-failure evolution-ews-3.18.5/src/collection/e-ews-backend.c --- evolution-ews-3.18.5/src/collection/e-ews-backend.c.ntlm-auth-test-failure 2015-09-21 11:59:31.000000000 +0200 +++ evolution-ews-3.18.5/src/collection/e-ews-backend.c 2016-04-20 22:54:21.032556789 +0200 @@ -1045,6 +1045,11 @@ ews_backend_authenticate_sync (EBackend e_collection_backend_authenticate_children (E_COLLECTION_BACKEND (backend), credentials); e_ews_backend_sync_folders (ews_backend, NULL, ews_backend_folders_synced_cb, NULL); + } else if (e_ews_connection_utils_get_without_password (ews_settings) && + result == E_SOURCE_AUTHENTICATION_REJECTED && + !e_named_parameters_exists (credentials, E_SOURCE_CREDENTIAL_PASSWORD)) { + e_ews_connection_utils_force_off_ntlm_auth_check (); + result = E_SOURCE_AUTHENTICATION_REQUIRED; } return result; diff -up evolution-ews-3.18.5/src/configuration/e-ews-config-utils.c.ntlm-auth-test-failure evolution-ews-3.18.5/src/configuration/e-ews-config-utils.c --- evolution-ews-3.18.5/src/configuration/e-ews-config-utils.c.ntlm-auth-test-failure 2015-06-17 18:07:41.000000000 +0200 +++ evolution-ews-3.18.5/src/configuration/e-ews-config-utils.c 2016-04-20 22:54:21.032556789 +0200 @@ -383,12 +383,18 @@ e_ews_config_utils_open_connection_for ( if (result != E_SOURCE_AUTHENTICATION_ACCEPTED) { g_clear_object (&conn); - break; + if (result != E_SOURCE_AUTHENTICATION_REJECTED || local_error) + break; } - } else { + } + + if (!conn) { EShell *shell; TryCredentialsData data; + e_ews_connection_utils_force_off_ntlm_auth_check (); + g_clear_error (&local_error); + shell = e_shell_get_default (); data.ews_settings = g_object_ref (ews_settings); diff -up evolution-ews-3.18.5/src/configuration/e-mail-config-ews-autodiscover.c.ntlm-auth-test-failure evolution-ews-3.18.5/src/configuration/e-mail-config-ews-autodiscover.c --- evolution-ews-3.18.5/src/configuration/e-mail-config-ews-autodiscover.c.ntlm-auth-test-failure 2015-03-23 08:28:34.000000000 +0100 +++ evolution-ews-3.18.5/src/configuration/e-mail-config-ews-autodiscover.c 2016-04-20 22:54:21.032556789 +0200 @@ -169,13 +169,21 @@ mail_config_ews_autodiscover_run_thread gboolean success = FALSE; if (!g_cancellable_set_error_if_cancelled (cancellable, &local_error) && !local_error) { - if (e_ews_connection_utils_get_without_password (async_context->ews_settings)) { + gboolean without_password; + + without_password = e_ews_connection_utils_get_without_password (async_context->ews_settings); + if (without_password) { success = e_ews_autodiscover_ws_url_sync ( async_context->ews_settings, async_context->email_address, "", cancellable, &local_error); - } else { + } + + if (!without_password || g_error_matches (local_error, SOUP_HTTP_ERROR, SOUP_STATUS_UNAUTHORIZED)) { EShell *shell; + e_ews_connection_utils_force_off_ntlm_auth_check (); + g_clear_error (&local_error); + shell = e_shell_get_default (); success = e_credentials_prompter_loop_prompt_sync (e_shell_get_credentials_prompter (shell), diff -up evolution-ews-3.18.5/src/server/e-ews-connection-utils.c.ntlm-auth-test-failure evolution-ews-3.18.5/src/server/e-ews-connection-utils.c --- evolution-ews-3.18.5/src/server/e-ews-connection-utils.c.ntlm-auth-test-failure 2014-08-11 09:12:45.000000000 +0200 +++ evolution-ews-3.18.5/src/server/e-ews-connection-utils.c 2016-04-20 22:54:21.032556789 +0200 @@ -67,6 +67,8 @@ e_ews_connection_utils_check_element (co return TRUE; } +static gboolean force_off_ntlm_auth_check = FALSE; + static gboolean ews_connect_check_ntlm_available (void) { @@ -80,6 +82,9 @@ ews_connect_check_ntlm_available (void) gchar *command; gint ret; + if (force_off_ntlm_auth_check) + return FALSE; + /* We are attempting to predict what libsoup will do. */ helper = g_getenv ("SOUP_NTLM_AUTH_DEBUG"); if (!helper) @@ -145,6 +150,11 @@ ews_connect_check_ntlm_available (void) #endif } +void +e_ews_connection_utils_force_off_ntlm_auth_check (void) +{ + force_off_ntlm_auth_check = TRUE; +} /* Should we bother to attempt a connection without a password? Remember, * this is *purely* an optimisation to avoid that extra round-trip if we diff -up evolution-ews-3.18.5/src/server/e-ews-connection-utils.h.ntlm-auth-test-failure evolution-ews-3.18.5/src/server/e-ews-connection-utils.h --- evolution-ews-3.18.5/src/server/e-ews-connection-utils.h.ntlm-auth-test-failure 2014-08-11 09:12:45.000000000 +0200 +++ evolution-ews-3.18.5/src/server/e-ews-connection-utils.h 2016-04-20 22:54:21.032556789 +0200 @@ -32,6 +32,8 @@ gboolean e_ews_connection_utils_check_el const gchar *element_name, const gchar *expected_name); +void e_ews_connection_utils_force_off_ntlm_auth_check + (void); gboolean e_ews_connection_utils_get_without_password (CamelEwsSettings *ews_settings);