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 ;
// 1st page
let value = new.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 = decode?;
if !resp.is_end
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=…>;DNand<GUID=…>;DNforms, hex and standard GUID. - ShowDeleted — marker type;
encode()returns[](caller omits controlValue). - VLV — byOffset variant encodes.
What is stubbed / partial
- VLV
greaterThanOrEqualtarget — not implemented; onlybyOffsetencodes. The type has no method for the other variant yet. - VLV response — decoder not written; consumer parses
contextIDmanually. - DirSync response OID (1.2.840.113556.1.4.842) — shares the wire shape
with the request, so
DirSyncControl::decodeworks 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-dtypcompanion. - 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
greaterThanOrEqualtarget + response decoder.
License
MIT.