mirror of https://github.com/apache/cloudstack.git
improved ldap logging. added stacktrace in debug level incase of exceptions.
Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
This commit is contained in:
parent
a28933085c
commit
fe305a5662
|
|
@ -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<String, String> 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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue