Class: ElDap::Base
- Inherits:
-
Object
- Object
- ElDap::Base
- Defined in:
- lib/el_dap/base.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#server_ips ⇒ Object
Returns the value of attribute server_ips.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#treebase ⇒ Object
Returns the value of attribute treebase.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Base
constructor
A new instance of Base.
- #search(search_string) ⇒ Object
- #validate(username, password) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 |
# File 'lib/el_dap/base.rb', line 5 def initialize @server_ips = [] @timeout = 15 yield(self) if block_given? end |
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/el_dap/base.rb', line 3 def password @password end |
#server_ips ⇒ Object
Returns the value of attribute server_ips.
3 4 5 |
# File 'lib/el_dap/base.rb', line 3 def server_ips @server_ips end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/el_dap/base.rb', line 3 def timeout @timeout end |
#treebase ⇒ Object
Returns the value of attribute treebase.
3 4 5 |
# File 'lib/el_dap/base.rb', line 3 def treebase @treebase end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/el_dap/base.rb', line 3 def username @username end |
Instance Method Details
#search(search_string) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/el_dap/base.rb', line 26 def search(search_string) return nil if Validator.blank?(search_string) @server_ips.each do |ip_address| begin TimeCop.timer.timeout(self.timeout) do worker = Worker.new(:username => self.username, :password => self.password, :ip_address => ip_address) raise(InvalidCredentialsError, 'The user credentials provided are invalid') unless worker.bind return worker.search_directory(search_string, self.treebase) end rescue Timeout::Error next end end false end |
#validate(username, password) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/el_dap/base.rb', line 11 def validate(username, password) return false if Validator.blank?(username, password) @server_ips.each do |ip_address| begin TimeCop.timer.timeout(self.timeout) do worker = Worker.new(:username => username, :password => password, :ip_address => ip_address) return worker.bind end rescue Timeout::Error next end end end |