ldap_parser/lib.rs
1//! [](./LICENSE-MIT)
2//! [](./LICENSE-APACHE)
3//! [](https://docs.rs/ldap-parser)
4//! [](https://crates.io/crates/ldap-parser)
5//! [](https://github.com/rusticata/ldap-parser/actions)
6//! [](#rust-version-requirements)
7//!
8//! # LDAP Parser
9//!
10//! A Lightweight Directory Access Protocol (LDAP) ([RFC4511]) parser, implemented with the
11//! [nom](https://github.com/Geal/nom) parser combinator framework.
12//!
13//! It is written in pure Rust, fast, and makes extensive use of zero-copy. A lot of care is taken
14//! to ensure security and safety of this crate, including design (recursion limit, defensive
15//! programming), tests, and fuzzing. It also aims to be panic-free.
16//!
17//! The code is available on [Github](https://github.com/rusticata/ldap-parser)
18//! and is part of the [Rusticata](https://github.com/rusticata) project.
19//!
20//! # Examples
21//!
22//! Parsing an LDAP message (in BER format):
23//!
24//! ```rust
25//! use ldap_parser::FromBer;
26//! use ldap_parser::ldap::{LdapMessage, MessageID, ProtocolOp, ProtocolOpTag};
27//!
28//! static DATA: &[u8] = include_bytes!("../assets/message-search-request-01.bin");
29//!
30//! # fn main() {
31//! let res = LdapMessage::from_ber(DATA);
32//! match res {
33//! Ok((rem, msg)) => {
34//! assert!(rem.is_empty());
35//! //
36//! assert_eq!(msg.message_id, MessageID(4));
37//! assert_eq!(msg.protocol_op.tag(), ProtocolOpTag::SearchRequest);
38//! match msg.protocol_op {
39//! ProtocolOp::SearchRequest(req) => {
40//! assert_eq!(req.base_object.0, "dc=rccad,dc=net");
41//! },
42//! _ => panic!("Unexpected message type"),
43//! }
44//! },
45//! _ => panic!("LDAP parsing failed: {:?}", res),
46//! }
47//! # }
48//! ```
49//!
50//! [RFC4511]: https://tools.ietf.org/html/rfc4511
51
52#![deny(/*missing_docs,*/
53 unstable_features,
54 unused_import_braces, unused_qualifications)]
55#![warn(
56 missing_debug_implementations,
57 /* missing_docs,
58 rust_2018_idioms,*/
59 unreachable_pub
60)]
61#![forbid(unsafe_code)]
62#![deny(rustdoc::broken_intra_doc_links)]
63#![doc(test(
64 no_crate_inject,
65 attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
66))]
67#![cfg_attr(docsrs, feature(doc_cfg))]
68
69pub mod error;
70pub mod filter;
71mod filter_parser;
72pub mod ldap;
73mod parser;
74
75pub use parser::*;
76
77pub use asn1_rs;
78pub use asn1_rs::nom::{Err, IResult};
79pub use asn1_rs::FromBer;