Method: Net::LDAP.open
- Defined in:
- lib/net/ldap.rb
permalink .open(args) ⇒ Object
#open takes the same parameters as #new. #open makes a network connection to the LDAP server and then passes a newly-created Net::LDAP object to the caller-supplied block. Within the block, you can call any of the instance methods of Net::LDAP to perform operations against the LDAP directory. #open will perform all the operations in the user-supplied block on the same network connection, which will be closed automatically when the block finishes.
# (PSEUDOCODE)
auth = {:method => :simple, :username => username, :password => password}
Net::LDAP.open( :host => ipaddress, :port => 389, :auth => auth ) do |ldap|
ldap.search( ... )
ldap.add( ... )
ldap.modify( ... )
end
490 491 492 493 |
# File 'lib/net/ldap.rb', line 490 def LDAP::open args ldap1 = LDAP.new args ldap1.open {|ldap| yield ldap } end |