Class: Wobaduser::LDAP
- Inherits:
-
Object
- Object
- Wobaduser::LDAP
- Defined in:
- lib/wobaduser/ldap.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#ldap_options ⇒ Object
readonly
Returns the value of attribute ldap_options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ LDAP
constructor
Wobaduser::LDAP.new({, bind: true}).
-
#operation_error ⇒ Object
returns last ldap operation error, if any.
-
#search(options = {}) ⇒ Object
execute ldap search operation.
Constructor Details
#initialize(options = {}) ⇒ LDAP
Wobaduser::LDAP.new({, bind: true})
:ldap_options
-
for possible ldap options see Net::LDAP::new
:bind
-
true: bind on initialize, false: bind on later operations
13 14 15 16 17 18 19 |
# File 'lib/wobaduser/ldap.rb', line 13 def initialize( = {}) .symbolize_keys! reset_errors @ldap_options = .fetch(:ldap_options).symbolize_keys! do_bind = .fetch(:bind, true) connection(ldap_options: @ldap_options, bind: do_bind) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/wobaduser/ldap.rb', line 6 def errors @errors end |
#ldap_options ⇒ Object (readonly)
Returns the value of attribute ldap_options.
6 7 8 |
# File 'lib/wobaduser/ldap.rb', line 6 def @ldap_options end |
Instance Method Details
#operation_error ⇒ Object
returns last ldap operation error, if any
40 41 42 |
# File 'lib/wobaduser/ldap.rb', line 40 def operation_error (connection.get_operation_result.code == 0) ? nil : connection.get_operation_result end |
#search(options = {}) ⇒ Object
execute ldap search operation
for possible ldap options see Net::LDAP#search
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/wobaduser/ldap.rb', line 25 def search( = {}) reset_errors .symbolize_keys! begin result = connection.search() add_error(operation_error) rescue => e result = [] add_error(e.) end result end |