Skip to content

Commit 2cb7001

Browse files
committed
Provide error in logs in case a LDAP server is not configured properly
Request: MO Change-Id: Id395ca0b5b0fee68b22928f5aed20076fb3ea1a0
1 parent 7bf3c4e commit 2cb7001

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

minion/src/main/java/io/bdeploy/minion/user/ldap/LdapAuthenticator.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,18 @@ private LdapContext createServerContext(LDAPSettingsDto server) throws NamingExc
160160

161161
// TODO: test pooling: env.put("com.sun.jndi.ldap.connect.pool", "true");
162162

163-
LdapContext ctx = new InitialLdapContext(env, null);
164-
165-
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, server.user);
166-
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, server.pass);
167-
ctx.reconnect(null);
163+
try {
164+
LdapContext ctx = new InitialLdapContext(env, null);
165+
166+
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, server.user);
167+
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, server.pass);
168+
ctx.reconnect(null);
169+
return ctx;
170+
} catch (Exception e) {
171+
log.error("Cannot create initial connection to {} as {}", server.server, server.user, e);
172+
throw e;
173+
}
168174

169-
return ctx;
170175
}
171176

172177
private void closeServerContext(DirContext ctx) throws NamingException {

0 commit comments

Comments
 (0)