Filter out deleted AD users unless otherwise instructed #548
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.
Tracking
https://bitwarden.atlassian.net/browse/PM-10380
Type of change
Objective
Directory Connector is deleting existing users even without the "Overwrite existing users" flag set. This happens for Active Directory configurations that have the Active Directory "Recycle Bin" enabled. This is a very specific and IdP configuration related bug, and so has probably flown under the radar for some time.
Code changes
This issue is caused because Directory Connector always checks for deleted users for Active Directory configurations, even with a live sync without the overwrite flag set. Adding a condition to the
getUsers
query for LDAP that returns early before searching for deleted users if the the sync is non-test and the overwrite flag is not set allows the users to come through in reports of a test sync, but stops them from being overwritten when a live sync is preformed. This mirrors the way disabled/deleted users work for other directory types.I've also added some inline documentation to this section of the code, since it required a lot of research to figure out exactly what was even happening here.
Screenshots
For a recreation of the issue see Jira. The below recording shows the behavior post-fix.
Screen.Recording.2024-08-09.at.2.10.31.PM.mov