log.error("Internal Error while authenticating " + authentication.getName() + " with LDAP", iase);
throw iase;
}
//Automatically create LDAP users in Tatami
User user = userService.getUserByLogin(login);
if (user == null) {
user = new User();
user.setLogin(login);
userService.createUser(user);
} else {
// ensure that this user has access to its domain if it has been created before
domainRepository.updateUserInDomain(user.getDomain(), user.getLogin());
}
// The real authentication object uses the login, and not the username
org.springframework.security.core.userdetails.User realUser = userDetailsService.getTatamiUserDetails(login,
authentication.getCredentials().toString());