@@ -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
@@ -1219,7 +1224,9 @@ def use_connection(args)
12191224
12201225 # Establish a new connection to the LDAP server
12211226 def new_connection
1227+ socket = @connect_cb . call ( @host , @port ) if @connect_cb
12221228 Net ::LDAP ::Connection . new \
1229+ :socket => socket ,
12231230 :host => @host ,
12241231 :port => @port ,
12251232 :encryption => @encryption ,
0 commit comments