Skip to main content

LdapConfig

Struct LdapConfig 

Source
pub struct LdapConfig {
    pub host: String,
    pub port: u16,
    pub encryption: Encryption,
    pub verify_certificate: bool,
    pub allow_plaintext_password: bool,
    pub connect_timeout: Duration,
    pub timeout: Duration,
    pub max_message_size: usize,
}
Expand description

Where the directory is and how much to insist on before talking to it.

Holds no credentials, which is why it can derive Debug: the bind DN and password live in crate::directory::Directory, which cannot.

Fields§

§host: String§port: u16§encryption: Encryption§verify_certificate: bool

Whether the server’s certificate has to chain to a trusted root and name the host. Off is for a laboratory and nowhere else.

§allow_plaintext_password: bool

Whether a simple bind may go over an unencrypted connection.

False by default, and the error when it fires says why. A simple bind puts the password on the wire verbatim; this is the most common LDAP deployment mistake there is, and it is invisible from the outside because everything works.

§connect_timeout: Duration§timeout: Duration

How long to wait for one response.

§max_message_size: usize

The largest message this client will buffer.

Enforced from the length header, before anything is read, so a directory cannot make a client allocate by announcing a size it never sends.

Implementations§

Source§

impl LdapConfig

Source

pub fn parse(url: &str) -> Result<LdapConfig>

Parse ldap://host:port or ldaps://host:port.

ldaps:// implies port 636 and TLS from the first byte. ldap:// implies port 389 and, by default, StartTLS — because a URL is not a security decision and defaulting to the encrypted form of the same port is the version that fails loudly rather than leaking quietly. A caller who genuinely wants plain text asks with LdapConfig::plaintext.

Source

pub fn plaintext(self) -> LdapConfig

Do not encrypt at all.

Separate from LdapConfig::allow_plaintext_password on purpose: this says “no TLS”, that one says “and send the password anyway”. A read-only anonymous search over plain TCP is a perfectly ordinary thing to do, and needs only the first.

Source

pub fn start_tls(self) -> LdapConfig

Source

pub fn ldaps(self) -> LdapConfig

Source

pub fn port(self, port: u16) -> LdapConfig

Source

pub fn allow_plaintext_password(self) -> LdapConfig

Send a simple bind even though the connection is not encrypted.

The named-in-full opt-in the security rule asks for. It exists because a test container on loopback is a real case; it should not appear in anything that talks to a directory over a network.

Source

pub fn dangerously_accept_any_certificate(self) -> LdapConfig

Believe whatever certificate the directory presents.

This turns TLS into protection against a passive listener and nothing else: an active attacker simply presents a certificate of their own. The name is long because the call site is where somebody will read it.

Source

pub fn timeout(self, timeout: Duration) -> LdapConfig

Source

pub fn connect_timeout(self, timeout: Duration) -> LdapConfig

Source

pub fn max_message_size(self, bytes: usize) -> LdapConfig

Source

pub fn address(&self) -> String

Trait Implementations§

Source§

impl Clone for LdapConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LdapConfig

Source§

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

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.