1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

EWS: separate domain from userName in NTLM mode

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1349 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2010-08-17 06:56:38 +00:00
parent 34d927f506
commit 36aff74010
2 changed files with 14 additions and 1 deletions

View File

@ -484,7 +484,7 @@ public abstract class ExchangeSession {
protected void checkFormLoginQueryString(HttpMethod logonMethod) throws DavMailAuthenticationException {
String queryString = logonMethod.getQueryString();
if (queryString != null && queryString.contains("reason=2")) {
if (queryString != null && (queryString.contains("reason=2") || queryString.contains("reason=4"))) {
logonMethod.releaseConnection();
throwAuthenticationFailed();
}

View File

@ -480,6 +480,19 @@ public final class DavGatewayHttpClientFacade {
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
// separate domain from username in credentials
AuthScope authScope = new AuthScope(null, -1);
NTCredentials credentials = (NTCredentials) httpClient.getState().getCredentials(authScope);
String userName = credentials.getUserName();
int backSlashIndex = userName.indexOf('\\');
if (backSlashIndex >=0) {
String domain = userName.substring(0, backSlashIndex);
userName = userName.substring(backSlashIndex+1);
credentials = new NTCredentials(userName, credentials.getPassword(), "", domain);
httpClient.getState().setCredentials(authScope, credentials);
}
// make sure NTLM is always active
needNTLM = true;
}