summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-01 22:06:40 -0500
committerLuke Kanies <luke@madstop.com>2008-07-01 22:22:07 -0500
commit4d22a95b571991eb47046c3b0103b2e733b2801d (patch)
tree0ccc6dcfe19bf060510dd6d2ba4bf1216f6b24da /lib
parentb47d4e1b3e1224541e555648854baf0503b1612e (diff)
downloadpuppet-4d22a95b571991eb47046c3b0103b2e733b2801d.tar.gz
puppet-4d22a95b571991eb47046c3b0103b2e733b2801d.tar.xz
puppet-4d22a95b571991eb47046c3b0103b2e733b2801d.zip
Switching the ldap terminus to use Util::Ldap::Connection.
This is a simplified class for managing ldap connections, and this work just removes some duplication.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/indirector/ldap.rb19
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb
index 7c3aca0da..7485bd932 100644
--- a/lib/puppet/indirector/ldap.rb
+++ b/lib/puppet/indirector/ldap.rb
@@ -1,4 +1,5 @@
require 'puppet/indirector/terminus'
+require 'puppet/util/ldap/connection'
class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
# Perform our ldap search and process the result.
@@ -56,8 +57,6 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
return found
end
- private
-
# Create an ldap connection.
def connection
unless defined? @connection and @connection
@@ -65,19 +64,11 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
raise Puppet::Error, "Could not set up LDAP Connection: Missing ruby/ldap libraries"
end
begin
- if Puppet[:ldapssl]
- @connection = LDAP::SSLConn.new(Puppet[:ldapserver], Puppet[:ldapport])
- elsif Puppet[:ldaptls]
- @connection = LDAP::SSLConn.new(
- Puppet[:ldapserver], Puppet[:ldapport], true
- )
- else
- @connection = LDAP::Conn.new(Puppet[:ldapserver], Puppet[:ldapport])
- end
- @connection.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
- @connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
- @connection.simple_bind(Puppet[:ldapuser], Puppet[:ldappassword])
+ conn = Puppet::Util::Ldap::Connection.instance
+ conn.start
+ @connection = conn.connection
rescue => detail
+ puts detail.backtrace if Puppet[:trace]
raise Puppet::Error, "Could not connect to LDAP: %s" % detail
end
end