Method: Puppet::Util::Ldap::Connection#start

Defined in:
lib/vendor/puppet/util/ldap/connection.rb

#startObject

Start our ldap connection.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/vendor/puppet/util/ldap/connection.rb', line 59

def start
    case ssl
    when :tls
      @connection = LDAP::SSLConn.new(host, port, true)
    when true
      @connection = LDAP::SSLConn.new(host, port)
    else
      @connection = LDAP::Conn.new(host, port)
    end
    @connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
    @connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
    @connection.simple_bind(user, password)
rescue => detail
    raise Puppet::Error, "Could not connect to LDAP: #{detail}"
end