Class: LeveretAuth::Ldap::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/leveret_auth/ldap/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Connection

Returns a new instance of Connection.



8
9
10
11
12
13
14
15
# File 'lib/leveret_auth/ldap/connection.rb', line 8

def initialize(configuration)
  @configuration = if configuration.is_a?(Configuration)
                     configuration
                   else
                     Configuration.new(configuration)
                   end
  @connection = Net::LDAP.new(@configuration.connection_config)
end

Instance Method Details

#bind_as(entry_dn, password) ⇒ Object



21
22
23
# File 'lib/leveret_auth/ldap/connection.rb', line 21

def bind_as(entry_dn, password)
  @connection.bind(method: :simple, username: entry_dn, password: password)
end

#search(value) ⇒ Object



17
18
19
# File 'lib/leveret_auth/ldap/connection.rb', line 17

def search(value)
  @connection.search(filter: build_filter(value))
end