mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-07 03:38:05 -05:00
EWS: Get primary smtp email address with ResolveNames in direct EWS mode
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2032 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
178896b9c6
commit
bb4fb34582
@ -169,6 +169,8 @@ public final class ExchangeSessionFactory {
|
|||||||
throw exc;
|
throw exc;
|
||||||
} catch (IllegalStateException exc) {
|
} catch (IllegalStateException exc) {
|
||||||
throw exc;
|
throw exc;
|
||||||
|
} catch (NullPointerException exc) {
|
||||||
|
throw exc;
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
handleNetworkDown(exc);
|
handleNetworkDown(exc);
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,12 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
// no need to check logon method body
|
// no need to check logon method body
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
method.releaseConnection();
|
method.releaseConnection();
|
||||||
// need to retrieve email and alias
|
}
|
||||||
|
boolean directEws = method == null || "/ews/services.wsdl".equalsIgnoreCase(method.getPath());
|
||||||
|
|
||||||
|
// options page is not available in direct EWS mode
|
||||||
|
if (!directEws) {
|
||||||
|
// retrieve email and alias from options page
|
||||||
getEmailAndAliasFromOptions();
|
getEmailAndAliasFromOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +245,23 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
httpClient.getParams().setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
|
httpClient.getParams().setParameter(HttpClientParams.PREEMPTIVE_AUTHENTICATION, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// direct EWS: get primary smtp email address with ResolveNames
|
||||||
|
if (directEws) {
|
||||||
|
try {
|
||||||
|
ResolveNamesMethod resolveNamesMethod = new ResolveNamesMethod(alias);
|
||||||
|
executeMethod(resolveNamesMethod);
|
||||||
|
List<EWSMethod.Item> responses = resolveNamesMethod.getResponseItems();
|
||||||
|
for (EWSMethod.Item response : responses) {
|
||||||
|
if (alias.equalsIgnoreCase(response.get("Name"))) {
|
||||||
|
email = response.get("EmailAddress");
|
||||||
|
currentMailboxPath = "/users/" + email.toLowerCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOGGER.warn("Unable to get primary email address with ResolveNames", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
folderIdMap = new HashMap<String, String>();
|
folderIdMap = new HashMap<String, String>();
|
||||||
// load actual well known folder ids
|
// load actual well known folder ids
|
||||||
@ -2097,7 +2119,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
|||||||
|
|
||||||
protected FolderId getFolderIdIfExists(String folderPath) throws IOException {
|
protected FolderId getFolderIdIfExists(String folderPath) throws IOException {
|
||||||
String lowerCaseFolderPath = folderPath.toLowerCase();
|
String lowerCaseFolderPath = folderPath.toLowerCase();
|
||||||
if (currentMailboxPath.equals(lowerCaseFolderPath)) {
|
if (lowerCaseFolderPath.equals(currentMailboxPath)) {
|
||||||
return getSubFolderIdIfExists(null, "");
|
return getSubFolderIdIfExists(null, "");
|
||||||
} else if (lowerCaseFolderPath.startsWith(currentMailboxPath + '/')) {
|
} else if (lowerCaseFolderPath.startsWith(currentMailboxPath + '/')) {
|
||||||
return getSubFolderIdIfExists(null, folderPath.substring(currentMailboxPath.length() + 1));
|
return getSubFolderIdIfExists(null, folderPath.substring(currentMailboxPath.length() + 1));
|
||||||
|
Loading…
Reference in New Issue
Block a user