msldap-ext 0.1.0

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: 34.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 623.4 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • icedracon/msldap-ext
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • icedracon

msldap-ext

Crates.io Docs.rs License: MIT

Encoder/decoder for the MS-ADTS LDAP extension controls that mainstream Rust LDAP clients (ldap3, native_tls_ldap, …) do not ship. Built for offensive-AD tooling that has to page through millions of objects, walk tombstones, replicate incrementally with DirSync, or slice nTSecurityDescriptor by SD_FLAGS — all the things impacket / ldap3.py / ldapdomaindump do today with hand-crafted BER.

Status

0.1.0-dev — pre-alpha, expect breaking changes before 0.1.0. Part of the icedracon Rust offensive AD ecosystem.

What it does

Pure BER control-value codecs for the six MS-ADTS controls an attacker actually reaches for. The crate does not open sockets — it produces the byte blob you feed into ldap3::Ldap::search_ext (or any LDAP transport) as the controlValue of a Control SEQUENCE, and decodes the response-side control value back into a typed struct.

OID Control Spec Where it shows up
1.2.840.113556.1.4.319 Paged Results RFC 2696 Any AD search past MaxPageSize (1000)
1.2.840.113556.1.4.529 ExtendedDN MS-ADTS §3.1.1.3.4.1.5 objectGUID + objectSid inline with DN
1.2.840.113556.1.4.801 SD_FLAGS MS-ADTS §3.1.1.3.4.1.11 Read owner/DACL/SACL slices of nTSecurityDescriptor
1.2.840.113556.1.4.417 ShowDeleted MS-ADTS §3.1.1.3.4.1.14 Include tombstones (deleted-object recovery)
1.2.840.113556.1.4.841 DirSync MS-ADTS §3.1.1.3.4.1.3 Incremental replication of a naming context
2.16.840.1.113730.3.4.9 VLV draft-ietf-ldapext-ldapv3-vlv Virtual List View (byOffset only)

Hand-rolled BER (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

use msldap_ext::{PagedResults, PAGED_RESULTS_OID};

// First page: encode a Paged Results control asking for 1000 rows.
let value = PagedResults::new(1000).encode();
// -> pass (PAGED_RESULTS_OID, is_critical = true, Some(value))
//    into ldap3::Ldap::search_ext as the request control.

// Server returns a control with the same OID. Decode its value:
let resp = PagedResults::decode(&server_control_value)?;
if !resp.is_end() {
    // Cookie non-empty — ask for the next page.
    let next = PagedResults::with_cookie(1000, resp.cookie.unwrap()).encode();
    // ...next search_ext call with `next` as the controlValue...
}
# Ok::<(), msldap_ext::Error>(())

What works / what does not (this version)

  • Working
    • PagedResults — full round-trip (encode + decode, initial + with-cookie).
    • SdFlags — encode/decode plus owner_dacl() / sacl() / all() helpers.
    • DirSyncControl — 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).
    • VirtualListView — byOffset variant encodes.
  • Stubbed / partial
    • VLV greaterThanOrEqual target — no method yet.
    • VLV response decoder — not written; consumer parses contextID manually.
    • DirSync response OID (1.2.840.113556.1.4.842) — shares wire shape with the request, so DirSyncControl::decode handles both; a distinct response type would be clearer.
    • ExtendedDn SID — response parser keeps the raw "S-1-5-…" string; binary SID decode is deferred to an ms-dtyp companion.
    • BER long-length encode > 4 bytes — refused. Fine for control values.
  • Not planned for 0.1.0
    • Property-based round-trip tests, live-DC integration harness, no_std.

Related icedracon crates

  • ms-even6 — MS-EVEN6 EventLog Remoting v6 client + BinXml decoder (remote log pulls over \pipe\eventlog).
  • ms-tds — TDS 7.4 client for Microsoft SQL Server with NTLM login and pentest primitives.

Together the three cover the LDAP / EventLog / MSSQL data-plane primitives that Python + impacket dominate today.

License

MIT (c) 2026 zevs