Skip to content

Commit

Permalink
LDAP: Support user name sync by default
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Jul 3, 2017
1 parent 15eb28e commit 0dbb5ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/UserApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,13 @@ public static User authenticateWithLdap(String loginIdOrEmail, String password)
if(!localUserFoundByLdapLogin.isSamePassword(password)) {
User.resetPassword(localUserFoundByLdapLogin.loginId, password);
}

if (StringUtils.isNotEmpty(ldapUser.getDepartment())) {
localUserFoundByLdapLogin.name = ldapUser.getDisplayName() + " [" + ldapUser.getDepartment() + "]";
} else {
localUserFoundByLdapLogin.name = ldapUser.getDisplayName();
}
localUserFoundByLdapLogin.update();
return localUserFoundByLdapLogin;
}
} catch (CommunicationException e) {
Expand Down
5 changes: 5 additions & 0 deletions app/utils/LdapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
**/
package utils;

import models.User;
import models.support.LdapUser;
import play.Play;

Expand Down Expand Up @@ -67,6 +68,10 @@ private String getProperUsernameGuessing(@Nonnull String username){
if(username.contains("@")){
return username;
} else {
User user = User.findByLoginId(username);
if(!user.isAnonymous()) {
return user.email;
}
return USER_NAME_PROPERTY + "=" + username + "," + DN_POSTFIX;
}
}
Expand Down

0 comments on commit 0dbb5ce

Please sign in to comment.