Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/net/ldap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class LdapError < StandardError; end
DefaultAuth = { :method => :anonymous }
DefaultTreebase = "dc=com"
DefaultForceNoPage = false
DefaultKeepalive = true

StartTlsOid = "1.3.6.1.4.1.1466.20037"

Expand Down Expand Up @@ -473,6 +474,7 @@ def initialize(args = {})
@auth = args[:auth] || DefaultAuth
@base = args[:base] || DefaultTreebase
@force_no_page = args[:force_no_page] || DefaultForceNoPage
@keepalive = args[:keepalive] || DefaultKeepalive
encryption args[:encryption] # may be nil

if pr = @auth[:password] and pr.respond_to?(:call)
Expand Down Expand Up @@ -851,6 +853,11 @@ def bind(auth = @auth)
:instrumentation_service => @instrumentation_service
payload[:connection] = conn
payload[:bind] = @result = conn.bind(auth)
if @keepalive
@open_connection.close if @open_connection
@open_connection = conn
conn = nil
end
ensure
conn.close if conn
end
Expand Down