Module controls

Source
Expand description

Control construction and parsing.

A control can be associated with a request or a response. Several common controls, such as PagedResults, are implemented directly by this library. If an implemented control has the same form for the request and the response, there will be a single structure for both. (This is the case for PagedResults.) If the response control is different, its name will consist of the request control name with the Resp suffix.

A request control can be created by instantiating its structure and converting it to ASN.1 with into() when passing the instance or constructing the request control vector in the call to with_controls(). A third-party control must implement the conversion from an instance of itself to RawControl, a general form of control.

RawControl, together with an optional instance of ControlType, forms the type Control; a vector of Controls is part of the result of all LDAP operation which return one.

The first element of Control will have a value if the parser recognizes the control’s OID as one that is implemented by the library itself. Since the list of implemented controls is expected to grow, the ControlType enum cannot be exhaustively matched.

A recognized response control can be parsed by calling parse() on the instance of RawControl representing it. A third-party control must implement the ControlParser trait to support this interface.

§Example

With an LdapResult in res, iterating through controls and matching the desired ones could be done like this:

for ctrl in res.ctrls {
    match ctrl {
        // matching a control implemented by the library
        Control(Some(ControlType::PagedResults), ref raw) => {
            dbg!(raw.parse::<PagedResults>());
        },
        // matching a control unknown to the library
        // the OID is actually that of PagedResults
        Control(None, ref raw) if raw.ctype == "1.2.840.113556.1.4.319" => {
            dbg!(raw.parse::<PagedResults>());
        },
        _ => (),
    }
}

Structs§

Assertion
Assertion control (RFC 4528).
Control
Response control.
CriticalControl
Wrapper for a control marked as critical.
ManageDsaIt
ManageDsaITcontrol (RFC 3296).
MatchedValues
Matched Values control (RFC 3876)
PagedResults
Paged Results control (RFC 2696).
PostRead
Post-Read request control (RFC 4527).
PreRead
Pre-Read request control (RFC 4527).
ProxyAuth
Proxy Authorization control (RFC 4370).
RawControl
Generic control.
ReadEntryResp
Response for Pre-Read and Post-Read controls.
RelaxRules
Relax Rules control (draft specification).
SyncDone
Sync Done response control (RFC 4533).
SyncRequest
Sync Request control (RFC 4533).
SyncState
Sync State response control (RFC 4533).

Enums§

ControlType
Recognized control types.
EntryState
Possible states for the Sync State control.
RefreshMode
Content refresh mode.
SyncInfo
Values of the Sync Info intermediate message (RFC 4533).

Traits§

ControlParser
Conversion trait for response controls.
IntoRawControlVec
MakeCritical
Mark a control as critical.

Functions§

parse_syncinfo
Parse the Sync Info value from the Search result entry.

Type Aliases§

PostReadResp
Type alias for Post-Read response.
PreReadResp
Type alias for Pre-Read response.