@@ -241,7 +241,7 @@ class LDAP
241241# and then keeps it open while it executes a user-supplied block.
242242# Net::LDAP#open closes the connection on completion of the block.
243243class Net ::LDAP
244- VERSION = "0.2"
244+ VERSION = "0.2.1 "
245245
246246 class LdapError < StandardError ; end
247247
@@ -1452,18 +1452,25 @@ def search(args = {})
14521452 result_code
14531453 end
14541454
1455- def self . modify_ops args
1456- modify_ops = [ ]
1457- a = args [ :operations ] and a . each { |op , attr , values |
1458- # TODO, fix the following line, which gives a bogus error
1459- # if the opcode is invalid.
1460- op_1 = { :add => 0 , :delete => 1 , :replace => 2 } [ op . to_sym ] . to_ber_enumerated
1461- values = [ values ] . flatten . map { |v |
1462- v . to_ber unless v . nil?
1463- } . to_ber_set
1464- modify_ops << [ op_1 , [ attr . to_s . to_ber , values ] . to_ber_sequence ] . to_ber
1455+ MODIFY_OPERATIONS = { #:nodoc:
1456+ :add => 0 ,
1457+ :delete => 1 ,
1458+ :replace => 2
1459+ }
1460+
1461+ def self . modify_ops ( operations )
1462+ modify_ops = [ ]
1463+ if operations
1464+ operations . each { |op , attrib , values |
1465+ # TODO, fix the following line, which gives a bogus error if the
1466+ # opcode is invalid.
1467+ op_ber = MODIFY_OPERATIONS [ op . to_sym ] . to_ber_enumerated
1468+ values = [ values ] . flatten . map { |v | v . to_ber if v } . to_ber_set
1469+ values = [ attrib . to_s . to_ber , values ] . to_ber_sequence
1470+ modify_ops << [ op_ber , values ] . to_ber
14651471 }
1466- modify_ops
1472+ end
1473+ modify_ops
14671474 end
14681475
14691476 #--
@@ -1476,9 +1483,9 @@ def self.modify_ops args
14761483 def modify ( args )
14771484 modify_dn = args [ :dn ] or raise "Unable to modify empty DN"
14781485 modify_ops = modify_ops args [ :operations ]
1479- request = [ modify_dn . to_ber ,
1480- modify_ops . to_ber_sequence ] . to_ber_appsequence ( 6 )
1481- pkt = [ next_msgid . to_ber , request ] . to_ber_sequence
1486+ request = [ modify_dn . to_ber ,
1487+ modify_ops . to_ber_sequence ] . to_ber_appsequence ( 6 )
1488+ pkt = [ next_msgid . to_ber , request ] . to_ber_sequence
14821489 @conn . write pkt
14831490
14841491 ( be = @conn . read_ber ( Net ::LDAP ::AsnSyntax ) ) && ( pdu = Net ::LDAP ::PDU . new ( be ) ) && ( pdu . app_tag == 7 ) or raise Net ::LDAP ::LdapError , "response missing or invalid"
0 commit comments