mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-05 18:58:02 -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;
|
||||
} catch (IllegalStateException exc) {
|
||||
throw exc;
|
||||
} catch (NullPointerException exc) {
|
||||
throw exc;
|
||||
} catch (Exception exc) {
|
||||
handleNetworkDown(exc);
|
||||
}
|
||||
|
@ -186,7 +186,12 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
// no need to check logon method body
|
||||
if (method != null) {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -240,6 +245,23 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
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 {
|
||||
folderIdMap = new HashMap<String, String>();
|
||||
// load actual well known folder ids
|
||||
@ -2097,7 +2119,7 @@ public class EwsExchangeSession extends ExchangeSession {
|
||||
|
||||
protected FolderId getFolderIdIfExists(String folderPath) throws IOException {
|
||||
String lowerCaseFolderPath = folderPath.toLowerCase();
|
||||
if (currentMailboxPath.equals(lowerCaseFolderPath)) {
|
||||
if (lowerCaseFolderPath.equals(currentMailboxPath)) {
|
||||
return getSubFolderIdIfExists(null, "");
|
||||
} else if (lowerCaseFolderPath.startsWith(currentMailboxPath + '/')) {
|
||||
return getSubFolderIdIfExists(null, folderPath.substring(currentMailboxPath.length() + 1));
|
||||
|
Loading…
Reference in New Issue
Block a user