diff --git a/federation/ldap/src/main/java/org/keycloak/storage/ldap/LDAPStorageProvider.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/LDAPStorageProvider.java index 69c513d0c1..161ed12752 100755 --- a/federation/ldap/src/main/java/org/keycloak/storage/ldap/LDAPStorageProvider.java +++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/LDAPStorageProvider.java @@ -38,20 +38,11 @@ import org.keycloak.credential.CredentialInputValidator; import org.keycloak.credential.CredentialModel; import org.keycloak.federation.kerberos.impl.KerberosUsernamePasswordAuthenticator; import org.keycloak.federation.kerberos.impl.SPNEGOAuthenticator; -import org.keycloak.models.CredentialValidationOutput; -import org.keycloak.models.GroupModel; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.LDAPConstants; -import org.keycloak.models.ModelDuplicateException; -import org.keycloak.models.ModelException; +import org.keycloak.models.*; +import org.keycloak.models.utils.DefaultRoles; import org.keycloak.models.utils.ReadOnlyUserModelDelegate; import org.keycloak.policy.PasswordPolicyManagerProvider; import org.keycloak.policy.PolicyError; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RoleModel; -import org.keycloak.models.UserCredentialModel; -import org.keycloak.models.UserManager; -import org.keycloak.models.UserModel; import org.keycloak.models.cache.UserCache; import org.keycloak.models.credential.PasswordUserCredentialModel; import org.keycloak.models.utils.KeycloakModelUtils; @@ -269,7 +260,20 @@ public class LDAPStorageProvider implements UserStorageProvider, user.setSingleAttribute(LDAPConstants.LDAP_ID, ldapUser.getUuid()); user.setSingleAttribute(LDAPConstants.LDAP_ENTRY_DN, ldapUser.getDn().toString()); - return proxy(realm, user, ldapUser); + // Add the user to the default groups and add default required actions + UserModel proxy = proxy(realm, user, ldapUser); + DefaultRoles.addDefaultRoles(realm, user); + + for (GroupModel g : realm.getDefaultGroups()) { + proxy.joinGroup(g); + } + for (RequiredActionProviderModel r : realm.getRequiredActionProviders()) { + if (r.isEnabled() && r.isDefaultAction()) { + user.addRequiredAction(r.getAlias()); + } + } + + return proxy; } @Override