summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-01 21:20:13 -0500
committerLuke Kanies <luke@madstop.com>2008-07-01 22:22:07 -0500
commita1d1abdd5a2fc11dceeed63da8c6f48d2fa21cfe (patch)
tree2fcc0518905ad74bf5d05928556a81af109262a2 /lib/puppet/util
parent4bdb793092a1aee1798d921cb82ee9c12f0c51be (diff)
downloadpuppet-a1d1abdd5a2fc11dceeed63da8c6f48d2fa21cfe.tar.gz
puppet-a1d1abdd5a2fc11dceeed63da8c6f48d2fa21cfe.tar.xz
puppet-a1d1abdd5a2fc11dceeed63da8c6f48d2fa21cfe.zip
Adding an 'instance' class method to ldap connections.
This just returns a Connection instance with the default ldap configuration information already provided.
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/ldap/connection.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb
index abcc07ecb..861539872 100644
--- a/lib/puppet/util/ldap/connection.rb
+++ b/lib/puppet/util/ldap/connection.rb
@@ -8,6 +8,18 @@ class Puppet::Util::Ldap::Connection
attr_reader :connection
+ # Return a default connection, using our default settings.
+ def self.instance
+ ssl = if Puppet[:ldaptls]
+ :tls
+ elsif Puppet[:ldapssl]
+ true
+ else
+ false
+ end
+ new(Puppet[:ldapserver], Puppet[:ldapport], :ssl => ssl)
+ end
+
def close
connection.unbind if connection.bound?
end
@@ -51,6 +63,7 @@ class Puppet::Util::Ldap::Connection
@connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
@connection.simple_bind(user, password)
rescue => detail
+ puts detail.class
raise Puppet::Error, "Could not connect to LDAP: %s" % detail
end
end