The net-ldap gem deprecated `Net::LDAP::LdapError` and renamed it to
`Net::LDAP::Error` starting with version 0.11 (released on Jan 21st,
2015). Version 0.17 (released on Nov 29th, 2020) removed the deprecaded
`Net::LDAP::LdapError` class.
Update the module to use the new class and unbreak the module when using
a recent version of net-ldap.
`to_s` the values too (like the attribute in line 129). This prevents the
copious logging of lines like
```
[puppetserver] Puppet Ssh_authorized_key[arjen-ssh-rsa]['user']['key']['type'] contains a Net::BER::BerIdentifiedString value. It will be converted to the String 'ssh-rsa'
```
for each and every piece of data that gets used from the `ldapquery` results.
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.
Previously, its impossible to know if the results you are working with
in the puppet manifest are in string or array form without counting
them. This work ensures that an array is always returned, even if there
is only one item returned.
This is useful in situations where an attribute is commonly both
multi-valued and single-valued to avoid complext manifest code.
Ldap has the potential to slow down compiles if a search takes too long.
Here we add timing information to the debug output, so that in case of
question, we can at least have a method of determining the time a given
search took.
Testing the methods inside of the function is a complete pain. This
moves the code out to use the PuppetX pattern and adds some basic unit
tests that validate the logic.