class ROM::LDAP::PDU
LDAP
Message Protocol Data Unit (PDU
)
@api private
Public Instance Methods
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 193 def add_response? pdu_type == :add_response end
@example
"Matchingrule is required for sorting by the attribute cn"
@return [String]
# File lib/rom/ldap/pdu.rb, line 62 def advice tag[2] end
@return [Integer]
# File lib/rom/ldap/pdu.rb, line 40 def app_tag tag.ber_identifier & 0x1f end
@return [OpenStruct] => :version, :name, :authentication
# File lib/rom/ldap/pdu.rb, line 91 def bind_parameters return unless bind_request? s = ::OpenStruct.new s.version, s.name, s.authentication = tag s end
@see tools.ietf.org/html/rfc4511#section-4.2.1
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 201 def bind_request? pdu_type == :bind_request end
@return [Array] => [version, username, password]
# File lib/rom/ldap/pdu.rb, line 81 def bind_result return unless bind_result? raise ResponseTypeInvalidError, 'Invalid bind_result' unless gteq_3? tag end
A successful operation is indicated by a BindResponse with a resultCode set to success.
@see tools.ietf.org/html/rfc4511#section-4.2.2
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 211 def bind_result? pdu_type.eql?(:bind_result) end
Grep for error message
@return [String, FalseClass]
# File lib/rom/ldap/pdu.rb, line 173 def error_message tag[3][/comment: (.*), data/, 1] if tag[3] end
Message
@example => “No attribute with the name false exists in the server's schema”
@return [String, NilClass]
# File lib/rom/ldap/pdu.rb, line 123 def extended_response raise ResponseTypeInvalidError, 'Invalid extended_response' unless gteq_3? tag[3] if extended_response? end
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 235 def extended_response? pdu_type == :extended_response end
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 247 def failure? !success? end
@return [String]
# File lib/rom/ldap/pdu.rb, line 185 def flag detailed_response[2] end
@return [String]
# File lib/rom/ldap/pdu.rb, line 179 def info detailed_response[1] end
@return [String]
# File lib/rom/ldap/pdu.rb, line 53 def matched_dn tag[1] end
First item from responses.yaml
@return [String]
# File lib/rom/ldap/pdu.rb, line 165 def message detailed_response[0] end
@return [Symbol]
# File lib/rom/ldap/pdu.rb, line 255 def pdu_type BER.fetch(:response, app_tag) || raise(ResponseTypeInvalidError, "Unknown pdu_type: #{app_tag}") end
@return [Integer]
# File lib/rom/ldap/pdu.rb, line 46 def result_code tag[0] end
@return [Symbol]
# File lib/rom/ldap/pdu.rb, line 261 def result_code_symbol BER.fetch(:result, result_code) end
RFC-2251, an LDAP
'control' is a sequence of tuples, each consisting of
- an OID - a boolean criticality flag defaulting FALSE - and an optional Octet String
If only two fields are given, the second one may be either criticality or data, since criticality has a default value. RFC-2696 is a good example.
@see Connection::Read#search
@return [Array<OpenStruct>] => :oid, :criticality, :value
# File lib/rom/ldap/pdu.rb, line 151 def result_controls ctrls.map do |control| oid, level, value = control value, level = level, false if level.is_a?(String) ::OpenStruct.new(oid: oid, criticality: level, value: value) end end
# File lib/rom/ldap/pdu.rb, line 72 def result_server_sasl_creds return unless bind_result? && gteq4? tag[3] end
- “dn”, [ entry… ]
-
@return [Array, NilClass]
# File lib/rom/ldap/pdu.rb, line 133 def search_entry raise ResponseTypeInvalidError, 'Invalid search_entry' unless gteq_2? tag if search_result? end
@return [OpenStruct, NilClass] => :version, :name, :authentication
# File lib/rom/ldap/pdu.rb, line 102 def search_parameters return unless search_request? s = ::OpenStruct.new s.base_object, s.scope, s.deref_aliases, s.size_limit, s.time_limit, s.types_only, s.filter, s.attributes = tag s end
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 229 def search_referral? pdu_type == :search_result_referral end
# File lib/rom/ldap/pdu.rb, line 66 def search_referrals return unless search_referral? tag[3] || EMPTY_ARRAY end
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 217 def search_request? pdu_type.eql?(:search_request) end
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 223 def search_result? pdu_type.eql?(:search_returned_data) end
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 241 def success? SUCCESS_CODES.include?(result_code_symbol) end
Private Instance Methods
# File lib/rom/ldap/pdu.rb, line 267 def detailed_response RESPONSES[result_code_symbol] end
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 273 def gteq_2? tag.length >= 2 end
@return [Boolean]
# File lib/rom/ldap/pdu.rb, line 279 def gteq_3? tag.length >= 3 end