[−][src]Struct ldap3::Ldap
Asynchronous handle for LDAP operations. *
All LDAP operations allow attaching a series of request controls, which augment or modify
the operation. Controls are attached by calling with_controls()
on the handle, and using the result to call another modifier or the operation itself.
A timeout can be imposed on an operation by calling with_timeout()
on the handle before invoking the operation.
The Search operation has many parameters, most of which are infrequently used. Those
parameters can be specified by constructing a SearchOptions
structure and passing it to with_search_options()
called on the handle. This method can be combined with with_controls()
and with_timeout()
,
described above.
There are two ways to invoke a search. The first, using search()
,
returns all result entries in a single vector, which works best if it's known that the
result set will be limited. The other way uses streaming_search()
,
which accepts the same parameters, but returns a handle which must be used to obtain
result entries one by one.
As a rule, operations return LdapResult
,
a structure of result components. The most important element of LdapResult
is the result code, a numeric value indicating the outcome of the operation.
This structure also contains the possibly empty vector of response controls,
which are not directly usable, but must be additionally parsed by the driver- or
user-supplied code.
The handle can be freely cloned. Each clone will multiplex the invoked LDAP operations on the same underlying connection. Dropping the last handle will automatically close the connection.
Fields
timeout: Option<Duration>
controls: Option<Vec<RawControl>>
search_opts: Option<SearchOptions>
Implementations
impl Ldap
[src]
pub fn with_search_options(&mut self, opts: SearchOptions) -> &mut Self
[src]
Use the provided SearchOptions
with the next Search operation, which can
be invoked directly on the result of this method. If this method is used in
combination with a non-Search operation, the provided options will be silently
discarded when the operation is invoked.
The Search operation can be invoked on the result of this method.
pub fn with_controls<V: IntoRawControlVec>(&mut self, ctrls: V) -> &mut Self
[src]
Pass the provided request control(s) to the next LDAP operation.
Controls can be constructed by instantiating structs in the
controls
module, and converted to the form needed
by this method by calling into()
on the instances. Alternatively, a control
struct may offer a constructor which will produce a RawControl
instance
itself. See the module-level documentation for the list of directly supported
controls and procedures for defining custom controls.
This method accepts either a single RawControl
or a Vec
of them, in
order to make the call site less noisy, since it's expected that passing
a single control will comprise the majority of uses.
The desired operation can be invoked on the result of this method.
pub fn with_timeout(&mut self, duration: Duration) -> &mut Self
[src]
Perform the next operation with the timeout specified in duration
.
The LDAP Search operation consists of an indeterminate number of Entry/Referral
replies; the timer is reset for each reply.
If the timeout occurs, the operation will return an error. The connection remains usable for subsequent operations.
The desired operation can be invoked on the result of this method.
pub async fn simple_bind(
&mut self,
bind_dn: &str,
bind_pw: &str
) -> Result<LdapResult>
[src]
&mut self,
bind_dn: &str,
bind_pw: &str
) -> Result<LdapResult>
Do a simple Bind with the provided DN (bind_dn
) and password (bind_pw
).
pub async fn sasl_external_bind(&mut self) -> Result<LdapResult>
[src]
Do a SASL EXTERNAL bind on the connection. The identity of the client must have already been established by connection-specific methods, as is the case for Unix domain sockets or TLS client certificates. The bind is made with the hardcoded empty authzId value.
pub async fn search<'a, S: AsRef<str> + Send + Sync + 'a>(
&mut self,
base: &str,
scope: Scope,
filter: &str,
attrs: Vec<S>
) -> Result<SearchResult>
[src]
&mut self,
base: &str,
scope: Scope,
filter: &str,
attrs: Vec<S>
) -> Result<SearchResult>
Perform a Search with the given base DN (base
), scope, filter, and
the list of attributes to be returned (attrs
). If attrs
is empty,
or if it contains a special name *
(asterisk), return all (user) attributes.
Requesting a special name +
(plus sign) will return all operational
attributes. Include both *
and +
in order to return all attributes
of an entry.
The returned structure wraps the vector of result entries and the overall
result of the operation. Entries are not directly usable, and must be parsed by
SearchEntry::construct()
. All
referrals in the result stream will be collected in the refs
vector of the
operation result. Any intermediate messages will be discarded.
This method should be used if it's known that the result set won't be
large. For other situations, one can use streaming_search()
.
pub async fn streaming_search<'a, S: AsRef<str> + Send + Sync + 'a>(
&mut self,
base: &str,
scope: Scope,
filter: &str,
attrs: Vec<S>
) -> Result<SearchStream<'a, S>>
[src]
&mut self,
base: &str,
scope: Scope,
filter: &str,
attrs: Vec<S>
) -> Result<SearchStream<'a, S>>
Perform a Search, but unlike search()
(q.v., also for
the parameters), which returns all results at once, return a handle which
will be used for retrieving entries one by one. See SearchStream
for the explanation of the protocol which must be adhered to in this case.
pub async fn streaming_search_with<'a, V: IntoAdapterVec<'a, S>, S: AsRef<str> + Send + Sync + 'a>(
&mut self,
adapters: V,
base: &str,
scope: Scope,
filter: &str,
attrs: Vec<S>
) -> Result<SearchStream<'a, S>>
[src]
&mut self,
adapters: V,
base: &str,
scope: Scope,
filter: &str,
attrs: Vec<S>
) -> Result<SearchStream<'a, S>>
Perform a streaming Search internally modified by a chain of adapters.
The first argument can either be a struct implementing Adapter
, if a single adapter is needed,
or a vector of boxed Adapter
trait objects.
pub async fn add<S: AsRef<[u8]> + Eq + Hash>(
&mut self,
dn: &str,
attrs: Vec<(S, HashSet<S>)>
) -> Result<LdapResult>
[src]
&mut self,
dn: &str,
attrs: Vec<(S, HashSet<S>)>
) -> Result<LdapResult>
Add an entry named by dn
, with the list of attributes and their values
given in attrs
. None of the HashSet
s of values for an attribute may
be empty.
pub async fn compare<B: AsRef<[u8]>>(
&mut self,
dn: &str,
attr: &str,
val: B
) -> Result<CompareResult>
[src]
&mut self,
dn: &str,
attr: &str,
val: B
) -> Result<CompareResult>
Compare the value(s) of the attribute attr
within an entry named by dn
with the
value val
. If any of the values is identical to the provided one, return result code 5
(compareTrue
), otherwise return result code 6 (compareFalse
). If access control
rules on the server disallow comparison, another result code will be used to indicate
an error.
pub async fn delete(&mut self, dn: &str) -> Result<LdapResult>
[src]
Delete an entry named by dn
.
pub async fn modify<S: AsRef<[u8]> + Eq + Hash>(
&mut self,
dn: &str,
mods: Vec<Mod<S>>
) -> Result<LdapResult>
[src]
&mut self,
dn: &str,
mods: Vec<Mod<S>>
) -> Result<LdapResult>
Modify an entry named by dn
by sequentially applying the modifications given by mods
.
See the Mod
documentation for the description of possible values.
pub async fn modifydn(
&mut self,
dn: &str,
rdn: &str,
delete_old: bool,
new_sup: Option<&str>
) -> Result<LdapResult>
[src]
&mut self,
dn: &str,
rdn: &str,
delete_old: bool,
new_sup: Option<&str>
) -> Result<LdapResult>
Rename and/or move an entry named by dn
. The new name is given by rdn
. If
delete_old
is true
, delete the previous value of the naming attribute from
the entry. If the entry is to be moved elsewhere in the DIT, new_sup
gives
the new superior entry where the moved entry will be anchored.
pub async fn extended<E>(&mut self, exop: E) -> Result<ExopResult> where
E: Into<Exop>,
[src]
E: Into<Exop>,
Perform an Extended operation given by exop
. Extended operations are defined in the
exop
module. See the module-level documentation for the list of extended
operations supported by this library and procedures for defining custom exops.
pub async fn unbind(&mut self) -> Result<()>
[src]
Terminate the connection to the server.
pub fn last_id(&mut self) -> RequestId
[src]
Return the message ID of the last active operation. When the handle is initialized, this value is set to zero. The intended use is to obtain the ID of a timed out operation for passing it to an Abandon or Cancel operation.
Using this method in the start()
adapter chain of a streaming Search will return zero,
since the Message ID is obtained in the inner start()
method.
pub async fn abandon(&mut self, msgid: RequestId) -> Result<()>
[src]
Ask the server to abandon an operation identified by msgid
.
Trait Implementations
impl Clone for Ldap
[src]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Ldap
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Ldap
[src]
impl Send for Ldap
[src]
impl Sync for Ldap
[src]
impl Unpin for Ldap
[src]
impl !UnwindSafe for Ldap
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,