Skip to content

A smoll collection of LDAP protocol conformance fixes - #81

Merged
Firstyear merged 7 commits into
kanidm:masterfrom
rumba-id:protocol-fixes
Aug 18, 2026
Merged

A smoll collection of LDAP protocol conformance fixes#81
Firstyear merged 7 commits into
kanidm:masterfrom
rumba-id:protocol-fixes

Conversation

@danielsreichenbach

Copy link
Copy Markdown
Contributor

Protocol fixes

Thank you so much for providing this crate. It has been insanely helpful in my own work, and so I would like to contribute back a few fixes I have been running in my own fork for a while.

I do hope my understanding of the RFCs is correct here.

serverSaslCreds wire tag (RFC 4511 §4.2.2)

serverSaslCreds is now encoded as [7] IMPLICIT OCTET STRING (0x87) instead of a universal OCTET STRING (0x04). The previous encoding was rejected with LDAP_PROTOCOL_ERROR e.g. by Samba's ldb client, Windows, and OpenLDAP. The encode side now matches the existing parse side.

Server-Side Sort request control (RFC 2891 §1.1)

  • Parses the 1.2.840.113556.1.4.473 request control: SortKeyList with attributeType, optional [0] orderingRule, optional [1] reverseOrder.
  • Preserves sort-key precedence order (previously reversed by the parser's stack-pop).
  • Rejects malformed keys: attributeType must be an OCTET STRING; unknown tags are a ControlBer error.
  • reverseOrder is no longer emitted when FALSE — RFC 4511 §5.1 requires default values to be absent.
  • Enforces a non-empty key list.

SearchResultReference builder (RFC 4511 §4.5.3)

New SearchRequest::gen_result_reference helper so servers can emit continuation references, plus a LdapSearchResultReference re-export.

SIZE (1..MAX) enforcement

Empty SearchResultReference URI lists and empty sort key lists are rejected at parse time.

Bind version enforcement tests (RFC 4511 §4.2)

Tests for the existing version-3-only parse check (version 2 rejected, version 3 accepted).

Testing

I added some regression tests this time:

  • raw-wire assertions (saslCreds 0x87 byte, absence of the default reverseOrder tag),
  • direct BER-parse tests for every legal SortKeyList shape plus malformed inputs,
  • codec round-trips (sort control, search result reference, SASL bind response).

@Firstyear Firstyear left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice set of changes! Thank you!

I reviewed all your dot-points here and it does seem you are correct WRT to the RFC and these points.

Feel free to add yourself to contributors.md as well.

Do you have other changes you want to make as well? I think just out of an abundance of caution when I do the release I'll bump the version just in case the saslCred change causes a problem for someone.

@Firstyear
Firstyear merged commit 4155522 into kanidm:master Aug 18, 2026
1 check passed
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