if (securityManager.findIdentityByName(uid) != null) {
log.error("Can't create user with username='" + uid + "', does already exist in OLAT database");
return;
}
// Create User (first and lastname is added in next step)
User user = UserManager.getInstance().createUser(null, null, email);
// Set User Property's (Iterates over Attributes and gets OLAT Property out
// of olatexconfig.xml)
NamingEnumeration<Attribute> neAttr = (NamingEnumeration<Attribute>) userAttributes.getAll();
try {
while (neAttr.hasMore()) {
Attribute attr = neAttr.next();
String olatProperty = LDAPHelper.mapLdapAttributeToOlatProperty(attr.getID());
if (attr.get() != uid) {
String ldapValue = LDAPHelper.getAttributeValue(attr);
if (olatProperty == null || ldapValue == null) continue;
user.setProperty(olatProperty, ldapValue);
}
}
// Add static user properties from the configuration
Map<String, String> staticProperties = LDAPLoginModule.getStaticUserProperties();
if (staticProperties != null && staticProperties.size() > 0) {
for (Entry<String, String> staticProperty : staticProperties.entrySet()) {
user.setProperty(staticProperty.getKey(), staticProperty.getValue());
}
}
} catch (NamingException e) {
log.error("NamingException when trying to create and persist LDAP user with username::" + uid, e);
return;