[][src]Crate ldap3

A pure-Rust LDAP library using the Tokio stack.

Usage

In Cargo.toml:

[dependencies.ldap3]
version = "0.7.0-alpha"

Summary

The library provides both synchronous and asynchronous interfaces. The LdapConn structure is the starting point for all synchronous operations. LdapConnAsync is its asynchronous analogue, and Ldap is the low-level asynchronous handle useds internally by LdapConn, and explicitly by the users of the asynchronous interface.

In the struct list, async-related structs have an asterisk (*) after the short description.

The documentation is written for readers familiar with LDAP concepts and terminology, which it won't attempt to explain.

Examples

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(
        "ou=Places,dc=example,dc=org",
        Scope::Subtree,
        "(&(objectClass=locality)(l=ma*))",
        vec!["l"]
    )?.success()?;
    for entry in rs {
        println!("{:?}", SearchEntry::construct(entry));
    }
    Ok(ldap.unbind()?)
}
use ldap3::{LdapConnAsync, Scope, SearchEntry};
use ldap3::result::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let (conn, mut ldap) = LdapConnAsync::new("ldap://localhost:2389").await?;
    ldap3::drive!(conn);
    let (rs, _res) = ldap.search(
        "ou=Places,dc=example,dc=org",
        Scope::Subtree,
        "(&(objectClass=locality)(l=ma*))",
        vec!["l"]
    ).await?.success()?;
    for entry in rs {
        println!("{:?}", SearchEntry::construct(entry));
    }
    Ok(ldap.unbind().await?)
}

Re-exports

pub extern crate log;
pub use result::LdapError;
pub use result::LdapResult;
pub use result::SearchResult;

Modules

asn1

ASN.1 structure construction and parsing.

controls

Control construction and parsing.

exop

Extended operation construction and parsing.

result

Operation result structures and helpers.

Macros

drive

Drive the connection until its completion.

Structs

EntryStream

Handle for obtaining a stream of search results.

Ldap

Asynchronous handle for LDAP operations. *

LdapConn

Synchronous connection to an LDAP server.

LdapConnAsync

Asynchronous connection to an LDAP server. *

LdapConnSettings

Additional settings for an LDAP connection.

ResultEntry

Wrapper for the internal structure of a result entry.

SearchEntry

Parsed search result entry.

SearchOptions

Additional parameters for the Search operation.

SearchStream

Asynchronous handle for obtaining a stream of search results. *

Enums

DerefAliases

Possible values for alias dereferencing during search.

Mod

Possible sub-operations for the Modify operation.

Scope

Possible values for search scope.

SyncInfo

Possible values of the Sync Info intermediate message. See the Content Synchronization specification (RFC 4532).

Functions

dn_escape

Escape an attribute value in a relative distinguished name (RDN).

ldap_escape

Escape a filter literal.

parse_syncinfo

Parse the Sync Info value from the raw BER-encoded octet string.

Type Definitions

RequestId

Type alias for the LDAP message ID.