@@ -441,6 +441,10 @@ def self.result2string(code) #:nodoc:
441
441
# described below. The following arguments are supported:
442
442
# * :host => the LDAP server's IP-address (default 127.0.0.1)
443
443
# * :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.
444
448
# * :auth => a Hash containing authorization parameters. Currently
445
449
# supported values include: {:method => :anonymous} and {:method =>
446
450
# :simple, :username => your_user_name, :password => your_password }
@@ -469,6 +473,7 @@ def self.result2string(code) #:nodoc:
469
473
def initialize ( args = { } )
470
474
@host = args [ :host ] || DefaultHost
471
475
@port = args [ :port ] || DefaultPort
476
+ @connect_cb = args [ :connect_cb ]
472
477
@verbose = false # Make this configurable with a switch on the class.
473
478
@auth = args [ :auth ] || DefaultAuth
474
479
@base = args [ :base ] || DefaultTreebase
@@ -1219,7 +1224,9 @@ def use_connection(args)
1219
1224
1220
1225
# Establish a new connection to the LDAP server
1221
1226
def new_connection
1227
+ socket = @connect_cb . call ( @host , @port ) if @connect_cb
1222
1228
Net ::LDAP ::Connection . new \
1229
+ :socket => socket ,
1223
1230
:host => @host ,
1224
1231
:port => @port ,
1225
1232
:encryption => @encryption ,
0 commit comments