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()] |
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.
| if not conn.entries: | ||
| logger.warning("no posix entries found for the given username.") | ||
| return None |
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?
There was a problem hiding this comment.
The previous code required additional updates, I have also discovered new observations with inconsistencies, which led to further adjustments. I hope the latest changes address this comment.
|
These changes include
Summary of the code flow now would be
|
|
Given these inconsistencies, wouldn't it be nice to enhance logging and result tracking.
What do you think? |
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.