Module: Devise::LdapAdapter

Defined in:
lib/devise_ldap_authenticatable/ldap_adapter.rb

Defined Under Namespace

Classes: LdapConnect

Class Method Summary collapse

Class Method Details

.get_dn(login) ⇒ Object



47
48
49
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 47

def self.get_dn()
  self.ldap_connect().dn
end

.get_groups(login) ⇒ Object



43
44
45
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 43

def self.get_groups()
  self.ldap_connect().user_groups
end

.get_ldap_entry(login) ⇒ Object



65
66
67
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 65

def self.get_ldap_entry()
  self.ldap_connect().
end

.get_ldap_param(login, param) ⇒ Object



60
61
62
63
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 60

def self.get_ldap_param(,param)
  resource = self.ldap_connect()
  resource.ldap_param_value(param)
end

.ldap_connect(login) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 31

def self.ldap_connect()
  options = {:login => ,
             :ldap_auth_username_builder => ::Devise.ldap_auth_username_builder,
             :admin => ::Devise.ldap_use_admin_to_bind}

  resource = LdapConnect.new(options)
end

.set_ldap_param(login, param, new_value, password = nil) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 51

def self.set_ldap_param(, param, new_value, password = nil)
  options = { :login => ,
              :ldap_auth_username_builder => ::Devise.ldap_auth_username_builder,
              :password => password }

  resource = LdapConnect.new(options)
  resource.set_param(param, new_value)
end

.update_own_password(login, new_password, current_password) ⇒ Object



27
28
29
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 27

def self.update_own_password(, new_password, current_password)
  set_ldap_param(, :userpassword, new_password, current_password)
end

.update_password(login, new_password) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 17

def self.update_password(, new_password)
  options = {:login => ,
             :new_password => new_password,
             :ldap_auth_username_builder => ::Devise.ldap_auth_username_builder,
             :admin => ::Devise.ldap_use_admin_to_bind}

  resource = LdapConnect.new(options)
  resource.change_password! if new_password.present?
end

.valid_credentials?(login, password_plaintext) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 7

def self.valid_credentials?(, password_plaintext)
  options = {:login => ,
             :password => password_plaintext,
             :ldap_auth_username_builder => ::Devise.ldap_auth_username_builder,
             :admin => ::Devise.ldap_use_admin_to_bind}

  resource = LdapConnect.new(options)
  resource.authorized?
end

.valid_login?(login) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/devise_ldap_authenticatable/ldap_adapter.rb', line 39

def self.valid_login?()
  self.ldap_connect().valid_login?
end