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
impl LdapClient
sourcepub async fn from(url: &str, bind_dn: &str, bind_pw: &str) -> Self
pub async fn from(url: &str, bind_dn: &str, bind_pw: &str) -> Self
Open a connection to an LDAP server specified by url
.
pub async fn unbind(&mut self) -> Result<(), String>
sourcepub async fn authenticate(
&mut self,
base: &str,
uid: String,
password: &String,
filter: Box<dyn Filter>
) -> Result<(), Error>
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.
sourcepub async fn search<T: for<'a> Deserialize<'a>>(
&mut self,
base: &str,
scope: Scope,
filter: &dyn Filter,
attributes: Vec<&str>
) -> Result<T, Error>
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.
sourcepub 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>
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.
sourcepub async fn streaming_search<T: for<'a> Deserialize<'a>>(
&mut self,
base: &str,
scope: Scope,
filter: &dyn Filter,
limit: i32,
attributes: Vec<&str>
) -> Result<Vec<T>, Error>
pub async fn streaming_search<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 multi value attributes. Method will return a vector of structs of type T. return vector will be maximum of the limit provided.
sourcepub 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>
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.
sourcepub async fn create<T: for<'a> Deserialize<'a>>(
&mut self,
uid: &str,
base: &str,
data: Vec<(&str, HashSet<&str>)>
) -> Result<(), Error>
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”