class LDAP::Client

Defined in:

ldap/client.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(socket, tls_context : OpenSSL::SSL::Context::Client | Nil = nil, max_message_size : Int32 = (16 * 1024) * 1024, timeout : Time::Span | Nil = nil) #

max_message_size caps how many bytes the BER decoder will allocate or read for a single received message and its nested values, guarding against a hostile server forcing a huge allocation. Defaults to 16 MiB; 0 or a negative value disables the bound.

timeout bounds how long each operation waits for its response before raising TimeoutError. nil (the default) waits indefinitely. A timed-out operation drops its pending state and leaves the connection usable: any late data the server still streams for it is ignored. (The connection is not abandoned server-side — LDAP Abandon is a separate, future operation.)


[View source]

Instance Method Detail

def add(dn : String, attributes : Hash(String, Array(String))) : self #

https://tools.ietf.org/html/rfc4511#section-4.7


[View source]
def authenticate(username : String = "", password : String = "") #

[View source]
def close #

[View source]
def closed? #

[View source]
def compare(dn : String, attribute : String, value : String) : Bool #

https://tools.ietf.org/html/rfc4511#section-4.10 Returns whether the entry's attribute holds the asserted value.


[View source]
def delete(dn : String) : self #

https://tools.ietf.org/html/rfc4511#section-4.8


[View source]
def modify(dn : String, changes : Enumerable(Modification)) : self #

https://tools.ietf.org/html/rfc4511#section-4.6


[View source]
def modify_dn(dn : String, new_rdn : String, delete_old_rdn : Bool = true, new_superior : String | Nil = nil) : self #

https://tools.ietf.org/html/rfc4511#section-4.9


[View source]
def search(base : String, filter : Request::Filter | String = Request::Filter.equal("objectClass", "*"), scope : SearchScope = SearchScope::WholeSubtree, attributes : Enumerable(String) | Enumerable(Symbol) = [] of String, attributes_only : Bool = false, dereference : DereferenceAliases = DereferenceAliases::Always, size : Int = 0, time : Int = 0, sort : String | Request::SortControl | BER | Nil = nil) : Array(Entry) #

Runs a search and returns the matching entries. Raises ReferralError (with any entries found + the referral URLs) when the result set is incomplete because it lives elsewhere; SearchLimitError (with the partial entries) on a server-side size/time/admin limit; OperationError on any other failure code.


[View source]
def search(base : String, filter : Request::Filter | String = Request::Filter.equal("objectClass", "*"), scope : SearchScope = SearchScope::WholeSubtree, attributes : Enumerable(String) | Enumerable(Symbol) = [] of String, attributes_only : Bool = false, dereference : DereferenceAliases = DereferenceAliases::Always, size : Int = 0, time : Int = 0, sort : String | Request::SortControl | BER | Nil = nil, page_size : Int = 1000, & : Entry -> _) : Nil #

Streaming, auto-paginated search (RFC 2696). Issues successive pages of at most page_size entries, yielding each Entry as it arrives; memory is bounded to one page. Raises ReferralError (with the referral URLs) when a page is a referral; SearchLimitError (with empty entries — matched entries were already yielded) on a server-side size/time/admin limit; OperationError on any other failure. Because entries stream as they arrive, a page's entries are yielded before its result code is inspected — so an OperationError on a later page may follow entries the caller has already received. Composes with sort.


[View source]
def unbind : Nil #

https://tools.ietf.org/html/rfc4511#section-4.3 Sends an UnbindRequest (which has no response) and closes the connection.


[View source]