Skip to content

Use REPLACE for attributes without equality matching - #1595

Open
arimu1 wants to merge 1 commit into
spring-projects:mainfrom
arimu1:gh-1263
Open

Use REPLACE for attributes without equality matching#1595
arimu1 wants to merge 1 commit into
spring-projects:mainfrom
arimu1:gh-1263

Conversation

@arimu1

@arimu1 arimu1 commented Aug 17, 2026

Copy link
Copy Markdown

DirContextAdapter.getModificationItems() used REMOVE-by-value for partial updates of multi-valued attributes. That fails on strict directories (for example OpenLDAP) for types without an equality matching rule such as facsimileTelephoneNumber (RFC 4519). RFC 2251 section 4.6 requires REPLACE of remaining values instead.

NameAwareAttribute now records whether equality matching is defined (RFC 4519 types without it, plus an explicit constructor). Ordered attributes and types without equality matching are replaced in full; attributes with equality matching keep per-value ADD/REMOVE.

Summary

  • REPLACE remaining values when an attribute has no equality matching rule
  • Preserve REMOVE-by-value when equality matching is defined

Fixes #1263
Closes gh-1263

Test plan

  • Proved FAIL on main (4b8ac9e5) for facsimileTelephoneNumber remove-one-of-two (REMOVE-by-value)
  • ./gradlew :spring-ldap-core:test --tests org.springframework.ldap.core.DirContextAdapterTests --tests org.springframework.ldap.core.DirContextAdapterBugTests --tests org.springframework.ldap.core.NameAwareAttributeTests --tests org.springframework.ldap.core.NameAwareAttributesTests (JDK 21)
  • ./gradlew :spring-ldap-core:checkstyleMain :spring-ldap-core:checkstyleTest :spring-ldap-core:checkFormat

RFC 2251 section 4.6 forbids deleting individual values of attributes
without an equality matching rule. Collect remaining values with
REPLACE instead of REMOVE-by-value.

Closes spring-projectsgh-1263

Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>

@jzheaux jzheaux left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, @arimu1, for the PR! I've left my feedback inline.

* matching rule. Per RFC 2251 §4.6, clients must REPLACE remaining values rather than
* REMOVE individual values for these types.
*/
private static final Set<String> ATTRS_WITHOUT_EQUALITY_MATCHING_RULE = Set.of("facsimiletelephonenumber", "fax",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd prefer that NameAwareAttribute remain unaware of schema unless we are going to implement getAttributeDefinition. And since DirContextAdapter is the only thing that needs to know whether an attribute has equality-matching, I think we can move this set there and have getModificationItems consult it internally. Will this work for you?

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.

getModificationItems() produces wrong results for attributes without an equality matching rule

2 participants