Repository navigation
Conversation
When a group disappeared from LDAP, the cached memberships were deleted before they were read to dispatch the events, so no UserRemovedEvent was ever sent. Listeners like the share manager, the external storage mount cache or the activity app therefore never learned that the members lost the group. The group manager also usually cannot resolve such a group anymore, as the LDAP backend no longer reports it, so fall back to a backend-less group object carrying the group id. The test also calls the parent setUp, without which the test class fails when run on its own. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Sending UserRemovedEvent for removed groups lets listeners clean up, some of them irreversibly (e.g. share cleanup). Therefore: - Do not treat all known groups as removed when LDAP returns no groups at all, which usually means a broken group configuration. - Skip users that are still in a group with the same id provided by another backend. - Handle one group at a time and delete its memberships only after the events were sent, so a failing listener does not lose the events of the remaining members and memory stays bounded. - Apply the same group fallback on login, where the membership was removed but the event was dropped for groups no longer in LDAP. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Being absent from the group list does not prove that a group is gone, e.g. when one of several configurations returns incomplete results. Removal events trigger irreversible cleanup in listeners, so verify the group against LDAP without cache first and keep the memberships of groups that still exist. This makes the stricter empty-result guard unnecessary, which also blocked the cleanup when the last group was removed on purpose. The check for a same-named group from another backend now only asks the non-LDAP backends, because the cached LDAP membership of a just removed group can be stale and would suppress the event for good. It is shared by all places that dispatch removal events, including the login path and members leaving a group that still exists. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Groups that still exist on LDAP are now kept, so listing every candidate as removed would make the log misleading. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
susnux
marked this pull request as ready for review
December 2, 2026 11:32
susnux
requested review from
a team,
Altahrim and
come-nc
and removed request for
a team
December 2, 2026 11:32
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a group disappears from LDAP, the
UpdateGroupsbackground job never dispatchedUserRemovedEventfor its former members.UpdateGroupsService::handleRemovedGroups()deleted the cached memberships first and then read them to send the events, so it always found nothing. This has been the case since the move to the flatldap_group_membershiptable (Nextcloud 28).Even with the order fixed, the events would still be skipped:
IGroupManager::get()returnsnullfor such a group becauseGroup_LDAP::groupExists()can no longer read it from LDAP. A group object that has no backends but carries the group id is now used as a fallback. All listeners in server only read the gid from it (share manager, external storage mount cache, activity, admin audit, collaboration resources).As a result, listeners now learn that members lost the group, which also covers apps that keep their own membership copies (e.g. Teams).
Some listeners clean up irreversibly (the share manager removes the user's group share customizations and, with "share with group members only", user shares without a common group). This matches what already happens when a user leaves a group that still exists, but to keep it from firing by accident:
groupExistsOnLDAP($gid, true)). If it still exists, e.g. because one of several configurations returned incomplete results, its memberships are kept and no event is sent. An unreachable server throws and aborts the job as before.Deactivating an LDAP configuration does not trigger mass events: its users can no longer be resolved, so no event is sent for them.
The dispatching is shared by all removal paths: removed groups, members leaving a group that still exists, and
LoginListener. The login path had the same problem for a single user: it deleted the membership and then dropped the event because the group could not be resolved.GroupDeletedEventis intentionally still not dispatched. It was removed in 7732de7 because a group that is no longer returned by LDAP is not necessarily deleted (filter change, temporary partial results), and its listeners delete the group shares themselves. That is why #38618 (group shares staying in place) is related but not resolved by this PR.The test class also gets the missing
parent::setUp()call; without itUpdateGroupsServiceTesterrors intearDown()when run on its own.How to test
occ ldap:check-group <gid> --update).OCA\User_LDAP\Jobs\UpdateGroupsjob, e.g.occ background-job:execute --force-execute <id>.TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)
Assisted by ClaudeCode:claude-opus-5-5
🤖 Generated with Claude Code