Giter VIP home page Giter VIP logo

puppet-ldap's Introduction

Overview

This module is a suite of utility functions for Puppet that allow for the arbitrary query and retrieval of data from an LDAP server.

Usage

The included functions are documented thusly:

ldapquery ( FILTER_OR_LDAP_URL, [ ATTRIBUTE ], [ FIRST_RESULT_ONLY ] )

This function takes one mandatory and two optional arguments and returns either an array or a string value. The first argument can be any valid LDAP filter string (e.g. (|(mail=)(pager=))), or an LDAP URL that strongly resembles a standard RFC 2255 LDAP URL. See below for details.

The second argument specifies the name of the attribute to return from the LDAP object (if using a filter or if not specified in the URL). If omitted, it will default to the DN value of the result(s).

The third argument is a boolean value that specifies whether to return an array of all results (default) or only the first result (as a string).

Examples

ldapquery("(mail=@example.net)")*

This will perform an LDAP query for all objects up to one level below the root (default) that contain a mail attribute. It will return an array of distinguished names (DNs).

ldapquery("(mail=@example.net)", “uid”)*

This is the same as above, except it will return an array of non-empty values from the ‘uid’ attribute of each matching result.

ldapquery(“ldap:///ou=People???(uid=bob)”, “cn”)

This will query the directory for all objects directly under the ‘People’ OU whose ‘uid’ attribute is ‘bob’, returning an array of ‘cn’ values.

LDAP URLs

The first argument to ldapquery() can either be a standard LDAP filter string, or a fully qualified LDAP URL. The URL resembles the RFC 2255 format, but has a few additional features that make it easier to use within the context of Puppet.

The format of the URL breaks down like this:

ldap:// [HOST[:PORT]] / [BASE_DN] ? [ATTRIB[, ...]] ? SCOPE ? FILTER ? [EXTENSIONS ...]
  • HOST and PORT are optional components that specify the LDAP server to query. If omitted, it will default to the value of the ‘ldapserver’ configuration in puppet.conf.
  • BASE_DN is the location to begin the search from. If omitted, it will default to the value of the ‘ldapbase’ configuration in puppet.conf. If a BASE_DN is specified that does not contain at least one ‘dc=’ component, it is taken to be a relative value. In this case, the value of ‘ldapbase’ will automatically be appended to the supplied value.
For example, given that puppet.conf reads:
[main]
…
ldapbase = dc=example,dc=net
The Base DN for the URL ldap:///ou=Groups???(cn=*) would expand to ou=Groups,dc=example,dc=net.
  • ATTRIB is a comma-separated list of one or more attributes the search should return.
  • SCOPE is one of ‘base’, ‘one’, or ‘sub’ that specifies the scope of the LDAP query to be run. ‘base’ will only search within the object specified as BASE_DN, ‘one’ will search up to one level below BASE_DN, and ‘sub’ will search the entire subtree below BASE_DN. The default is ‘one’.
  • FILTER is the LDAP Query to be run. This component is required.
  • EXTENSIONS are a comma-separated list of key=value pairs that can be passed into the function for various purposes. These are completely custom to this URL format. Currently supported extensions are:
    • userfact: the Facter fact that contains the username to be used in the LDAP bind.
    • passfact: the Facter fact that contains the password to be used in the LDAP bind.
    • timeout: specifies the amount of time (in seconds) before the query is cancelled.
    • multi: specifies what to do with attributes that appear multiple times in a result set.
      • first: only return the first value
      • join: join all values using attrDelim
      • merge: append all values into the result set (default)
    • attrDelim: specifies the string to join multiple attributes on (default: comma)

puppet-ldap's People

Contributors

ghetzel avatar

Stargazers

Zach Leslie avatar  avatar Stefan Jenkner avatar Erik Dalén avatar

Watchers

 avatar

puppet-ldap's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.