Index: servers/exchange/lib/e2k-uri.c =================================================================== RCS file: /cvs/gnome/evolution-data-server/servers/exchange/lib/e2k-uri.c,v retrieving revision 1.5 diff -u -p -r1.5 e2k-uri.c --- servers/exchange/lib/e2k-uri.c 27 Jan 2006 14:16:06 -0000 1.5 +++ servers/exchange/lib/e2k-uri.c 18 Apr 2006 10:00:10 -0000 @@ -109,14 +109,6 @@ e2k_uri_new (const char *uri_string) *backslash = '\0'; uri->user = g_strdup (backslash + 1); } - else { - /* if backslash is not there check for @ */ - user_at = strchr (uri->user, '@'); - if (user_at) { - *user_at = '\0'; - uri->domain = g_strdup (user_at + 1); - } - } } else uri->user = uri->passwd = uri->domain = NULL; Index: servers/exchange/lib/e2k-validate.h =================================================================== RCS file: /cvs/gnome/evolution-data-server/servers/exchange/lib/e2k-validate.h,v retrieving revision 1.3 diff -u -p -r1.3 e2k-validate.h --- servers/exchange/lib/e2k-validate.h 1 Jul 2005 05:43:21 -0000 1.3 +++ servers/exchange/lib/e2k-validate.h 18 Apr 2006 10:00:47 -0000 @@ -36,7 +36,7 @@ typedef enum { E2K_AUTOCONFIG_FAILED } E2kAutoconfigResult; -gboolean e2k_validate_user (const char *owa_url, char *user, ExchangeParams *exchange_params, gboolean *remember_password, E2kAutoconfigResult *result); +gboolean e2k_validate_user (const char *owa_url, char **user, ExchangeParams *exchange_params, gboolean *remember_password, E2kAutoconfigResult *result); #ifdef __cplusplus Index: servers/exchange/lib/e2k-autoconfig.c =================================================================== RCS file: /cvs/gnome/evolution-data-server/servers/exchange/lib/e2k-autoconfig.c,v retrieving revision 1.14 diff -u -p -r1.14 e2k-autoconfig.c --- servers/exchange/lib/e2k-autoconfig.c 6 Mar 2006 06:00:25 -0000 1.14 +++ servers/exchange/lib/e2k-autoconfig.c 18 Apr 2006 10:02:36 -0000 @@ -1002,6 +1002,7 @@ set_account_uri_string (E2kAutoconfig *a g_string_append (uri, ";mailbox="); e2k_uri_append_encoded (uri, mailbox, FALSE, ";?"); } + printf ("set account uri string: mailbox = %s \n", mailbox); g_string_append (uri, ";owa_path=/"); e2k_uri_append_encoded (uri, path, FALSE, ";?"); g_free (path); @@ -1505,6 +1506,7 @@ validate (const char *owa_url, char *use *mailbox++ = '\0'; exchange_params->mailbox = g_strdup (mailbox); + printf ("validate: mailbox = %s \n", exchange_params->mailbox); exchange_params->owa_path = g_strdup_printf ("%s%s", "/", path); g_free (path); exchange_params->host = g_strdup (ac->pf_server); @@ -1619,14 +1621,20 @@ validate (const char *owa_url, char *use } gboolean -e2k_validate_user (const char *owa_url, char *user, +e2k_validate_user (const char *owa_url, char **user, ExchangeParams *exchange_params, gboolean *remember_password, E2kAutoconfigResult *result) { gboolean valid = FALSE, remember=FALSE; char *key, *password, *prompt; + char *username; + gchar **usernames; + int try = 0; - key = g_strdup_printf ("%s//%s@%s/", "exchange:", user, owa_url); /* FIXME */ +try_auth_again: + username = g_strdup (*user); + + key = g_strdup_printf ("%s//%s@%s/", "exchange:", username, owa_url); /* FIXME */ password = e_passwords_get_password ("Exchange", key); if (password) { /* This can be the case, where user presses authenticate button and @@ -1636,7 +1644,7 @@ e2k_validate_user (const char *owa_url, e_passwords_forget_password ("Exchange", key); } - prompt = g_strdup_printf (_("Enter password for %s"), user); + prompt = g_strdup_printf (_("Enter password for %s"), username); password = e_passwords_ask_password (_("Enter password"), "Exchange", key, prompt, E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET, @@ -1644,10 +1652,11 @@ e2k_validate_user (const char *owa_url, g_free (prompt); if (!password) { g_free (key); + g_free (username); return valid; } - valid = validate (owa_url, user, password, exchange_params, result); + valid = validate (owa_url, username, password, exchange_params, result); if (valid) { /* generate the proper key once the host name * is read and remember password temporarily, @@ -1659,18 +1668,35 @@ e2k_validate_user (const char *owa_url, g_free (key); if (exchange_params->is_ntlm) key = g_strdup_printf ("exchange://%s;auth=NTLM@%s/", - user, exchange_params->host); + username, exchange_params->host); else - key = g_strdup_printf ("exchange://%s@%s/", user, exchange_params->host); + key = g_strdup_printf ("exchange://%s@%s/", username, exchange_params->host); e_passwords_add_password (key, password); e_passwords_remember_password ("Exchange", key); } else { + if (try == 0) { + /* Check for name as e-mail id and try once again + * extracing username from e-mail id. + */ + usernames = g_strsplit (*user, "@", 2); + if (usernames && usernames[0] && usernames[1]) { + username = g_strdup (usernames[0]); + g_strfreev (usernames); + try ++; + memset(*user, 0, strlen(*user)); + g_free (*user); + *user = g_strdup (username); + g_free (username); + goto try_auth_again; + } + } /* if validation failed*/ e_passwords_forget_password ("Exchange", key); } g_free (key); g_free (password); + g_free (username); return valid; }