mirror of
https://github.com/philippdieter/puppet-ldapquery.git
synced 2026-05-06 07:42:46 +00:00
Add support for scoped queries
This work adds support for setting the scope of a given query. This allows retrieval of a specific objects, or searching at a specific level of the tree for the desired results.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
# Provides a query interface to an LDAP server
|
||||
#
|
||||
# @example simple query
|
||||
# ldapquery("(objectClass=dnsDomain)", ['dc'])
|
||||
#
|
||||
# @example more complex query for ssh public keys
|
||||
# ldapquery('(&(objectClass=ldapPublicKey)(sshPublicKey=*)(objectClass=posixAccount))', ['uid', 'sshPublicKey'])
|
||||
#
|
||||
require_relative '../../../puppet_x/ldapquery'
|
||||
|
||||
begin
|
||||
@@ -9,14 +17,15 @@ end
|
||||
Puppet::Parser::Functions.newfunction(:ldapquery,
|
||||
:type => :rvalue) do |args|
|
||||
|
||||
if args.size > 3
|
||||
if args.size > 4
|
||||
raise Puppet::ParseError, "Too many arguments received in ldapquery()"
|
||||
end
|
||||
|
||||
filter, attributes, base = args
|
||||
filter, attributes, base, scope = args
|
||||
|
||||
attributes ||= []
|
||||
base ||= Puppet[:ldapbase]
|
||||
scope ||= 'sub'
|
||||
|
||||
return PuppetX::LDAPquery.new(filter, attributes, base).results
|
||||
return PuppetX::LDAPquery.new(filter, attributes, base, scope).results
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user