Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete group memberships when deleting a user #3080

Merged
merged 1 commit into from
Feb 2, 2022

Conversation

rhafer
Copy link
Contributor

@rhafer rhafer commented Feb 1, 2022

Description

Upon deleting a User from the LDAP backend, we also need to cleanup
the user's group memberships as LDAP itself doesn't make any promises
about referential integrity.

Related Issue

@rhafer rhafer self-assigned this Feb 1, 2022
@rhafer rhafer added the Status:Needs-Review Needs review from a maintainer label Feb 1, 2022
@rhafer rhafer requested review from butonic and C0rby February 1, 2022 13:39
Copy link
Contributor

@C0rby C0rby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Approved to soon.

@C0rby C0rby self-requested a review February 1, 2022 13:48
@@ -182,6 +182,20 @@ func (i *LDAP) DeleteUser(ctx context.Context, nameOrID string) error {
if err = i.conn.Del(&dr); err != nil {
return err
}

// Find all the groups that this user was a member of and remove it from there
groupEntries, err := i.getLDAPGroupsByFilter(fmt.Sprintf("(%s=%s)", i.groupAttributeMap.member, e.DN), true, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error needs to be checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Upon deleting a User from the LDAP backend, we also need to cleanup
the user's group memberships as LDAP itself doesn't make any promises
about referential integrity.

Fixes owncloud#3027
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

22.9% 22.9% Coverage
0.0% 0.0% Duplication

@rhafer rhafer merged commit b472d55 into owncloud:master Feb 2, 2022
ownclouders pushed a commit that referenced this pull request Feb 2, 2022
Merge: b5651e6 04083a4
Author: Ralf Haferkamp <[email protected]>
Date:   Wed Feb 2 12:10:40 2022 +0100

    Merge pull request #3080 from rhafer/graph-del-user

    Delete group memberships when deleting a user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status:Needs-Review Needs review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

graph user management: deleting a user doesn't remove group membership
2 participants