Skip to content

Commit

Permalink
remove filtered search for the bind account
Browse files Browse the repository at this point in the history
  • Loading branch information
mirestrepo committed Aug 2, 2019
1 parent 5b80c9e commit 9473a28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions src/main/resources/ValidateLdap.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -82,3 +78,4 @@ private boolean BindAndAuthenticate(DefaultSpringSecurityContextSource contextSo
false
}
}

0 comments on commit 9473a28

Please sign in to comment.