Skip to content

Allow for Modlist with ordered attribute values - #604

Open
tacerus wants to merge 2 commits into
python-ldap:mainfrom
tacerus:ldap-order
Open

tacerus wants to merge 2 commits into
python-ldap:mainfrom
tacerus:ldap-order

Conversation

@tacerus

@tacerus tacerus commented Jan 13, 2026

Copy link
Copy Markdown

In some LDAP implementations attribute ordering is relevant. Allow for modifications which consider the order of attributes by implementing an optional "strict_order_attr_types" parameter which takes a list of attributes to exempt from the transformation to a set.

@tacerus

tacerus commented Jan 14, 2026

Copy link
Copy Markdown
Author

FYI I tried to run the automatic formatting target but it reformatted lots of existing files in the repository, so I did not include that here.

In some LDAP implementations attribute ordering is relevant. Allow for
modifications which consider the order of attributes by implementing
an optional "strict_order_attr_types" parameter which takes a list of
attributes to exempt from the transformation to a set.

Signed-off-by: Georg Pfuetzenreuter <[email protected]>
Comment thread Lib/ldap/modlist.py
Comment on lines +95 to +97
normalize = bytes.lower if attrtype_lower in case_ignore_attr_types_set else lambda v: v
collection = list if attrtype_lower in strict_order_attr_types_set else set
replace_attr_value = collection(map(normalize, old_value)) != collection(map(normalize, new_value))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I allowed myself to rebase your branch @tacerus - and placed a commit on top of it which simplifies the logic a bit.

What I don't really like is that clients need to maintain a list of attributes which are affected by this.
My personal preference would be to use that behavior always - and require the clients to do it the other way round - if they want to eliminate some replace-operations they should not reorder (use sets instead).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants