File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -49,12 +49,13 @@ def authenticate(login, password)
49
49
end
50
50
return nil if dn . empty?
51
51
logger . debug "DN found for #{ login } : #{ dn } " if logger && logger . debug?
52
- # authenticate user
53
- ldap_con = initialize_ldap_con ( dn , password )
54
- return nil unless ldap_con . bind
55
- # return user's attributes
56
- logger . debug "Authentication successful for '#{ login } '" if logger && logger . debug?
57
- attrs
52
+
53
+ if authenticate_dn ( dn , password )
54
+ logger . debug "Authentication successful for '#{ login } '" if logger && logger . debug?
55
+ return attrs
56
+ else
57
+ return nil
58
+ end
58
59
rescue Net ::LDAP ::LdapError => text
59
60
raise "LdapError: " + text
60
61
end
@@ -96,6 +97,12 @@ def get_user_attributes_from_ldap_entry(entry)
96
97
:auth_source_id => self . id
97
98
]
98
99
end
100
+
101
+ # Check if a DN (user record) authenticates with the password
102
+ def authenticate_dn ( dn , password )
103
+ ldap_con = initialize_ldap_con ( dn , password )
104
+ return ldap_con . bind
105
+ end
99
106
100
107
def self . get_attr ( entry , attr_name )
101
108
if !attr_name . blank?
You can’t perform that action at this time.
0 commit comments