class ROM::LDAP::SearchRequest
The Search request is defined as follows:
SearchRequest ::= [APPLICATION 3] SEQUENCE { baseObject LDAPDN, scope ENUMERATED { baseObject (0), singleLevel (1), wholeSubtree (2), ... }, derefAliases ENUMERATED { neverDerefAliases (0), derefInSearching (1), derefFindingBaseObj (2), derefAlways (3) }, sizeLimit INTEGER (0 .. maxInt), timeLimit INTEGER (0 .. maxInt), typesOnly BOOLEAN, filter Filter, attributes AttributeSelection } AttributeSelection ::= SEQUENCE OF selector LDAPString -- The LDAPString is constrained to -- <attributeSelector> in Section 4.5.1.8 Filter ::= CHOICE { and [0] SET SIZE (1..MAX) OF filter Filter, or [1] SET SIZE (1..MAX) OF filter Filter, not [2] Filter, equalityMatch [3] AttributeValueAssertion, substrings [4] SubstringFilter, greaterOrEqual [5] AttributeValueAssertion, lessOrEqual [6] AttributeValueAssertion, present [7] AttributeDescription, approxMatch [8] AttributeValueAssertion, extensibleMatch [9] MatchingRuleAssertion, ... } SubstringFilter ::= SEQUENCE { type AttributeDescription, substrings SEQUENCE SIZE (1..MAX) OF substring CHOICE { initial [0] AssertionValue, -- can occur at most once any [1] AssertionValue, final [2] AssertionValue } -- can occur at most once } MatchingRuleAssertion ::= SEQUENCE { matchingRule [1] MatchingRuleId OPTIONAL, type [2] AttributeDescription OPTIONAL, matchValue [3] AssertionValue, dnAttributes [4] BOOLEAN DEFAULT FALSE }
@see tools.ietf.org/html/rfc4511#section-4.5.1
@api private
Public Instance Methods
controls()
click to toggle source
Controls sent by clients are termed 'request controls', and those
sent by servers are termed 'response controls'. Controls ::= SEQUENCE OF control Control Control ::= SEQUENCE { controlType LDAPOID, criticality BOOLEAN DEFAULT FALSE, controlValue OCTET STRING OPTIONAL }
@see tools.ietf.org/html/rfc4511#section-4.1.11
@return [Array]
# File lib/rom/ldap/search_request.rb, line 177 def controls ctrls = [] ctrls << build_controls(:paged_results, cookie) if paged ctrls << build_controls(:sort_request, sort_rules) if sorted ctrls.empty? ? nil : ctrls.to_ber_contextspecific(0) end
parts()
click to toggle source
Search request components.
@return [Array]
# File lib/rom/ldap/search_request.rb, line 149 def parts [ base.to_ber, # 4.5.1.1. SearchRequest.baseObject scope.to_ber_enumerated, # 4.5.1.2. SearchRequest.scope deref.to_ber_enumerated, # 4.5.1.3. SearchRequest.derefAliases limit.to_ber, # 4.5.1.4. SearchRequest.sizeLimit timeout.to_ber, # 4.5.1.5. SearchRequest.timeLimit attributes_only.to_ber, # 4.5.1.6. SearchRequest.typesOnly expression.to_ber, # 4.5.1.7. SearchRequest.filter ber_attrs.to_ber_sequence # 4.5.1.8. SearchRequest.attributes ] end
Private Instance Methods
ber_attrs()
click to toggle source
@return [Array]
@api private
# File lib/rom/ldap/search_request.rb, line 200 def ber_attrs Array(attributes).map { |attr| attr.to_s.to_ber } end
build_controls(type, payload)
click to toggle source
Control ::= SEQUENCE { controlType LDAPOID, criticality BOOLEAN DEFAULT FALSE, controlValue OCTET STRING OPTIONAL }
@return [String] LDAP
'control'
@see PDU#result_controls
# File lib/rom/ldap/search_request.rb, line 223 def build_controls(type, payload) [ OID[type].to_ber, false.to_ber, payload.to_ber_sequence.to_s.to_ber ].to_ber_sequence end
limit()
click to toggle source
Set test server to only serve 200 at a time to check paging
Limit to no more than 126 entries.
@return [Integer]
@api private
# File lib/rom/ldap/search_request.rb, line 193 def limit (0..126).cover?(max) ? max : 0 end
sort_rules()
click to toggle source
Only uses attribute names because not all vendors have fully implemented SSS.
SortKeyList ::= SEQUENCE OF SEQUENCE { attributeType AttributeDescription, orderingRule [0] MatchingRuleId OPTIONAL, reverseOrder [1] BOOLEAN DEFAULT FALSE }
@see tools.ietf.org/html/rfc2891 @see docs.ldap.com/ldap-sdk/docs/javadoc/com/unboundid/ldap/sdk/controls/ServerSideSortRequestControl.html
@api private
# File lib/rom/ldap/search_request.rb, line 243 def sort_rules sorted.map { |attr| [attr.to_ber].to_ber_sequence } end