A ldap client library that wraps ldap3 to make it easy to use.
Currently this is in early alpha stage. Library only support use asynchronously.
cargo add simple-ldap
```rust use simple-ldap::{LdapClient,Error,EqFilter}; use simple-ldap::ldap3::Scope;
fn main() -> Result<()> { let mut ldap = LdapClient::from( "ldap://localhost:1389/dc=example,dc=com", "cn=manager", "password", ) .await;
let data = vec![
(
"objectClass",
HashSet::from(["organizationalPerson", "inetorgperson", "top", "person"]),
),
(
"uid",
HashSet::from(["bd9b91ec-7a69-4166-bf67-cc7e553b2fd9"]),
),
("cn", HashSet::from(["Kasun"])),
("sn", HashSet::from(["Ranasingh"])),
];
let result = ldap
.create(
"bd9b91ec-7a69-4166-bf67-cc7e553b2fd9",
"ou=people,dc=example,dc=com",
data,
)
.await;
Ok(ldap.unbind().await?)
} ```
```rust use simple-ldap::{LdapClient,Error,EqFilter}; use simple-ldap::ldap3::Scope;
fn main() -> Result<()> {
let mut ldap = LdapClient::from(
"ldap://localhost:1389/dc=example,dc=com",
"cn=manager",
"password",
)
.await;
let namefilter = EqFilter::from("cn".tostring(), "Sam".tostring());
let user = ldap
.search::
rust
async fn main() -> Result<()> {
let mut ldap = LdapClient::from(
"ldap://localhost:1389/dc=example,dc=com",
"cn=manager",
"password",
)
.await;
let data = vec![
Mod::Replace("cn", HashSet::from(["Jhon_Update"])),
Mod::Replace("sn", HashSet::from(["Eliet_Update"])),
];
let result = ldap
.update(
"e219fbc0-6df5-4bc3-a6ee-986843bb157e",
"ou=people,dc=example,dc=com",
data,
Option::None,
)
.await;
Ok(ldap.unbind().await?)
}