#ldap #parser #nom

ldap-parser

Parser for the LDAP protocol (RFC 4511)

5 releases

0.2.0 Sep 13, 2021
0.1.3 Feb 8, 2021
0.1.2 Nov 29, 2020
0.1.1 Nov 25, 2020
0.1.0 Nov 22, 2020

#3 in #ldap

Download history 69/week @ 2021-06-06 50/week @ 2021-06-13 61/week @ 2021-06-20 61/week @ 2021-06-27 64/week @ 2021-07-04 37/week @ 2021-07-11 41/week @ 2021-07-18 45/week @ 2021-07-25 97/week @ 2021-08-01 71/week @ 2021-08-08 73/week @ 2021-08-15 55/week @ 2021-08-22 48/week @ 2021-08-29 25/week @ 2021-09-05 38/week @ 2021-09-12 59/week @ 2021-09-19

234 downloads per month

MIT/Apache

66KB
1K SLoC

License: MIT Apache License 2.0 docs.rs crates.io Github CI Minimum rustc version

LDAP Parser

A Lightweight Directory Access Protocol (LDAP) (RFC4511) parser, implemented with the nom parser combinator framework.

It is written in pure Rust, fast, and makes extensive use of zero-copy. A lot of care is taken to ensure security and safety of this crate, including design (recursion limit, defensive programming), tests, and fuzzing. It also aims to be panic-free.

The code is available on Github and is part of the Rusticata project.

Examples

Parsing an LDAP message (in BER format):

use ldap_parser::parse_ldap_message;
use ldap_parser::ldap::{MessageID, ProtocolOp, ProtocolOpTag};

static DATA: &[u8] = include_bytes!("../assets/message-search-request-01.bin");

let res = parse_ldap_message(DATA);
match res {
    Ok((rem, msg)) => {
        assert!(rem.is_empty());
        //
        assert_eq!(msg.message_id, MessageID(4));
        assert_eq!(msg.protocol_op.tag(), ProtocolOpTag::SearchRequest);
        match msg.protocol_op {
            ProtocolOp::SearchRequest(req) => {
                assert_eq!(req.base_object.0, "dc=rccad,dc=net");
            },
            _ => panic!("Unexpected message type"),
        }
    },
    _ => panic!("LDAP parsing failed: {:?}", res),
}

Changes

See CHANGELOG.md

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.5MB
~51K SLoC