Class: ElDap::Worker

Inherits:
Net::LDAP
  • Object
show all
Includes:
Constants
Defined in:
lib/el_dap/worker.rb

Constant Summary

Constants included from Constants

Constants::LDAP_ATTRS, Constants::LDAP_FILTERS, Constants::LDAP_SEARCH_FIELD

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Worker

Returns a new instance of Worker.



5
6
7
8
9
10
# File 'lib/el_dap/worker.rb', line 5

def initialize(args = {})
  super args
  self.host = args[:ip_address]
  self.auth args[:username], args[:password]
  self
end

Instance Method Details

#search_directory(search_string, treebase) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/el_dap/worker.rb', line 12

def search_directory(search_string, treebase)
  filters = LDAP_FILTERS & ::Net::LDAP::Filter.eq(LDAP_SEARCH_FIELD, "*#{search_string}*")
  search_result = search(:base => treebase,
                         :filter => filters,
                         :attributes => LDAP_ATTRS,
                         :return_result => true)
  # search will return false if unable to bind
  # e.g. service account credentials have expired
  return [] unless search_result
  create_result_collection search_result
end