Skip to main content

LdapConnectionManager

Struct LdapConnectionManager 

Source
pub struct LdapConnectionManager { /* private fields */ }
Expand description

A bb8::ManageConnection implementation for ldap3 async connections.

Implementations§

Source§

impl LdapConnectionManager

Source

pub fn new<S: Into<String>>(ldap_url: S) -> Result<Self, LdapError>

Creates a new LdapConnectionManager with the given LDAP URL.

The URL is parsed and validated. Valid schemes are ldap and ldapi.

Note: ldaps:// is not accepted. To use TLS, pass an ldap:// URL and configure StartTLS via LdapConnSettings::set_starttls(true).

§Errors

Returns LdapError::UrlParsing if the URL is malformed. Returns LdapError::UnknownScheme if the scheme is not ldap or ldapi.

Source

pub fn with_connection_settings(self, settings: LdapConnSettings) -> Self

Update the LDAP connection settings for this manager.

Source

pub fn with_bind_credentials<S: Into<String>>( self, bind_dn: S, bind_password: S, ) -> Self

Configures a simple bind to be performed when new connections are created.

The bind_dn is the distinguished name to bind as (e.g., "cn=admin,dc=example,dc=org"). The bind_password is the password for the bind DN.

The bind is performed immediately after each connection is established, before the connection is returned from the pool.

Source

pub fn with_validation_timeout(self, timeout: Duration) -> Self

Overrides the timeout used by is_valid health checks.

The timeout specifies the maximum duration to wait for the validation search. The default is 1 second.

Overrides the validation search performed by is_valid.

  • base_dn: The base DN for the search. Default: "" (root DSE).
  • scope: The search scope. Default: Scope::Base.
  • filter: The search filter. Default: "(objectClass=*)".
  • attributes: The attributes to return. Default: ["1.1"] (no attributes).
Source

pub fn with_connect_timeout(self, timeout: Duration) -> Self

Sets a timeout applied when establishing new connections.

This timeout is applied during connect() on a clone of the configured LdapConnSettings, and overrides any timeout previously set on those settings.

Trait Implementations§

Source§

impl Clone for LdapConnectionManager

Source§

fn clone(&self) -> LdapConnectionManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LdapConnectionManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ManageConnection for LdapConnectionManager

Implements bb8::ManageConnection to provide connection pooling for ldap3::Ldap connections.

  • connect() establishes a new LDAP connection and optionally performs a simple bind if credentials are configured.
  • is_valid() validates a connection by performing a lightweight LDAP search with the configured timeout.
  • has_broken() returns true if the underlying channel is closed (though this doesn’t guarantee full bidirectional health).
Source§

type Connection = Ldap

The connection type this manager deals with.
Source§

type Error = LdapError

The error type returned by Connections.
Source§

async fn connect(&self) -> Result<Self::Connection, Self::Error>

Attempts to create a new connection.
Source§

async fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error>

Determines if the connection is still connected to the database.
Source§

fn has_broken(&self, conn: &mut Self::Connection) -> bool

Synchronously determine if the connection is no longer usable, if possible.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.