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>

source

pub fn parse(i: &'a [u8]) -> Result<'_, LdapMessage<'_>>

👎Deprecated since 0.3.0: Parsing functions are deprecated. Users should instead use the FromBer trait

Parse a single LDAP message and return a structure borrowing fields from the input buffer

Trait Implementations§

source§

impl<'a> Clone for LdapMessage<'a>

source§

fn clone(&self) -> LdapMessage<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for LdapMessage<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

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§

fn from_ber(bytes: &'a [u8]) -> ParseResult<'_, Self, LdapError>

Attempt to parse input bytes into a BER object
source§

impl<'a> PartialEq for LdapMessage<'a>

source§

fn eq(&self, other: &LdapMessage<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> Eq for LdapMessage<'a>

source§

impl<'a> StructuralPartialEq for LdapMessage<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for LdapMessage<'a>

§

impl<'a> Send for LdapMessage<'a>

§

impl<'a> Sync for LdapMessage<'a>

§

impl<'a> Unpin for LdapMessage<'a>

§

impl<'a> UnwindSafe for LdapMessage<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.