diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java index ceeed6862fb..a5077c63891 100644 --- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java +++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java @@ -62,8 +62,9 @@ public class LdapContextFactory { private DirContext createInitialDirContext(final String principal, final String password, final String providerUrl, final boolean isSystemContext) throws NamingException { - return new InitialDirContext(getEnvironment(principal, password, - providerUrl, isSystemContext)); + Hashtable environment = getEnvironment(principal, password, providerUrl, isSystemContext); + s_logger.debug("initializing ldap with provider url: "+ environment.get(Context.PROVIDER_URL)); + return new InitialDirContext(environment); } public DirContext createUserContext(final String principal, diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java index 578ebce7f77..960a8279119 100644 --- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java +++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapManagerImpl.java @@ -72,6 +72,7 @@ public class LdapManagerImpl implements LdapManager, LdapValidator { s_logger.info("Added new ldap server with hostname: " + hostname); return new LdapConfigurationResponse(hostname, port); } catch (final NamingException e) { + s_logger.debug("NamingException while doing an LDAP bind", e); throw new InvalidParameterValueException("Unable to bind to the given LDAP server"); } } else { @@ -89,6 +90,7 @@ public class LdapManagerImpl implements LdapManager, LdapValidator { closeContext(context); return true; } catch (final NamingException e) { + s_logger.debug("NamingException: while doing an LDAP bind for user "+" "+username, e); s_logger.info("Failed to authenticate user: " + username + ". incorrect password."); return false; } @@ -100,7 +102,7 @@ public class LdapManagerImpl implements LdapManager, LdapValidator { context.close(); } } catch (final NamingException e) { - s_logger.warn(e.getMessage()); + s_logger.warn(e.getMessage(),e); } } @@ -174,6 +176,7 @@ public class LdapManagerImpl implements LdapManager, LdapValidator { context = _ldapContextFactory.createBindContext(); return _ldapUserManager.getUsers(context); } catch (final NamingException e) { + s_logger.debug("ldap NamingException: ",e); throw new NoLdapUserMatchingQueryException("*"); } finally { closeContext(context); @@ -187,6 +190,7 @@ public class LdapManagerImpl implements LdapManager, LdapValidator { context = _ldapContextFactory.createBindContext(); return _ldapUserManager.getUsersInGroup(groupName, context); } catch (final NamingException e) { + s_logger.debug("ldap NamingException: ",e); throw new NoLdapUserMatchingQueryException("groupName=" + groupName); } finally { closeContext(context); @@ -214,6 +218,7 @@ public class LdapManagerImpl implements LdapManager, LdapValidator { final String escapedUsername = LdapUtils.escapeLDAPSearchFilter(username); return _ldapUserManager.getUsers("*" + escapedUsername + "*", context); } catch (final NamingException e) { + s_logger.debug("ldap NamingException: ",e); throw new NoLdapUserMatchingQueryException(username); } finally { closeContext(context);