Class: Puppet::Indirector::Ldap
- Defined in:
- lib/puppet/indirector/ldap.rb
Direct Known Subclasses
Constant Summary
Constants included from Util
Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE
Constants included from Util::POSIX
Util::POSIX::LOCALE_ENV_VARS, Util::POSIX::USER_ENV_VARS
Constants included from Util::SymbolicFileMode
Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit
Constants included from Util::Docs
Instance Attribute Summary
Attributes included from Util::Docs
Instance Method Summary collapse
-
#connection ⇒ Object
Create an ldap connection.
-
#find(request) ⇒ Object
Perform our ldap search and process the result.
-
#ldapsearch(filter) ⇒ Object
Find the ldap node, return the class list and parent node specially, and everything else in a parameter hash.
-
#process(entry) ⇒ Object
Process the found entry.
-
#search_attributes ⇒ Object
Default to all attributes.
- #search_base ⇒ Object
-
#search_filter(name) ⇒ Object
The ldap search filter to use.
Methods inherited from Terminus
abstract_terminus?, #allow_remote_requests?, const2name, #indirection, indirection_name, inherited, #initialize, mark_as_abstract_terminus, model, #model, #name, name2const, register_terminus_class, terminus_class, terminus_classes, #terminus_type, #validate, #validate_key, #validate_model
Methods included from Util::InstanceLoader
#instance_docs, #instance_hash, #instance_load, #instance_loader, #instance_loading?, #loaded_instance, #loaded_instances
Methods included from Util
absolute_path?, benchmark, chuser, clear_environment, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, safe_posix_fork, set_env, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, which, withenv, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from Util::SymbolicFileMode
#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Methods included from Util::Docs
#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub
Constructor Details
This class inherits a constructor from Puppet::Indirector::Terminus
Instance Method Details
#connection ⇒ Object
Create an ldap connection.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/puppet/indirector/ldap.rb', line 63 def connection unless @connection #TRANSLATORS "ruby/ldap libraries" are code dependencies raise Puppet::Error, _("Could not set up LDAP Connection: Missing ruby/ldap libraries") unless Puppet.features.ldap? begin conn = Puppet::Util::Ldap::Connection.instance conn.start @connection = conn.connection rescue => detail = _("Could not connect to LDAP: %{detail}") % { detail: detail } Puppet.log_exception(detail, ) raise Puppet::Error, , detail.backtrace end end @connection end |
#find(request) ⇒ Object
Perform our ldap search and process the result.
6 7 8 |
# File 'lib/puppet/indirector/ldap.rb', line 6 def find(request) ldapsearch(search_filter(request.key)) { |entry| return process(entry) } || nil end |
#ldapsearch(filter) ⇒ Object
Find the ldap node, return the class list and parent node specially, and everything else in a parameter hash.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/puppet/indirector/ldap.rb', line 32 def ldapsearch(filter) raise ArgumentError.new(_("You must pass a block to ldapsearch")) unless block_given? found = false count = 0 begin connection.search(search_base, 2, filter, search_attributes) do |entry| found = true yield entry end rescue SystemExit,NoMemoryError raise rescue Exception => detail if count == 0 # Try reconnecting to ldap if we get an exception and we haven't yet retried. count += 1 @connection = nil Puppet.warning _("Retrying LDAP connection") retry else error = Puppet::Error.new(_("LDAP Search failed")) error.set_backtrace(detail.backtrace) raise error end end found end |
#process(entry) ⇒ Object
Process the found entry. We assume that we don’t just want the ldap object.
12 13 14 |
# File 'lib/puppet/indirector/ldap.rb', line 12 def process(entry) raise Puppet::DevError, "The 'process' method has not been overridden for the LDAP terminus for #{self.name}" end |
#search_attributes ⇒ Object
Default to all attributes.
17 18 19 |
# File 'lib/puppet/indirector/ldap.rb', line 17 def search_attributes nil end |