@@ -241,7 +241,7 @@ class LDAP
241
241
# and then keeps it open while it executes a user-supplied block.
242
242
# Net::LDAP#open closes the connection on completion of the block.
243
243
class Net ::LDAP
244
- VERSION = "0.2"
244
+ VERSION = "0.2.1 "
245
245
246
246
class LdapError < StandardError ; end
247
247
@@ -1452,18 +1452,25 @@ def search(args = {})
1452
1452
result_code
1453
1453
end
1454
1454
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
1465
1471
}
1466
- modify_ops
1472
+ end
1473
+ modify_ops
1467
1474
end
1468
1475
1469
1476
#--
@@ -1476,9 +1483,9 @@ def self.modify_ops args
1476
1483
def modify ( args )
1477
1484
modify_dn = args [ :dn ] or raise "Unable to modify empty DN"
1478
1485
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
1482
1489
@conn . write pkt
1483
1490
1484
1491
( 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