log.info("Adding " + LimsSecurityUtils.toLdapUser(user) + " to LDAP server");
ldapUserManager.createUser(LimsSecurityUtils.toLdapUser(user));
}
else {
*/
User existingUser = super.getUserByLoginName(user.getLoginName());
if (existingUser != null) {
if (SecurityContextHolder.getContext().getAuthentication() != null &&
SecurityContextHolder.getContext().getAuthentication().isAuthenticated()) {
//this should be the case if the user has already logged in and is wishing to update details, rather than create
//TODO - this seems to change the LDAP password (an encrypted version of the already encrypted string)
//ldapUserManager.updateUser(user.toLdapUser());
if (user.getUserId() == null) {
//this will happen if the user auths against LDAP and the user exists in the DB
//i.e. when they log into the LIMS for the very first time
user.setUserId(existingUser.getUserId());
}
if ("".equals(user.getFullName()) || user.getFullName() == null) {
throw new IOException("Cannot save user with no full name / display name.");
}