You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Automatic Update of Ldap groups and Ldap group memberships during periodic sync #9609
Hopefully new store will help with having syncing of groups properly implemented as "Group Storage" .
Still the sync of groups and roles can have performance impact. Hence I think it will be good to keep the current behaviour by default (EG. sync users configured at the LDAP provider does NOT sync groups/roles from LDAP).
Also due the performance impact, I can imagine that customer may want to use different intervals for syncing users and for syncing groups/roles (EG. Sync users once per day, but sync groups/roles from LDAP once per week). So it will be good to have a way to configure for each group/role mapper separately how periodic sync should work (full sync VS sync only changed objects) . So I think will be good to have the options like
Periodic Full Sync
Full Sync Period
Periodic Changed Groups (Roles) Sync
Changed Groups (Roles) Sync Period available also for groups/roles.
If we still have mappers with the new store, it will be good to address this for both LDAP group mapper and LDAP role mapper (I understand we may have customer, who want only groups, but will be nice to address this also for roles, which are very similar and will be nice to have this consistent for both roles and groups).
Reacted by murphy-25, Kresna Satya, Axel Klepping, ctrueltzsch, Peter Levart, MatejH, Vasil-Pahomov, Alexander Skrock, Moep90, UKFr-DIZ and 8 more
I would like to add that the current implementation also seems to act upon the group settings when syncing users : when groups are added in Keycloak and the group mapping has 'Drop non-existing groups during sync' enabled, the groups never end up in LDAP and are also removed from Keycloak. So using Keycloak as the single point for users AND group management with an LDAP backend is not possible. If the option is disabled, groups removed in LDAP will not be removed in Keycloak, so currently one needs to choose between those.
When wanting LDAP to be authorative ( my assumption ) the setting has to be enabled and groups can only be created directly in LDAP, requiring an LDAP client.
As a side note, it seems Keycloak sends to requests to the LDAP server when creating a user - not sure if this is related, but in a load balanced dual master setup this causes issues when the load balancer is not set to sticky sessions ( the second call being faster sometimes then the sync operation ).
It would be a great benefit if that could be part of any effort to improve this.
I have the same problem with sync user group membership from Keycloak to LDAP. So, the current solution we do is save in two place: Keycloak (by Keycloak REST admin API) and LDAP query in different methods.
Same issue. The reason why I wanted to try out KeyCloak is to have one (easy) single point of user administration. Are we doing something wrong? Or is this a genuine bug/missing feature?
Let me describe my observations of the behavior in the latest (21.1.1) Keycloak.
We are trying to use Active Directory as a source for Users and Groups. We configured:
"Active Directory" as a LDAP vendor (provider)
UNSYNCED as Edit mode
Subtree as Search scope for users
Import users: ON
Sync Registrations: OFF
Batch size: 200
Pagination: ON
We want users to be administered only in Active Directory and just want to propagate all their changes to Keycloak. This works. We synchronize ~15000 users this way and their data gets updated periodically.
We also added one or two group-ldap-mapper mappers and configured them to synchronize a subset of groups from LDAP. The settings of such mapper are:
Preserve Group Inheritance: ON (we make sure groups that are synchronized don't have multiple inheritance)
Ignore Missing Groups: ON
Mode: READ_ONLY (we also tried with IMPORT which is "...Read-only LDAP mode where group mappings are retrieved from LDAP just at the time when user is imported from LDAP", but then we don't get updated memberships which is what this issue is all about, I think)
Drop non-existing groups during sync: ON
So this seems to work, although to be totally sure, we need some more testing.
One thing that doesn't work as expected is the following:
We explicitly specified "Preserve Group Inheritance: ON" in group-ldap-mapper and we do get groups in a (single inheritance) hierarchy from LDAP properly connected in Keycloak, but user group memberships are nevertheless flattened, meaning if we have group A and a child group B, then when there is a user U that is a member of group B in LDAP, this user becomes member of group B in Keycloak and of group A in Keycloak. This is unnecessary flattening of memberships which is perhaps necessary when the group-ldap-mapper specifies "Preserve Group Inheritance: OFF", but in case this is ON, should not be happening.
Above striked-out claim might be unfounded. I was mislead by the "Members" tab on the Groups display. When a particular Group is selected on the left-side tree-like browser, the list of group Members on the Members tab is shown and that list includes, as the last column, Membership - display of all Groups a particular user is member of. That list seems to include transitive Memberships. The list of users does not include users that are transitive members of selected group unless "Include sub-group users" checkbox is checked.
OTOH, when watching the details view for a particular User, the "Groups" tab shows groups where that user is direct member and also some (but not all) groups where it is a transitive member of. When the "Direct membership" checkbox is unchecked, the list shows all groups the user is transitive member of. So these two views (direct User members of a Group vs. direct Group membership of a User) are at least inconsistent.
Is there any traction on this? I feel that due the lack of a proper group sync, deleting a group on keycloak does not delete it in ldap, so the group will always reappear.
Do you agree? Asking because we might want to work on them separately because the second one has been being discussed in the past with some attempts to fix the problem. For instance, #29206.
Activity
VGerris commentedon Mar 3, 2022
I would like to add that the current implementation also seems to act upon the group settings when syncing users : when groups are added in Keycloak and the group mapping has 'Drop non-existing groups during sync' enabled, the groups never end up in LDAP and are also removed from Keycloak. So using Keycloak as the single point for users AND group management with an LDAP backend is not possible. If the option is disabled, groups removed in LDAP will not be removed in Keycloak, so currently one needs to choose between those.
When wanting LDAP to be authorative ( my assumption ) the setting has to be enabled and groups can only be created directly in LDAP, requiring an LDAP client.
As a side note, it seems Keycloak sends to requests to the LDAP server when creating a user - not sure if this is related, but in a load balanced dual master setup this causes issues when the load balancer is not set to sticky sessions ( the second call being faster sometimes then the sync operation ).
It would be a great benefit if that could be part of any effort to improve this.
scila1996 commentedon Mar 8, 2022
+1
kresnasatya commentedon Jun 20, 2022
I have the same problem with sync user group membership from Keycloak to LDAP. So, the current solution we do is save in two place: Keycloak (by Keycloak REST admin API) and LDAP query in different methods.
SchneiderMK commentedon Aug 31, 2022
Having the same issue. Are there any updates, ETA?
kikolouro commentedon Sep 21, 2022
Same issue here.
robodrome commentedon Sep 27, 2022
Same issue. The reason why I wanted to try out KeyCloak is to have one (easy) single point of user administration. Are we doing something wrong? Or is this a genuine bug/missing feature?
plevart commentedo
8000
n Jun 8, 2023
Hi,
Let me describe my observations of the behavior in the latest (21.1.1) Keycloak.
We are trying to use Active Directory as a source for Users and Groups. We configured:
We want users to be administered only in Active Directory and just want to propagate all their changes to Keycloak. This works. We synchronize ~15000 users this way and their data gets updated periodically.
We also added one or two
group-ldap-mappermappers and configured them to synchronize a subset of groups from LDAP. The settings of such mapper are:So this seems to work, although to be totally sure, we need some more testing.
One thing that doesn't work as expected is the following:We explicitly specified "Preserve Group Inheritance: ON" in group-ldap-mapper and we do get groups in a (single inheritance) hierarchy from LDAP properly connected in Keycloak, but user group memberships are nevertheless flattened, meaning if we have group A and a child group B, then when there is a user U that is a member of group B in LDAP, this user becomes member of group B in Keycloak and of group A in Keycloak. This is unnecessary flattening of memberships which is perhaps necessary when the group-ldap-mapper specifies "Preserve Group Inheritance: OFF", but in case this is ON, should not be happening.Above striked-out claim might be unfounded. I was mislead by the "Members" tab on the Groups display. When a particular Group is selected on the left-side tree-like browser, the list of group Members on the Members tab is shown and that list includes, as the last column, Membership - display of all Groups a particular user is member of. That list seems to include transitive Memberships. The list of users does not include users that are transitive members of selected group unless "Include sub-group users" checkbox is checked.
OTOH, when watching the details view for a particular User, the "Groups" tab shows groups where that user is direct member and also some (but not all) groups where it is a transitive member of. When the "Direct membership" checkbox is unchecked, the list shows all groups the user is transitive member of. So these two views (direct User members of a Group vs. direct Group membership of a User) are at least inconsistent.
wrathinmind commentedon Mar 15, 2024
same issue
Keycloak 22.0.5
JVM: 17.0.6 (Red Hat, Inc. OpenJDK 64-Bit Server VM 17.0.6+10-LTS)
OS: Linux 5.14.0-381.el9.x86_64 amd64
oculos commentedon May 30, 2024
Is there any traction on this? I feel that due the lack of a proper group sync, deleting a group on keycloak does not delete it in ldap, so the group will always reappear.
tsaarni commentedon Sep 10, 2024
@mposolda I'm curious what is missing from groups periodic sync in detail?
When I configure periodic sync (whether it's full sync or sync of changed users), it seems that in addition to syncing users, there is also a call to
LDAPStorageProviderFactory.syncMappers(). This triggers calls to eitherGroupLDAPStorageMapper.syncDataFromFederationProviderToKeycloak()orRoleLDAPStorageMapper.syncDataFromFederationProviderToKeycloak(), depending on which mapper is in use.I notice that a search is performed on the LDAP server, and groups or role mappings appear to be updated.
pedroigor commentedon Dec 20, 2024
Looks like we have two different issues here?
Do you agree? Asking because we might want to work on them separately because the second one has been being discussed in the past with some attempts to fix the problem. For instance, #29206.