lib/net/ldap.rb in net-ldap-0.2.1 vs lib/net/ldap.rb in net-ldap-0.2.2

- old
+ new

@@ -239,11 +239,11 @@ # operation (typically binding first) and then disconnect from the server. # The exception is Net::LDAP#open, which makes a connection to the server # and then keeps it open while it executes a user-supplied block. # Net::LDAP#open closes the connection on completion of the block. class Net::LDAP - VERSION = "0.2.1" + VERSION = "0.2.2" class LdapError < StandardError; end SearchScope_BaseObject = 0 SearchScope_SingleLevel = 1 @@ -1457,22 +1457,22 @@ :delete => 1, :replace => 2 } def self.modify_ops(operations) - modify_ops = [] + ops = [] if operations operations.each { |op, attrib, values| # TODO, fix the following line, which gives a bogus error if the # opcode is invalid. op_ber = MODIFY_OPERATIONS[op.to_sym].to_ber_enumerated values = [ values ].flatten.map { |v| v.to_ber if v }.to_ber_set values = [ attrib.to_s.to_ber, values ].to_ber_sequence - modify_ops << [ op_ber, values ].to_ber + ops << [ op_ber, values ].to_ber } end - modify_ops + ops end #-- # TODO: need to support a time limit, in case the server fails to respond. # TODO: We're throwing an exception here on empty DN. Should return a @@ -1480,12 +1480,12 @@ # TODO: If the user specifies a bogus opcode, we'll throw a confusing # error here ("to_ber_enumerated is not defined on nil"). #++ def modify(args) modify_dn = args[:dn] or raise "Unable to modify empty DN" - modify_ops = modify_ops args[:operations] + ops = self.class.modify_ops args[:operations] request = [ modify_dn.to_ber, - modify_ops.to_ber_sequence ].to_ber_appsequence(6) + ops.to_ber_sequence ].to_ber_appsequence(6) pkt = [ next_msgid.to_ber, request ].to_ber_sequence @conn.write pkt (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" pdu.result_code