38 releases

0.11.3 Jun 8, 2023
0.11.1 Jan 4, 2023
0.11.0-beta.1 Dec 20, 2022
0.10.5 May 12, 2022
0.5.0 Jul 20, 2017

#15 in Authentication

Download history 4164/week @ 2023-11-01 4396/week @ 2023-11-08 4168/week @ 2023-11-15 3714/week @ 2023-11-22 3933/week @ 2023-11-29 5037/week @ 2023-12-06 4445/week @ 2023-12-13 3403/week @ 2023-12-20 2802/week @ 2023-12-27 3749/week @ 2024-01-03 3809/week @ 2024-01-10 4123/week @ 2024-01-17 4630/week @ 2024-01-24 4158/week @ 2024-01-31 3841/week @ 2024-02-07 3560/week @ 2024-02-14

17,007 downloads per month
Used in 27 crates (26 directly)


5.5K SLoC

LDAP client library

A pure-Rust LDAP client library using the Tokio stack.

Version notices

The 0.11 branch has had a belated but important dependency upgrade: the nom parser combinator crate, both in the lber support library and ldap3 proper. This should be an implementation detail invisible to the user, and the parsers have a battery of tests, but the version was nevertheless bumped up out of abundance of caution. There are no functional differences between 0.10.6 and 0.11.3.

Starting with 0.10.3, there is cross-platform Kerberos/GSSAPI support if compiled with the gssapi feature. This feature enables the use of integrated Windows authentication in Active Directory domains. See the description of the feature in this README for the details of compile-time requirements.

The 0.11 branch is actively developed. Bug fixes will be ported to 0.10.x. The 0.9 branch is hence retired.


API reference:

There is an LDAP introduction for those still getting their bearings in the LDAP world.

Miscellaneous notes

The library is client-only. One cannot make an LDAP server or a proxy with it. It supports only version 3 of the protocol over connection-oriented transports.

There is no built-in support for connection pooling, automatic fallback or reconnections.


Add this to your Cargo.toml:

version = "0.11.3"

The library can be used either synchronously or asynchronously. The aim is to offer essentially the same call interface for both flavors, with the necessary differences in interaction and return values according to the nature of I/O.


The following two examples perform exactly the same operation and should produce identical results. They should be run against the example server in the data subdirectory of the crate source. Other sample programs expecting the same server setup can be found in the examples subdirectory.

use ldap3::{LdapConn, Scope, SearchEntry};
use ldap3::result::Result;

fn main() -> Result<()> {
    let mut ldap = LdapConn::new("ldap://localhost:2389")?;
    let (rs, _res) = ldap.search(
    for entry in rs {
        println!("{:?}", SearchEntry::construct(entry));
use ldap3::{LdapConnAsync, Scope, SearchEntry};
use ldap3::result::Result;

async fn main() -> Result<()> {
    let (conn, mut ldap) = LdapConnAsync::new("ldap://localhost:2389").await?;
    let (rs, _res) = ldap.search(
    for entry in rs {
        println!("{:?}", SearchEntry::construct(entry));

Compile-time features

The following features are available at compile time:

  • sync (enabled by default): Synchronous API support.

  • gssapi (disabled by default): Kerberos/GSSAPI support. On Windows, system support crates and SDK libraries are used. Elsewhere, the feature needs Clang and its development libraries (for bindgen), as well as the Kerberos development libraries. On Debian/Ubuntu, that means clang-N, libclang-N-dev and libkrb5-dev. It should be clear from these requirements that GSSAPI support uses FFI to C libraries; you should consider the security implications of this fact.

    For usage notes and caveats, see the documentation for Ldap::sasl_gssapi_bind() in the API reference.

  • tls (enabled by default): TLS support, backed by the native-tls crate, which uses a platform-specific TLS backend. This is an alias for tls-native.

  • tls-rustls (disabled by default): TLS support, backed by the Rustls library.

Without any features, only plain TCP connections (and Unix domain sockets on Unix-like platforms) are available. For TLS support, tls and tls-rustls are mutually exclusive: choosing both will produce a compile-time error.


Licensed under either of:

at your option.


~756K SLoC