msldap-ext 0.1.0-dev

Encoder/decoder for MS-ADTS LDAP extension controls (Paged Results, ExtendedDN, SDFlags, ShowDeleted, DirSync, VLV). Pure BER — no transport.
Documentation
  • Coverage
  • 33.33%
    28 out of 84 items documented0 out of 37 items with examples
  • Size
  • Source code size: 32.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 925.2 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • icedracon

msldap-ext

STATUS: pre-alpha (0.1.0-dev). Not on crates.io. API will change.

Encoders/decoders for the MS-ADTS LDAP extension controls that ldap3 does not ship:

OID Control Where used
1.2.840.113556.1.4.319 Paged Results Every AD search past 1000 results
1.2.840.113556.1.4.529 ExtendedDN Return objectGUID + objectSid inline with DN
1.2.840.113556.1.4.801 SD_FLAGS Select owner/DACL/SACL slices of nTSecurityDescriptor
1.2.840.113556.1.4.417 ShowDeleted Include tombstones in search
1.2.840.113556.1.4.841 DirSync Incremental replication of a naming context
2.16.840.1.113730.3.4.9 VLV Virtual List View (byOffset only in 0.1.0-dev)

Pure BER codec. This crate does not open sockets — you feed the encoded bytes into ldap3::Ldap::search_ext (or any transport) as the controlValue of an LDAP Control SEQUENCE, and decode response-side control values back into typed structs.

Design

Hand-rolled BER (see src/ber.rs, ~130 LOC) instead of pulling rasn. The control values here only exercise SEQUENCE / INTEGER / OCTET STRING / one context-specific tag, and this keeps the dep graph flat (uuid, thiserror).

Usage sketch

use msldap_ext::{PagedResults, PAGED_RESULTS_OID};

// 1st page
let value = PagedResults::new(1000).encode();
// ...pass (PAGED_RESULTS_OID, is_critical=true, Some(value)) into ldap3...

// server returns a control with the same OID; decode its value:
let resp = PagedResults::decode(&server_control_value)?;
if !resp.is_end() {
    let next = PagedResults::with_cookie(1000, resp.cookie.unwrap()).encode();
    // ...next page...
}

What works in 0.1.0-dev

  • Paged Results — full round-trip (encode + decode, initial + with-cookie).
  • SD_FLAGS — encode/decode, owner_dacl() / sacl() / all() helpers.
  • DirSync — encode/decode, request-side flag constants.
  • ExtendedDN — request encode; response-string parser handles both <GUID=…>;<SID=…>;DN and <GUID=…>;DN forms, hex and standard GUID.
  • ShowDeleted — marker type; encode() returns [] (caller omits controlValue).
  • VLV — byOffset variant encodes.

What is stubbed / partial

  • VLV greaterThanOrEqual target — not implemented; only byOffset encodes. The type has no method for the other variant yet.
  • VLV response — decoder not written; consumer parses contextID manually.
  • DirSync response OID (1.2.840.113556.1.4.842) — shares the wire shape with the request, so DirSyncControl::decode works for both, but a distinct response type would be clearer.
  • ExtendedDN SID — response parser stores the SID as the raw string bytes it saw ("S-1-5-…"). Binary SID decode is deferred to an ms-dtyp companion.
  • BER long-length encode > 4 bytes — refused. Fine for control values; would break for pathological inputs.

Known gaps

  • No property-based / random round-trip tests. Only known-vector round-trips.
  • No integration test against a live DC — verified by hand-computed BER bytes.
  • No no_std.

Next steps

  • Live-DC integration: point at a lab AD, confirm each control against a real Windows Server response, capture pcaps as fixtures.
  • Add ExtendedDN response-side helper that walks a list of DNs from a search result and parses each.
  • Add DirSync response type and cookie-continuation helper.
  • VLV greaterThanOrEqual target + response decoder.

License

MIT.