Crate ldap_parser

Source
Expand description

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::FromBer;
use ldap_parser::ldap::{LdapMessage, MessageID, ProtocolOp, ProtocolOpTag};

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

let res = LdapMessage::from_ber(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),
}

Re-exports§

pub use asn1_rs;

Modules§

error
LDAP errors
filter
Definition for types used in LDAP filters
ldap
Definitions for LDAP types

Enums§

Err
The Err enum indicates the parser was not successful

Traits§

FromBer
Base trait for BER object parsers

Functions§

parse_ldap_messageDeprecated
parse_ldap_messages
Parse a list of LDAP messages and return a structure borrowing fields from the input buffer

Type Aliases§

IResult
Holds the result of parsing functions