diff --git a/src/main/java/org/nrg/xnat/auth/ldap/provider/XnatLdapAuthenticationProviderValidator.java b/src/main/java/org/nrg/xnat/auth/ldap/provider/XnatLdapAuthenticationProviderValidator.java index 67d7bae..c0b5f65 100644 --- a/src/main/java/org/nrg/xnat/auth/ldap/provider/XnatLdapAuthenticationProviderValidator.java +++ b/src/main/java/org/nrg/xnat/auth/ldap/provider/XnatLdapAuthenticationProviderValidator.java @@ -53,13 +53,8 @@ public String validate(final Properties properties) { final String bindingSearchBase = atoms.length > 1 ? atoms[1] : ""; final String bindingUsername = atoms[0]; - println("Validating the binding user account '{}' with search base '{}'", bindingUsername, bindingSearchBase); - final boolean bindingUserAuthenticated = bindAndAuthenticate(contextSource, bindingSearchBase, "(${bindingUsername})", bindingUsername, bindingPassword); - - if (bindingUserAuthenticated) { - println("Binding user '{}' authenticated successfully, validating the user account '{}'", bindingUsername, username); - bindAndAuthenticate(contextSource, searchBase, searchFilter, username, password); - } + println("Binding account {}, user account {}", bindingUsername, username); + bindAndAuthenticate(contextSource, searchBase, searchFilter, username, password); final String message = _buffer.getBuffer().toString(); log.info(message); diff --git a/src/main/resources/ValidateLdap.groovy b/src/main/resources/ValidateLdap.groovy index 7a54d82..5ba7870 100644 --- a/src/main/resources/ValidateLdap.groovy +++ b/src/main/resources/ValidateLdap.groovy @@ -51,13 +51,9 @@ final String[] atoms = userDn.split ",", 2 def bindingUsername = atoms[0] def bindingSearchBase = atoms.size() > 1 ? (atoms[1]) : "" -println "Validating the binding user account '${bindingUsername}' with search base '${bindingSearchBase}'" -def bindingUserAuthenticated = BindAndAuthenticate(contextSource, bindingSearchBase, "(${bindingUsername})", bindingUsername, bindingPassword) +println "Binding account '${bindingUsername}', user account '${username}" +BindAndAuthenticate(contextSource, searchBase, searchFilter, username, password) -if (bindingUserAuthenticated) { - println "Binding user '${bindingUsername}' authenticated successfully, validating the user account '${username}'" - BindAndAuthenticate(contextSource, searchBase, searchFilter, username, password) -} private boolean BindAndAuthenticate(DefaultSpringSecurityContextSource contextSource, String searchBase, String searchFilter, username, String password) { println "Creating user search object with search base '${searchBase}' and filter '${searchFilter}" @@ -82,3 +78,4 @@ private boolean BindAndAuthenticate(DefaultSpringSecurityContextSource contextSo false } } +