-
Notifications
You must be signed in to change notification settings - Fork 0
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
Nit 1204 ldap data refresh remove passwords #42
Merged
Merged
Conversation
This file contains 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
georgepstaylor
commented
Apr 26, 2024
Comment on lines
+511
to
+554
def remove_all_user_passwords(user_ou, root_dn): | ||
log.info("Removing all user passwords") | ||
|
||
ldap_connection = ldap_connect( | ||
env.vars.get("LDAP_HOST"), | ||
env.vars.get("LDAP_USER"), | ||
env.secrets.get("LDAP_BIND_PASSWORD"), | ||
) | ||
|
||
user_filter = "(!(cn=AutomatedTestUser))" | ||
|
||
try: | ||
ldap_connection.search( | ||
",".join([user_ou, root_dn]), | ||
user_filter, | ||
attributes=["cn"], | ||
search_scope="LEVEL", | ||
) | ||
except Exception as e: | ||
log.exception("Failed to search for users") | ||
raise e | ||
|
||
found_users = [entry.entry_dn for entry in ldap_connection.entries] | ||
log.debug("Users found:") | ||
log.debug(found_users) | ||
|
||
for user in found_users: | ||
try: | ||
ldap_connection.modify( | ||
user, | ||
{ | ||
"userPassword": [ | ||
( | ||
MODIFY_DELETE, | ||
[], | ||
) | ||
] | ||
}, | ||
) | ||
log.info(f"Successfully removed passwd for user {user}, or it didn't have one to begin with") | ||
except Exception as e: | ||
log.exception(f"Failed to remove passwd for user {user}") | ||
raise e | ||
ldap_connection.unbind() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove_all_user_passwords function
andrewmooreio
approved these changes
Apr 29, 2024
georgepstaylor
added a commit
that referenced
this pull request
Jul 1, 2024
* Add initial python for updating home areas * adding comments for future work * Update rbac.py * pre=release * prerelease test * PRERELEASE * release work flow test * pre release * Update rbac.py * clean up home area function * add setuptools requirements * Update setup.py * remove quotes unneeded * Retrofit logging and env dict from rbac uplift (#17) * flexibility * logging * add shorthand options * options for log levels * Update logging.py * Update __init__.py * Nit 824 nit 823 - update user roles and user notes (#18) * new functions and structure * find common entries in both * refactor + python rewrite foruser roles * remove action * remove debugging * start oracle db * add update notes * typo + rm commented code * refactor + comments * Update __init__.py * fix logger duplicates * re format + remove print debugging * log levels + debugging * Update logger.py * fixes requirements * reformat connection for oracle * Update user.py * Update user.py * Update user.py * Update user.py * Update user.py * Update user.py * Update user.py * Update user.py * bind by name * Update user.py * Update user.py * Update user.py * Update user.py * Update user.py * Update user.py * add handling for user notes * Nit 822 (#19) * add CRC user script * add click cmd * add deactivate-crc-users to main group * Update user.py * Update requirements.txt --------- Co-authored-by: Seb Norris <[email protected]> * Nit 822 (#20) * add CRC user script * add click cmd * add deactivate-crc-users to main group * Update user.py * Update requirements.txt * Update rbac.py --------- Co-authored-by: Seb Norris <[email protected]> * Nit 822 (#21) * add CRC user script * add click cmd * add deactivate-crc-users to main group * Update user.py * Update requirements.txt * Update rbac.py * no token needed for rbac --------- Co-authored-by: Seb Norris <[email protected]> * Nit 822 (#22) * add CRC user script * add click cmd * add deactivate-crc-users to main group * Update user.py * Update requirements.txt * Update rbac.py * no token needed for rbac * Update rbac.py --------- Co-authored-by: Seb Norris <[email protected]> * Nit 822 (#23) * add CRC user script * add click cmd * add deactivate-crc-users to main group * Update user.py * Update requirements.txt * Update rbac.py * no token needed for rbac * Update rbac.py * ldap config dict or local val --------- Co-authored-by: Seb Norris <[email protected]> * Formatting & linting pre commits (#24) * add pre commit * Update readme.md * format * Update tag-and-release.yml * Update pyproject.toml * Update .flake8 * Update .flake8 * use black defualt * format to black defaults * update black to latest * remove boilerplate excludes * update logging and requirements * NIT-854 Add exception handling and add logging where appropriate * NIT-854 fix typos * Apply suggestions from code review Co-authored-by: George Taylor <[email protected]> * Update rbac.py * migration to python-ldap - correction on tree deletion (#28) * Merge branch 'main' into dev * Update .flake8 * User expiry script added * Update rbac.py (#31) * init py change added * quotations * add error handling + get the ou path from the cli input/defaults * Update format-python.yml * Nit 1204 ldap data refresh remove passwords (#42) * remove passwords command * formatting * Update user.py * Update user.py * Update user.py * Update format-python.yml * Update format-python.yml * Formatted code with black --line-length 120 * Update format-python.yml --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: adrianweetman <[email protected]> Co-authored-by: Seb Norris <[email protected]> Co-authored-by: Andrew Moore <[email protected]> Co-authored-by: Andrew Moore <[email protected]> Co-authored-by: Ijaz Sultan <[email protected]> Co-authored-by: IjazMoJ <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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.
AutomatedTestUser