forked from dequbed/rust-ldap
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for creating LDAP clients from existing
TcpStream
and `…
…UnixStream`. That allows to create LDAP client from file descriptor and handle connection (with ssl) in sandboxed environemtn.
- Loading branch information
Showing
4 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Demonstrates synchronously connecting, binding to, | ||
// and disconnection from the exiting tcp stream. | ||
|
||
use ldap3::result::Result; | ||
use ldap3::{LdapConn, LdapConnSettings}; | ||
use std::net::TcpStream; | ||
use url::Url; | ||
|
||
fn main() -> Result<()> { | ||
let stream = TcpStream::connect("localhost:2389")?; | ||
|
||
let url = Url::parse("ldap://localhost:2389").unwrap(); | ||
let mut ldap = LdapConn::from_tcp_stream(stream, LdapConnSettings::new(), &url)?; | ||
let _res = ldap | ||
.simple_bind("cn=Manager,dc=example,dc=org", "secret")? | ||
.success()?; | ||
Ok(ldap.unbind()?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters