Open
Conversation
…tribute searches, add robust attribute extraction and cleaning utilities
| if isinstance(obj_class_val, list): | ||
| return [str(s).strip() for s in obj_class_val] | ||
| elif isinstance(obj_class_val, str): | ||
| return [s.strip() for s in obj_class_val.replace(",", " ").split() if s.strip()] |
Collaborator
There was a problem hiding this comment.
I think this might not work as intended if the value includes spaces or escaped commas \,.
It would be fine to merge this and then update later iso needed though.
Comment on lines
46
to
47
| if not conn.entries: | ||
| logger.warning("no posix entries found for the given username.") | ||
| return None |
Collaborator
There was a problem hiding this comment.
This should probably still get logged as f"No LDAP posix entries found for {username}" or something similar.
Is it intentional to exit here in that case, or is it supposed to try the "recovery step" with OPERATIONAL_ATTRIBUTES before exiting?
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.
This PR refactors the LDAP user info retrieval logic to improve reliability and completeness of returned attributes.
Key changes:
*), then explicitly fetches operational attributes (e.g.,objectGUID,objectSid,memberOf,whenCreated,whenChanged,manager), and merges results._extract_attributeshelper to standardize extraction of LDAP entry attributes into Python dictionaries, handling bytes, lists, and strings.clean_object_classto robustly handle both string and list formats for theobjectClassattribute, ensuring consistent output.generalized_time_to_strto reliably convert LDAP generalized time strings and datetime objects to readable UTC timestamps.These changes address erratic behavior with missing attributes, ensure all required data is returned, and make downstream processing more robust and maintainable.
This PR addresses issue #8 by refactoring LDAP search logic to reliably fetch operational attributes.