ruby-ldap/ruby-net-ldap

Add explicit close method

HynekPetrak opened this issue · 0 comments

Hi,

I assume in the below example (taken from the documentation) the TCP connection is not closed at the end and there is no method for that.
Can you please add explicit close method to the LDAP class? It's seems it's only assumed to go via #open method, which closes the connection in the ensure block.

require 'rubygems'
require 'net/ldap'

ldap = Net::LDAP.new :host => server_ip_address,
     :port => 389,
     :auth => {
           :method => :simple,
           :username => "cn=manager, dc=example, dc=com",
           :password => "opensesame"
     }

filter = Net::LDAP::Filter.eq("cn", "George*")
treebase = "dc=example, dc=com"

ldap.search(:base => treebase, :filter => filter) do |entry|
  puts "DN: #{entry.dn}"
  entry.each do |attribute, values|
    puts "   #{attribute}:"
    values.each do |value|
      puts "      --->#{value}"
    end
  end
end

p ldap.get_operation_result