#ldap #async #high-level

simple-ldap

A high-level LDAP client for Rust

9 releases (major breaking)

Uses new Rust 2024

8.0.0 Aug 29, 2025
7.1.0 Aug 5, 2025
7.0.1 May 19, 2025
6.0.1 Apr 17, 2025
0.0.4 Jun 4, 2023

#421 in Authentication

Download history 56/week @ 2025-07-22 119/week @ 2025-07-29 203/week @ 2025-08-05 104/week @ 2025-08-12 67/week @ 2025-08-19 159/week @ 2025-08-26 151/week @ 2025-09-02 152/week @ 2025-09-09 97/week @ 2025-09-16 55/week @ 2025-09-23 92/week @ 2025-09-30 16/week @ 2025-10-07 151/week @ 2025-10-14 215/week @ 2025-10-21 23/week @ 2025-10-28 10/week @ 2025-11-04

401 downloads per month

MIT/Apache

110KB
1.5K SLoC

Simple LDAP client library for Ldap3

A ldap client library that wraps ldap3 to make it easy to use.

CI codecov Crates.io Documentation

Usage

Adding simple_ldap as a dependency to your project:

cargo add simple-ldap

Other useful pieces you'll likely need:

cargo add url serde --features serde/derive

Example

There are plenty more examples in the documentation!

Search records

use simple_ldap::{
    LdapClient, LdapConfig, SimpleDN,
    filter::EqFilter,
    ldap3::Scope
};
use url::Url;
use serde::Deserialize;
use serde_with::serde_as;
use serde_with::OneOrMany;

// A type for deserializing the search result into.
#[serde_as] // serde_with for multiple values
#[derive(Debug, Deserialize)]
struct User {
    pub dn: SimpleDN,
    pub uid: String,
    pub cn: String,
    pub sn: String,
    #[serde_as(as = "OneOrMany<_>")]
    pub addresses: Vec<String>,
}


#[tokio::main]
async fn main(){
    let ldap_config = LdapConfig {
        bind_dn: String::from("cn=manager"),
        bind_password: String::from("password"),
        ldap_url: Url::parse("ldaps://localhost:1389/dc=example,dc=com").unwrap(),
        dn_attribute: None,
        connection_settings: None
    };
    let mut client = LdapClient::new(ldap_config).await.unwrap();
    let name_filter = EqFilter::from("cn".to_string(), "Sam".to_string());
    let user: User = client
        .search(
        "ou=people,dc=example,dc=com",
        Scope::OneLevel,
        &name_filter,
        vec!["dn", "cn", "sn", "uid","addresses"],
    ).await.unwrap();
}

Dependencies

~12–32MB
~457K SLoC