Struct ldap_parser::ldap::LdapMessage
source · pub struct LdapMessage<'a> {
pub message_id: MessageID,
pub protocol_op: ProtocolOp<'a>,
pub controls: Option<Vec<Control<'a>>>,
}
Expand description
An LDAP Message according to RFC4511
Parse a single LDAP message and return a structure borrowing fields from the input buffer
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),
}
Fields§
§message_id: MessageID
Message Identifier (32-bits unsigned integer)
The messageID of a request MUST have a non-zero value different from the messageID of any other request in progress in the same LDAP session. The zero value is reserved for the unsolicited notification message.
protocol_op: ProtocolOp<'a>
The LDAP operation from this LDAP message
controls: Option<Vec<Control<'a>>>
Message controls (optional)
Controls provide a mechanism whereby the semantics and arguments of existing LDAP operations may be extended. One or more controls may be attached to a single LDAP message. A control only affects the semantics of the message it is attached to.
Implementations§
source§impl<'a> LdapMessage<'a>
impl<'a> LdapMessage<'a>
sourcepub fn parse(i: &'a [u8]) -> Result<'_, LdapMessage<'_>>
👎Deprecated since 0.3.0: Parsing functions are deprecated. Users should instead use the FromBer trait
pub fn parse(i: &'a [u8]) -> Result<'_, LdapMessage<'_>>
Parse a single LDAP message and return a structure borrowing fields from the input buffer
Trait Implementations§
source§impl<'a> Clone for LdapMessage<'a>
impl<'a> Clone for LdapMessage<'a>
source§fn clone(&self) -> LdapMessage<'a>
fn clone(&self) -> LdapMessage<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for LdapMessage<'a>
impl<'a> Debug for LdapMessage<'a>
source§impl<'a> FromBer<'a, LdapError> for LdapMessage<'a>
impl<'a> FromBer<'a, LdapError> for LdapMessage<'a>
Parse a single LDAP message and return a structure borrowing fields from the input buffer
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),
}
source§impl<'a> PartialEq for LdapMessage<'a>
impl<'a> PartialEq for LdapMessage<'a>
source§fn eq(&self, other: &LdapMessage<'a>) -> bool
fn eq(&self, other: &LdapMessage<'a>) -> bool
self
and other
values to be equal, and is used
by ==
.