diff --git a/src/java/davmail/exchange/ExchangeSessionFactory.java b/src/java/davmail/exchange/ExchangeSessionFactory.java index f884f1db..6edc32b6 100644 --- a/src/java/davmail/exchange/ExchangeSessionFactory.java +++ b/src/java/davmail/exchange/ExchangeSessionFactory.java @@ -96,6 +96,16 @@ public final class ExchangeSessionFactory { } } + private static String convertUserName(String userName) { + String result = userName; + // prepend default windows domain prefix + String defaultDomain = Settings.getProperty("davmail.defaultDomain"); + if (userName.indexOf('\\') < 0 && defaultDomain != null) { + result = defaultDomain + '\\' + userName; + } + return result; + } + /** * Create authenticated Exchange session * @@ -109,12 +119,7 @@ public final class ExchangeSessionFactory { ExchangeSession session = null; try { - // prepend default windows domain prefix - String defaultDomain = Settings.getProperty("davmail.defaultDomain"); - if (userName.indexOf('\\') < 0 && defaultDomain != null) { - userName = defaultDomain + '\\' + userName; - } - PoolKey poolKey = new PoolKey(baseUrl, userName, password); + PoolKey poolKey = new PoolKey(baseUrl, convertUserName(userName), password); synchronized (LOCK) { session = POOL_MAP.get(poolKey); @@ -263,8 +268,9 @@ public final class ExchangeSessionFactory { * @return user password */ public static String getUserPassword(String userName) { + String fullUserName = convertUserName(userName); for (PoolKey poolKey : POOL_MAP.keySet()) { - if (poolKey.userName.equals(userName)) { + if (poolKey.userName.equals(fullUserName)) { return poolKey.password; } } diff --git a/src/java/davmail/ldap/LdapConnection.java b/src/java/davmail/ldap/LdapConnection.java index 42633418..0c914c05 100644 --- a/src/java/davmail/ldap/LdapConnection.java +++ b/src/java/davmail/ldap/LdapConnection.java @@ -510,7 +510,7 @@ public class LdapConnection extends AbstractConnection { protected static final byte[] EMPTY_BYTE_ARRAY= new byte[0]; protected void handleRequest(byte[] inbuf, int offset) throws IOException { - dumpBer(inbuf, offset); + //dumpBer(inbuf, offset); BerDecoder reqBer = new BerDecoder(inbuf, 0, offset); int currentMessageId = 0; try { @@ -575,7 +575,7 @@ public class LdapConnection extends AbstractConnection { } else { Map properties = new HashMap(); properties.put("javax.security.sasl.qop", "auth,auth-int"); - saslServer = Sasl.createSaslServer(mechanism, "ldap", InetAddress.getLocalHost().getHostName(), properties, callbackHandler); + saslServer = Sasl.createSaslServer(mechanism, "ldap", client.getLocalAddress().getHostAddress(), properties, callbackHandler); serverResponse = saslServer.evaluateResponse(EMPTY_BYTE_ARRAY); status = LDAP_SASL_BIND_IN_PROGRESS; } @@ -792,6 +792,7 @@ public class LdapConnection extends AbstractConnection { Map attributes = new HashMap(); attributes.put("objectClass", "top"); attributes.put("namingContexts", NAMING_CONTEXTS); + //attributes.put("supportedsaslmechanisms", "PLAIN"); sendEntry(currentMessageId, "Root DSE", attributes); }