ldap3 0.12.1

Pure-Rust LDAP Client
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Demonstrates synchronously connecting, binding to,
// and disconnecting from the exiting tcp stream.

use std::net::TcpStream;

use ldap3::result::Result;
use ldap3::{LdapConn, LdapConnSettings, StdStream};

fn main() -> Result<()> {
    let stream = TcpStream::connect("localhost:2389")?;
    let settings = LdapConnSettings::new().set_std_stream(StdStream::Tcp(stream));
    let mut ldap = LdapConn::with_settings(settings, "ldap://localhost:2389")?;
    let _res = ldap
        .simple_bind("cn=Manager,dc=example,dc=org", "secret")?
        .success()?;
    Ok(ldap.unbind()?)
}