https://github.com/rusticata/ldap-parser
LDAP parser written in pure Rust. Fast, zero-copy, safe.
https://github.com/rusticata/ldap-parser
Last synced: 2 months ago
JSON representation
LDAP parser written in pure Rust. Fast, zero-copy, safe.
- Host: GitHub
- URL: https://github.com/rusticata/ldap-parser
- Owner: rusticata
- License: apache-2.0
- Created: 2020-11-21T12:11:50.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-18T07:45:47.000Z (10 months ago)
- Last Synced: 2025-03-29T17:34:06.389Z (9 months ago)
- Language: Rust
- Size: 77.1 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README

[](./LICENSE-MIT)
[](./LICENSE-APACHE)
[](https://docs.rs/ldap-parser)
[](https://crates.io/crates/ldap-parser)
[](https://github.com/rusticata/ldap-parser/actions)
[](#rust-version-requirements)
# LDAP Parser
A Lightweight Directory Access Protocol (LDAP) ([RFC4511]) parser, implemented with the
[nom](https://github.com/Geal/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](https://github.com/rusticata/ldap-parser)
and is part of the [Rusticata](https://github.com/rusticata) project.
# Examples
Parsing an LDAP message (in BER format):
```rust
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),
}
```
[RFC4511]: https://tools.ietf.org/html/rfc4511
## Changes
See [CHANGELOG.md](CHANGELOG.md)
# License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
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.