diff --git a/federation/ldap/src/main/java/org/keycloak/storage/ldap/LDAPStorageUserManager.java b/federation/ldap/src/main/java/org/keycloak/storage/ldap/LDAPStorageUserManager.java index 798f188266..3c035d4003 100644 --- a/federation/ldap/src/main/java/org/keycloak/storage/ldap/LDAPStorageUserManager.java +++ b/federation/ldap/src/main/java/org/keycloak/storage/ldap/LDAPStorageUserManager.java @@ -45,7 +45,13 @@ public class LDAPStorageUserManager { } public LDAPObject getManagedLDAPObject(String userId) { - return managedLDAPObjects.get(userId); + ManagedUserEntry entry = managedUsers.get(userId); + if (entry != null) { + return entry.getLdapUser(); + } + else { + return managedLDAPObjects.get(userId); + } } public void setManagedLDAPObject(String userId, LDAPObject ldapObject) { @@ -74,7 +80,7 @@ public class LDAPStorageUserManager { } LDAPTransaction ldapTransaction = new LDAPTransaction(provider, ldapObject); - ManagedUserEntry newEntry = new ManagedUserEntry(proxiedUser, ldapTransaction); + ManagedUserEntry newEntry = new ManagedUserEntry(proxiedUser, ldapObject, ldapTransaction); managedUsers.put(userId, newEntry); } @@ -87,10 +93,12 @@ public class LDAPStorageUserManager { private static class ManagedUserEntry { private final UserModel managedProxiedUser; + private final LDAPObject ldapUser; private final LDAPTransaction ldapTransaction; - public ManagedUserEntry(UserModel managedProxiedUser, LDAPTransaction ldapTransaction) { + public ManagedUserEntry(UserModel managedProxiedUser, LDAPObject ldapUser, LDAPTransaction ldapTransaction) { this.managedProxiedUser = managedProxiedUser; + this.ldapUser = ldapUser; this.ldapTransaction = ldapTransaction; } @@ -98,6 +106,10 @@ public class LDAPStorageUserManager { return managedProxiedUser; } + public LDAPObject getLdapUser() { + return ldapUser; + } + public LDAPTransaction getLdapTransaction() { return ldapTransaction; }