Module: ROM::LDAP::Client::Operations Private
- Included in:
- ROM::LDAP::Client
- Defined in:
- lib/rom/ldap/client/operations.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Adds entry creation capability to the connection.
Instance Method Summary collapse
- #add(dn:, attrs:) ⇒ Object private
- #delete(dn:, controls: nil) ⇒ Object private
-
#password_modify(dn:, old_pwd: nil, new_pwd:) ⇒ PDU
Password should have a minimum of 5 characters.
-
#rename(dn:, rdn:, replace: false, superior: nil) ⇒ PDU
TODO: spec rename and use by relations.
-
#search(return_refs: true, **params) {|Entry| ... } ⇒ Object
private
Connection Search Operation.
-
#update(dn:, ops:) ⇒ PDU
private
Result object.
Instance Method Details
#add(dn:, attrs:) ⇒ Object
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.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/rom/ldap/client/operations.rb', line 100 def add(dn:, attrs:) request_type = pdu_lookup(:add_request) ber_attrs = attrs.each_with_object([]) do |(k, v), attributes| ber_values = values_to_ber_set(v) attributes << [k.to_s.to_ber, ber_values].to_ber_sequence end request = [ dn.to_ber, ber_attrs.to_ber_sequence ].to_ber_appsequence(request_type) submit(:add_response, request) end |
#delete(dn:, controls: nil) ⇒ Object
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.
121 122 123 124 125 126 127 128 129 130 |
# File 'lib/rom/ldap/client/operations.rb', line 121 def delete(dn:, controls: nil) request_type = pdu_lookup(:delete_request) request = dn.to_ber_application_string(request_type) if controls submit(:delete_response, request, controls.to_ber_control) else submit(:delete_response, request) end end |
#password_modify(dn:, old_pwd: nil, new_pwd:) ⇒ PDU
Password should have a minimum of 5 characters.
189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/rom/ldap/client/operations.rb', line 189 def password_modify(dn:, old_pwd: nil, new_pwd:) request_type = pdu_lookup(:extended_request) context = OID[:password_modify].to_ber_contextspecific(0) payload = [dn.to_ber(0x80)] payload << old_pwd.to_ber(0x81) if old_pwd payload << new_pwd.to_ber(0x82) payload = payload.to_ber_sequence.to_ber(0x81) request = [context, payload].to_ber_appsequence(request_type) submit(:extended_response, request) end |
#rename(dn:, rdn:, replace: false, superior: nil) ⇒ PDU
TODO: spec rename and use by relations
164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/rom/ldap/client/operations.rb', line 164 def rename(dn:, rdn:, replace: false, superior: nil) request_type = pdu_lookup(:modify_rdn_request) request = [dn, rdn, replace].map { |a| a.to_ber } # &:to_ber request << superior.to_ber_contextspecific(0) if superior request = request.to_ber_appsequence(request_type) submit(:modify_rdn_response, request) end |
#search(return_refs: true, **params) {|Entry| ... } ⇒ Object
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.
Write spec for yielding search_referrals
Connection Search Operation
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/rom/ldap/client/operations.rb', line 27 def search(return_refs: true, **params) search_request = SearchRequest.new(params) request_type = pdu_lookup(:search_request) result_pdu = nil more_pages = false = [126, EMPTY_STRING] # paged_results_cookie = [10, EMPTY_STRING] request = search_request.parts.to_ber_appsequence(request_type) controls = search_request.controls = next_msgid loop do write(request, , controls) result_pdu = nil controls = EMPTY_ARRAY while (pdu = from_queue()) case pdu.app_tag when pdu_lookup(:search_returned_data) # 4 yield(pdu.search_entry) when pdu_lookup(:search_result) # 5 result_pdu = pdu controls = pdu.result_controls yield(search_referrals: pdu.search_referrals) if return_refs && pdu.search_referral? break when pdu_lookup(:search_result_referral) # 19 yield(search_referrals: pdu.search_referrals) if return_refs else raise ResponseTypeInvalidError, "invalid response-type in search: #{pdu.app_tag}" end end if result_pdu&.success? controls.each do |c| next if c.oid != OID[:paged_results] next if c.value&.empty? # [ 0, "" ] _int, = c.value.read_ber # next page of results # unless &.empty? # cookie => "\u0001\u0000\u0000" # cookie.read_ber => true [1] = more_pages = true end end end break unless more_pages end result_pdu ensure queue.delete() end |
#update(dn:, ops:) ⇒ PDU
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 result object.
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rom/ldap/client/operations.rb', line 139 def update(dn:, ops:) request_type = pdu_lookup(:modify_request) operations = modify_ops(ops) request = [ dn.to_ber, operations.to_ber_sequence ].to_ber_appsequence(request_type) submit(:modify_response, request) end |