1 module Puppet::Parser::Functions
2 newfunction(:ldapinfo, :type => :rvalue) do |attributes|
4 host = attributes.shift
6 unless attributes.include?("*") or attributes.include?('hostname')
7 attributes << 'hostname'
11 ldap = LDAP::SSLConn.new('db.debian.org', 636)
14 filter = '(hostname=' + host + ')'
16 ldap.search2('ou=hosts,dc=debian,dc=org', LDAP::LDAP_SCOPE_SUBTREE, filter, attrs=attributes, false, 0, 0, s_attr="hostname").each do |x|
17 results[x['hostname'][0]] = x
19 rescue LDAP::ResultError
20 raise Puppet::ParseError, "LDAP error"
22 raise Puppet::ParseError, "No data returned from search"