Struct ldap3::LdapConnAsync
source · pub struct LdapConnAsync { /* private fields */ }
Expand description
Asynchronous connection to an LDAP server. *
In this version of the interface, opening a connection with new()
will return a tuple consisting of the connection itself and an Ldap
handle for performing the LDAP operations. The connection must be spawned on the active
Tokio executor before using the handle. A convenience macro, drive!
, is
provided by the library. For the connection conn
, it does the equivalent of:
tokio::spawn(async move {
if let Err(e) = conn.drive().await {
warn!("LDAP connection error: {}", e);
}
});
If you need custom connection lifecycle handling, use the drive()
method
on the connection inside your own async
block.
The Ldap
handle can be freely cloned, with each clone capable of launching a separate
LDAP operation multiplexed on the original connection. Dropping the last handle will automatically
close the connection.
Some connections need additional parameters, but providing many separate functions to initialize
them, singly or in combination, would result in a cumbersome interface. Instead, connection
initialization is optimized for the expected most frequent usage, and additional customization
is possible through the LdapConnSettings
struct, which can be
passed to with_settings()
.
Implementations§
source§impl LdapConnAsync
impl LdapConnAsync
sourcepub async fn with_settings(
settings: LdapConnSettings,
url: &str
) -> Result<(Self, Ldap)>
pub async fn with_settings( settings: LdapConnSettings, url: &str ) -> Result<(Self, Ldap)>
Open a connection to an LDAP server specified by url
, using
settings
to specify additional parameters.
sourcepub async fn new(url: &str) -> Result<(Self, Ldap)>
pub async fn new(url: &str) -> Result<(Self, Ldap)>
Open a connection to an LDAP server specified by url
.
The url
is an LDAP URL. Depending on the platform and compile-time features, the
library will recognize one or more URL schemes.
The ldap scheme, which uses a plain TCP connection, is always available. Unix-like platforms also support ldapi, using Unix domain sockets. With the tls or tls-rustls feature, the ldaps scheme and StartTLS over ldap are additionally supported.
The connection element in the returned tuple must be spawned on the current Tokio
executor before using the Ldap
element. See the introduction to this struct’s
documentation.
sourcepub async fn from_url_with_settings(
settings: LdapConnSettings,
url: &Url
) -> Result<(Self, Ldap)>
pub async fn from_url_with_settings( settings: LdapConnSettings, url: &Url ) -> Result<(Self, Ldap)>
Open a connection to an LDAP server specified by an already parsed Url
, using
settings
to specify additional parameters.