Class: ESearchy::OtherEngines::Ldap
- Inherits:
-
Object
- Object
- ESearchy::OtherEngines::Ldap
- Defined in:
- lib/esearchy/OtherEngines/ldap.rb
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#base ⇒ Object
Returns the value of attribute base.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#HOST ⇒ Object
Returns the value of attribute HOST.
-
#PORT ⇒ Object
Returns the value of attribute PORT.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#SSLPORT ⇒ Object
Returns the value of attribute SSLPORT.
Instance Method Summary collapse
-
#initialize(host = nil, port = nil, base = nil, scope = nil, filter = nil, attr = nil) ⇒ Ldap
constructor
A new instance of Ldap.
- #search(bind, &block) ⇒ Object
Constructor Details
#initialize(host = nil, port = nil, base = nil, scope = nil, filter = nil, attr = nil) ⇒ Ldap
Returns a new instance of Ldap.
5 6 7 8 9 10 11 12 13 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 5 def initialize(host = nil, port = nil, base = nil, scope = nil, filter = nil, attr = nil) @HOST = host @PORT = port || LDAP::LDAP_PORT @base = base || "dc=localhost,dc=#{host}" @scope = scope || 2 @filter = filter || '(objectclass=person)' @attrs = attr || ['sn', 'cn'] end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
14 15 16 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 14 def attrs @attrs end |
#base ⇒ Object
Returns the value of attribute base.
14 15 16 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 14 def base @base end |
#filter ⇒ Object
Returns the value of attribute filter.
14 15 16 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 14 def filter @filter end |
#HOST ⇒ Object
Returns the value of attribute HOST.
14 15 16 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 14 def HOST @HOST end |
#PORT ⇒ Object
Returns the value of attribute PORT.
14 15 16 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 14 def PORT @PORT end |
#scope ⇒ Object
Returns the value of attribute scope.
14 15 16 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 14 def scope @scope end |
#SSLPORT ⇒ Object
Returns the value of attribute SSLPORT.
14 15 16 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 14 def SSLPORT @SSLPORT end |
Instance Method Details
#search(bind, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/esearchy/OtherEngines/ldap.rb', line 16 def search(bind, &block) connect(bind) begin block.call(self) if block_given? @conn.search(base, scope, filter, attrs, block) rescue LDAP::ResultError @conn.perror("search") end @conn.perror("search") close end |