@@ -441,6 +441,10 @@ def self.result2string(code) #:nodoc:
441441 # described below. The following arguments are supported:
442442 # * :host => the LDAP server's IP-address (default 127.0.0.1)
443443 # * :port => the LDAP server's TCP port (default 389)
444+ # * :connect_cb => a Proc that will be called when a new connection is
445+ # needed. This should return an actual Ruby IO object. Useful for
446+ # manually handling connecting, like if you want to go through a proxy
447+ # server. It will receive :host: and :port: as arguments.
444448 # * :auth => a Hash containing authorization parameters. Currently
445449 # supported values include: {:method => :anonymous} and {:method =>
446450 # :simple, :username => your_user_name, :password => your_password }
@@ -469,6 +473,7 @@ def self.result2string(code) #:nodoc:
469473 def initialize ( args = { } )
470474 @host = args [ :host ] || DefaultHost
471475 @port = args [ :port ] || DefaultPort
476+ @connect_cb = args [ :connect_cb ]
472477 @verbose = false # Make this configurable with a switch on the class.
473478 @auth = args [ :auth ] || DefaultAuth
474479 @base = args [ :base ] || DefaultTreebase
@@ -1215,7 +1220,9 @@ def use_connection(auth)
12151220 end
12161221
12171222 def new_connection
1223+ socket = @connect_cb . call ( @host , @port ) if @connect_cb
12181224 Net ::LDAP ::Connection . new \
1225+ :socket => socket ,
12191226 :host => @host ,
12201227 :port => @port ,
12211228 :encryption => @encryption ,
0 commit comments