diff --git a/lib/puppet/parser/functions/ldapquery.rb b/lib/puppet/parser/functions/ldapquery.rb index 3110671..4ecb2cc 100644 --- a/lib/puppet/parser/functions/ldapquery.rb +++ b/lib/puppet/parser/functions/ldapquery.rb @@ -17,15 +17,17 @@ end Puppet::Parser::Functions.newfunction(:ldapquery, type: :rvalue) do |args| - if args.size > 4 + if args.size > 3 raise Puppet::ParseError, 'Too many arguments received in ldapquery()' end - filter, attributes, base, scope = args + filter, attributes, opts = args attributes ||= [] - base ||= Puppet[:ldapbase] - scope ||= 'sub' + opts ||= {} + base = opts['base'] || Puppet[:ldapbase] + scope = opts['scope'] || 'sub' + server = opts['server'] || Puppet[:ldapserver] - return PuppetX::LDAPquery.new(filter, attributes, base, scope).results + return PuppetX::LDAPquery.new(filter, attributes, base, scope, server).results end diff --git a/lib/puppet_x/ldapquery.rb b/lib/puppet_x/ldapquery.rb index 6cbe3b9..c7f6993 100644 --- a/lib/puppet_x/ldapquery.rb +++ b/lib/puppet_x/ldapquery.rb @@ -9,11 +9,13 @@ module PuppetX filter, attributes = [], base = Puppet[:ldapbase], - scope = 'sub' + scope = 'sub', + server = Puppet[:ldapserver] ) @filter = filter @attributes = attributes @base = base + @host = server return unless scope @@ -41,7 +43,6 @@ module PuppetX end end - host = Puppet[:ldapserver] port = Puppet[:ldapport] if Puppet[:ldapuser] && Puppet[:ldappassword] @@ -53,7 +54,7 @@ module PuppetX ca_file = "#{Puppet[:confdir]}/ldap_ca.pem" conf = { - host: host, + host: @host, port: port }