return byUsername;
}
private void createRaveUserFromLdapInfo(DirContextOperations ctx, String username) {
NewUser newUser = new NewUser();
newUser.setUsername(username);
if (!ctx.attributeExists(mailAttributeName) || StringUtils.isBlank(ctx.getStringAttribute(mailAttributeName))) {
throw new RuntimeException("Missing LDAP attribute for email for user " + username);
}
newUser.setEmail(ctx.getStringAttribute(mailAttributeName));
if (ctx.attributeExists(displayNameAttributeName)) {
newUser.setDisplayName(ctx.getStringAttribute(displayNameAttributeName));
}
newUser.setPassword(RandomStringUtils.random(16));
newUser.setPageLayout(pageLayoutCode);
try {
newAccountService.createNewAccount(newUser);
} catch (Exception e) {
throw new RuntimeException("Could not bind LDAP username '{" + username + "}' to a user", e);
}