Method: Net::LDAP.open
- Defined in:
- lib/net/ldap.rb
.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
644 645 646 647 |
# File 'lib/net/ldap.rb', line 644 def self.open(args) ldap1 = new(args) ldap1.open { |ldap| yield ldap } end |