diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/LdapAuthenticator.java b/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/LdapAuthenticator.java index edad29c4f26d..32ff88bcabaa 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/LdapAuthenticator.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/security/auth/LdapAuthenticator.java @@ -162,8 +162,16 @@ private User checkAndCreateUser(String userDn, String email, String userName) th // Check if the user exists in OM Database try { - User omUser = - userRepository.getByEmail(null, email, userRepository.getFields("id,name,email,roles")); + // Load the same field set the PUT path uses (USER_UPDATE_FIELDS): roles, teams, + // profile, authenticationMechanism, isEmailVerified, personas, defaultPersona, + // domains, personaPreferences. UserUpdater.entitySpecificUpdate runs updateTeams / + // updatePersonas / etc. unconditionally; with a sparse fetch those fields arrive + // null and the updater wipes the corresponding relationships, which destroys the + // user's manually-assigned teams on every LDAP login and makes login slow (deleteTo + // does work proportional to the user's existing team count). Use getPutFields() + // (narrow) rather than getFieldsWithUserAuth("*") (wide) so we don't eagerly load + // the heavy owns/follows relationship sets on every login. + User omUser = userRepository.getByEmail(null, email, userRepository.getPutFields()); getRoleForLdap(userDn, omUser, Boolean.TRUE); finalUser = omUser; } catch (EntityNotFoundException ex) {