Repository navigation
Conversation
…ng rules An imported remote attribute type that declares no equality or ordering matching rule the bundled schema can resolve was registered with that rule left null. A strict schema then rejects assertions on it: an equality filter cannot be evaluated, and a range (>=, <=) filter fails to even parse with ERR_13301_NO_ORDERING_MR_FOR_AT - which blocks Active Directory delta-sync clients that filter with e.g. (uSNChanged>=N). When the rule cannot be resolved, fall back to the octet-string matching rules (octetStringMatch for equality, octetStringOrderingMatch for ordering) instead of dropping it to null, mirroring the existing octet-string syntax fallback and the bundled octet-string attribute types (e.g. objectGUID). The ordering fallback is applied only when the bundled schema actually defines the rule, so an environment without it keeps the previous behavior. The octet-string rules compare raw bytes; the backend forwards the real comparison to the remote server, which applies its own schema. Add unit tests for both fallbacks, including one that reproduces the delta-sync range filter that previously failed to parse, and document the fallback in the extraAttributes section of service_ldap_server.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The DirectoryString test checks schema registration but lacks behavioral coverage for value preservation, deduplication, and equality-filter assertion round-tripping under the octet-string equality rule.
1 open issue
What changed in this PR
This PR adds matching-rule fallbacks to Knox’s remote LDAP schema imports, enabling equality and range filters needed by clients such as Active Directory delta-sync tools.
Changes:
- Fall back to octet-string equality and ordering rules when remote rules cannot be resolved, checking ordering-rule availability first.
- Add warning messages and tests for fallback registration and range-filter parsing.
- Document fallback behavior and byte-based comparison semantics.
| File | Description |
|---|---|
| knox-site/docs/service_ldap_server.md | Explains matching-rule fallbacks for extra attributes. |
| gateway-server/src/test/java/org/apache/knox/gateway/services/ldap/backend/LdapProxyBackendTest.java | Tests fallback rules and AD-style range-filter parsing. |
| gateway-server/src/main/java/org/apache/knox/gateway/services/ldap/LdapMessages.java | Adds warnings for equality and ordering fallbacks. |
| gateway-server/src/main/java/org/apache/knox/gateway/services/ldap/backend/LdapProxyBackend.java | Applies fallback matching rules during remote attribute import. |
Review effort: Balanced
| return resolved; | ||
| } | ||
| LOG.ldapRemoteAttributeEqualityFallback(getName(), remoteType.getName(), String.valueOf(remoteType.getEqualityOid())); | ||
| return OCTET_STRING_MATCH_OID; |
There was a problem hiding this comment.
I updated the code and tests to use caseIgnoreMatch instead of octetStringMatch to compare human readable attributes.
There was a problem hiding this comment.
@handavid - this seems worth looking into. Can you take a look?
There was a problem hiding this comment.
yes. I've addressed this in e44ac9f. The issue occurs if a remote attribute type has a syntax but not a equality or ordering. The previous code defaulted to octetStringMatch, but that is only for binary values. RemoteSchemaConverter would call Entry.contains for anything it thought was "human readable" which would cause a ClassCastException as it tried to coerce a byte[] into a String. This is fixed by only using the octetStringMatch when the syntax is octet string and using caseIgnoreMatch otherwise.
Test Results 5 files 5 suites 1m 23s ⏱️ Results for commit f32e89a. |
The equality/ordering fallback registered an octet-string matching rule regardless of the attribute's syntax. Pairing octetStringMatch (a byte-array comparator) with a human-readable syntax such as DirectoryString throws a ClassCastException the first time a String value is compared under it - for example in RemoteSchemaConverter.copyAttribute, whose deduplication contains() check runs on every copied value. Make the fallback follow the resolved syntax: - An octet-string (binary) syntax - including a syntax coerced to octet string because the bundled schema did not know it (e.g. AD LargeInteger on uSNChanged) - takes the octet-string rules (octetStringMatch, octetStringOrderingMatch), overriding any rule the remote declared for the original, now-dropped syntax. - A human-readable syntax keeps the remote's declared rule when the bundled schema resolves it, otherwise equality falls back to caseIgnoreMatch (a string rule) and ordering is left as declared-or-null; a string ordering rule is not synthesised. Add a behavioral regression that copies multiple distinct values (including non-ASCII) through copyAttribute under the fallback equality rule, verifying values are preserved verbatim, a value already on the target is not duplicated, and an equality filter parses and serialises without changing its assertion value. Without the fix this test fails with the ClassCastException above. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

KNOX-3604 - Give imported remote attributes usable equality and ordering rules
What changes were proposed in this pull request?
An imported remote attribute type that declares no equality or ordering matching rule the bundled schema can resolve was registered with that rule left null. A strict schema then rejects assertions on it: an equality filter cannot be evaluated, and a range (>=, <=) filter fails to even parse with ERR_13301_NO_ORDERING_MR_FOR_AT - which blocks Active Directory delta-sync clients that filter with e.g. (uSNChanged>=N).
When the rule cannot be resolved, fall back to the octet-string matching rules (octetStringMatch for equality, octetStringOrderingMatch for ordering) instead of dropping it to null, mirroring the existing octet-string syntax fallback and the bundled octet-string attribute types (e.g. objectGUID). The ordering fallback is applied only when the bundled schema actually defines the rule, so an environment without it keeps the previous behavior. The octet-string rules compare raw bytes; the backend forwards the real comparison to the remote server, which applies its own schema.
Add unit tests for both fallbacks, including one that reproduces the delta-sync range filter that previously failed to parse, and document the fallback in the extraAttributes section of service_ldap_server.md.
How was this patch tested?
New unit tests were added to that parse a search filter with the imported attribute using a range filter.
Manual tests were run against Active Directory using the
uSNChangedattribute. This previously failed with the error ERR_13301_NO_ORDERING_MR_FOR_AT but now works.Integration Tests
No integration tests were added since the remote ldap has the same schema as the ldap proxy.
UI changes
No UI changes