Struct RustLDAP

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

A high level abstraction over the raw OpenLDAP functions.

A RustLDAP object hides raw OpenLDAP complexities and exposes a simple object that is created, configured, and queried. Methods that call underlying OpenLDAP calls that can fail will raise an errors::LDAPError with additional details.

Using a RustLDAP object is easy!

Implementations§

Source§

impl RustLDAP

Source

pub fn new(uri: &str) -> Result<RustLDAP, LDAPError>

Create a new RustLDAP.

Creates a new RustLDAP and initializes underlying OpenLDAP library. Upon creation, a subsequent calls to set_option and simple_bind are possible. Before calling a search related function, one must bind to the server by calling simple_bind. See module usage information for more details on using a RustLDAP object.

§Parameters
  • uri - URI of the LDAP server to connect to. E.g., ldaps://localhost:636.
Source

pub fn set_option<T: LDAPOptionValue + ?Sized>( &self, option: i32, value: &T, ) -> bool

Sets an option on the LDAP connection.

When setting an option to ON or OFF one may use the boolean values true or false, respectively.

§Parameters
  • option - An option identifier from cldap::codes.
  • value - The value to set for the option.
Source

pub fn simple_bind(&self, who: &str, pass: &str) -> Result<i32, LDAPError>

Bind to the LDAP server.

If you wish to configure options on the LDAP server, be sure to set required options using set_option before binding to the LDAP server. In some advanced cases, it may be required to set multiple options for an option to be made available. Refer to the OpenLDAP documentation for information on available options and how to use them.

§Parameters
  • who - The user’s name to bind with.
  • pass - The user’s password to bind with.

Simple synchronous search.

Performs a simple search with only the base, returning all attributes found.

§Parameters
  • base - The LDAP base.
  • scope - The search scope. See cldap::codes::scopes.
Source

pub fn start_tls( &self, serverctrls: Option<*mut *mut LDAPControl>, clientctrls: Option<*mut *mut LDAPControl>, ) -> Result<i32, LDAPError>

Installs TLS handlers on the session

§Examples
use openldap::RustLDAP;
let ldap = RustLDAP::new(&"ldaps://myserver:636").unwrap();

ldap.set_option(
    openldap::codes::options::LDAP_OPT_PROTOCOL_VERSION,
    &openldap::codes::versions::LDAP_VERSION3,
);

ldap.set_option(
    openldap::codes::options::LDAP_OPT_X_TLS_REQUIRE_CERT,
    &openldap::codes::options::LDAP_OPT_X_TLS_ALLOW,
);

ldap.set_option(openldap::codes::options::LDAP_OPT_X_TLS_NEWCTX, &0);

ldap.start_tls(None, None);
ldap.simple_bind("some-dn", "some-password").unwrap();

Advanced synchronous search.

Exposes a raw API around the underlying ldap_search_ext_s function from OpenLDAP. Wherever possible, use provided wrappers.

§Parameters
  • base - The base domain.
  • scope - The search scope. See cldap::codes::scopes.
  • filter - An optional filter.
  • attrs - An optional set of attrs.
  • attrsonly - True if should return only the attrs specified in attrs.
  • serverctrls - Optional sever controls.
  • clientctrls - Optional client controls.
  • timeout - A timeout.
  • sizelimit - The maximum number of entities to return, or -1 for no limit.

Trait Implementations§

Source§

impl Drop for RustLDAP

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for RustLDAP

Source§

impl Sync for RustLDAP

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> 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, 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.