Skip to content
Snippets Groups Projects
Commit cbdaef7a authored by William Enright's avatar William Enright
Browse files

Directory search now queries by LOGON_NAME if no results are found

Change-Id: I5f296d09829c7973d6d87fe65a7bec24eeb96a98
parent 517fa5bd
No related branches found
No related tags found
No related merge requests found
...@@ -31,8 +31,13 @@ public class AuthenticationService { ...@@ -31,8 +31,13 @@ public class AuthenticationService {
public boolean authenticateUser(String username, String password) { public boolean authenticateUser(String username, String password) {
Endpoint endpoint = ADConnector.getConnection(username, password);
if (username.contains("cn=")) {
String marked_username = username.substring(username.indexOf("cn=") + 3, username.indexOf(",")); //ADConnector.settings.getRealm() + "\\" + ADConnector.settings.getUsername(); String marked_username = username.substring(username.indexOf("cn=") + 3, username.indexOf(",")); //ADConnector.settings.getRealm() + "\\" + ADConnector.settings.getUsername();
Endpoint endpoint = ADConnector.getConnection(marked_username, password); endpoint = ADConnector.getConnection(marked_username, password);
}
try { try {
ConnectionResponse connectionResponse = DirectoryConnectorService.authenticate(endpoint); ConnectionResponse connectionResponse = DirectoryConnectorService.authenticate(endpoint);
return !connectionResponse.isError(); return !connectionResponse.isError();
......
...@@ -74,6 +74,14 @@ public class SearchDirectoryServlet extends HttpServlet { ...@@ -74,6 +74,14 @@ public class SearchDirectoryServlet extends HttpServlet {
UserProfile[] profiles = v.getUserProfile(req.getParameter("queryString"),"FULL_TEXT_NAME"); UserProfile[] profiles = v.getUserProfile(req.getParameter("queryString"),"FULL_TEXT_NAME");
if(profiles != null && profiles.length != 0) userProfiles.addAll(Arrays.asList(profiles)); if(profiles != null && profiles.length != 0) userProfiles.addAll(Arrays.asList(profiles));
}); });
// check logon names if nothing was found
if (userProfiles.isEmpty()) {
userAuthenticationModule.getAuthSources().forEach( (k,v) ->{
UserProfile[] profiles = v.getUserProfile(req.getParameter("queryString"),"LOGON_NAME");
if(profiles != null && profiles.length != 0) userProfiles.addAll(Arrays.asList(profiles));
});
}
resp.getOutputStream().write(JsonStream.serialize(userProfiles).getBytes()); resp.getOutputStream().write(JsonStream.serialize(userProfiles).getBytes());
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment