Struct simple_ldap::LdapClient

source ·
pub struct LdapClient { /* private fields */ }
Expand description

Simple wrapper ontop of ldap3 crate. This wrapper provides a simple interface to perform LDAP operations including authentication.

Implementations§

source§

impl LdapClient

source

pub fn get_inner(&self) -> Ldap

Returns the ldap3 client

source§

impl LdapClient

source

pub async fn from(url: &str, bind_dn: &str, bind_pw: &str) -> Self

Open a connection to an LDAP server specified by url.

source

pub fn from_ldap(ldap: Ldap) -> Self

Create a new LdapClient from an existing Ldap connection.

source

pub async fn unbind(&mut self) -> Result<(), String>

source

pub async fn authenticate( &mut self, base: &str, uid: String, password: &String, filter: Box<dyn Filter> ) -> Result<(), Error>

The user is authenticated by searching for the user in the LDAP server. The search is performed using the provided filter. The filter should be a filter that matches a single user.

source

pub async fn search<T: for<'a> Deserialize<'a>>( &mut self, base: &str, scope: Scope, filter: &dyn Filter, attributes: Vec<&str> ) -> Result<T, Error>

Search a single value from the LDAP server. The search is performed using the provided filter. The filter should be a filter that matches a single user. if the filter matches multiple users, an error is returned. This operatrion is useful when records has single value attributes. Result will be mapped to a struct of type T.

source

pub async fn search_multi_valued<T: for<'a> Deserialize<'a>>( &mut self, base: &str, scope: Scope, filter: &dyn Filter, attributes: Vec<&str> ) -> Result<T, Error>

Search a single value from the LDAP server. The search is performed using the provided filter. The filter should be a filter that matches a single user. if the filter matches multiple users, an error is returned. This operatrion is useful when records has multi value attributes. Result will be mapped to a struct of type T.

This method is used to search multiple records from the LDAP server. The search is performed using the provided filter. This operatrion is useful when records has multi value attributes. Method will return a vector of structs of type T. return vector will be maximum of the limit provided.

source

pub async fn streaming_search_multi_valued<T: for<'a> Deserialize<'a>>( &mut self, base: &str, scope: Scope, filter: &dyn Filter, limit: i32, attributes: Vec<&str> ) -> Result<Vec<T>, Error>

This method is used to search multiple records from the LDAP server. The search is performed using the provided filter. This operatrion is useful when records has single value attributes. Method will return a vector of structs of type T. return vector will be maximum of the limit provided.

source

pub async fn create<T: for<'a> Deserialize<'a>>( &mut self, uid: &str, base: &str, data: Vec<(&str, HashSet<&str>)> ) -> Result<(), Error>

base = “ou=people,dc=example,dc=com”

source

pub async fn update( &mut self, uid: &str, base: &str, data: Vec<Mod<&str>>, new_udid: Option<&str> ) -> Result<(), Error>

source

pub async fn delete(&mut self, uid: &str, base: &str) -> Result<(), Error>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more