Class: ROM::LDAP::PDU Private

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Defined in:
lib/rom/ldap/pdu.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

LDAP Message Protocol Data Unit (PDU)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tagArray (readonly)

Returns:

  • (Array)


34
# File 'lib/rom/ldap/pdu.rb', line 34

param :tag, reader: :private, type: Types::Strict::Array

Instance Method Details

#add_response?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


193
194
195
# File 'lib/rom/ldap/pdu.rb', line 193

def add_response?
  pdu_type == :add_response
end

#adviceString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Examples:

"Matchingrule is required for sorting by the attribute cn"

Returns:

  • (String)


62
63
64
# File 'lib/rom/ldap/pdu.rb', line 62

def advice
  tag[2]
end

#app_tagInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


40
41
42
# File 'lib/rom/ldap/pdu.rb', line 40

def app_tag
  tag.ber_identifier & 0x1f
end

#bind_parametersOpenStruct

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns => :version, :name, :authentication.

Returns:

  • (OpenStruct)

    > :version, :name, :authentication



91
92
93
94
95
96
97
# 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

#bind_request?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



201
202
203
# File 'lib/rom/ldap/pdu.rb', line 201

def bind_request?
  pdu_type == :bind_request
end

#bind_resultArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns => [version, username, password].

Returns:

  • (Array)

    > [version, username, password]

Raises:

  • (ResponseTypeInvalidError)


81
82
83
84
85
86
# 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

#bind_result?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A successful operation is indicated by a BindResponse with a resultCode set to success.



211
212
213
# File 'lib/rom/ldap/pdu.rb', line 211

def bind_result?
  pdu_type.eql?(:bind_result)
end

#error_messageString, FalseClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Grep for error message

Returns:

  • (String, FalseClass)


173
174
175
# File 'lib/rom/ldap/pdu.rb', line 173

def error_message
  tag[3][/comment: (.*), data/, 1] if tag[3]
end

#extended_responseString, NilClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Message

Examples:

> “No attribute with the name false exists in the server’s schema”


Returns:

  • (String, NilClass)

Raises:

  • (ResponseTypeInvalidError)


123
124
125
126
127
# 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

#extended_response?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


235
236
237
# File 'lib/rom/ldap/pdu.rb', line 235

def extended_response?
  pdu_type == :extended_response
end

#failure?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


247
248
249
# File 'lib/rom/ldap/pdu.rb', line 247

def failure?
  !success?
end

#flagString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


185
186
187
# File 'lib/rom/ldap/pdu.rb', line 185

def flag
  detailed_response[2]
end

#infoString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


179
180
181
# File 'lib/rom/ldap/pdu.rb', line 179

def info
  detailed_response[1]
end

#matched_dnString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


53
54
55
# File 'lib/rom/ldap/pdu.rb', line 53

def matched_dn
  tag[1]
end

#messageString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

First item from responses.yaml

Returns:

  • (String)


165
166
167
# File 'lib/rom/ldap/pdu.rb', line 165

def message
  detailed_response[0]
end

#pdu_typeSymbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Symbol)


255
256
257
# File 'lib/rom/ldap/pdu.rb', line 255

def pdu_type
  BER.fetch(:response, app_tag) || raise(ResponseTypeInvalidError, "Unknown pdu_type: #{app_tag}")
end

#result_codeInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)


46
47
48
# File 'lib/rom/ldap/pdu.rb', line 46

def result_code
  tag[0]
end

#result_code_symbolSymbol

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Symbol)


261
262
263
# File 'lib/rom/ldap/pdu.rb', line 261

def result_code_symbol
  BER.fetch(:result, result_code)
end

#result_controlsArray<OpenStruct>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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.

Returns:

  • (Array<OpenStruct>)

    > :oid, :criticality, :value

See Also:

  • Connection::Read#search


151
152
153
154
155
156
157
# 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

#result_server_sasl_credsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



72
73
74
75
76
# File 'lib/rom/ldap/pdu.rb', line 72

def result_server_sasl_creds
  return unless bind_result? && gteq4?

  tag[3]
end

#search_entryArray, NilClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

“dn”, [ entry… ]

Returns:

  • (Array, NilClass)

Raises:

  • (ResponseTypeInvalidError)


133
134
135
136
137
# File 'lib/rom/ldap/pdu.rb', line 133

def search_entry
  raise ResponseTypeInvalidError, 'Invalid search_entry' unless gteq_2?

  tag if search_result?
end

#search_parametersOpenStruct, NilClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns => :version, :name, :authentication.

Returns:

  • (OpenStruct, NilClass)

    > :version, :name, :authentication



102
103
104
105
106
107
108
109
110
111
112
113
114
115
# 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

#search_referral?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


229
230
231
# File 'lib/rom/ldap/pdu.rb', line 229

def search_referral?
  pdu_type == :search_result_referral
end

#search_referralsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



66
67
68
69
70
# File 'lib/rom/ldap/pdu.rb', line 66

def search_referrals
  return unless search_referral?

  tag[3] || EMPTY_ARRAY
end

#search_request?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


217
218
219
# File 'lib/rom/ldap/pdu.rb', line 217

def search_request?
  pdu_type.eql?(:search_request)
end

#search_result?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


223
224
225
# File 'lib/rom/ldap/pdu.rb', line 223

def search_result?
  pdu_type.eql?(:search_returned_data)
end

#success?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


241
242
243
# File 'lib/rom/ldap/pdu.rb', line 241

def success?
  SUCCESS_CODES.include?(result_code_symbol)
end