Add more LDAP Debug logs

[ci skip]
pull/4455/head
Oliver Günther 9 years ago
parent b0844578ee
commit ece1de3e64
  1. 4
      app/models/auth_source.rb
  2. 7
      app/models/ldap_auth_source.rb

@ -69,10 +69,10 @@ class AuthSource < ActiveRecord::Base
def self.authenticate(login, password) def self.authenticate(login, password)
AuthSource.where(['onthefly_register=?', true]).each do |source| AuthSource.where(['onthefly_register=?', true]).each do |source|
begin begin
logger.debug "Authenticating '#{login}' against '#{source.name}'" if logger && logger.debug? Rails.logger.debug { "Authenticating '#{login}' against '#{source.name}'" }
attrs = source.authenticate(login, password) attrs = source.authenticate(login, password)
rescue => e rescue => e
logger.error "Error during authentication: #{e.message}" Rails.logger.error "Error during authentication: #{e.message}"
attrs = nil attrs = nil
end end
return attrs if attrs return attrs if attrs

@ -44,7 +44,7 @@ class LdapAuthSource < AuthSource
attrs = get_user_dn(login) attrs = get_user_dn(login)
if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password) if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? Rails.logger.debug { "Authentication successful for '#{login}'" }
return attrs.except(:dn) return attrs.except(:dn)
end end
rescue Net::LDAP::LdapError => error rescue Net::LDAP::LdapError => error
@ -115,6 +115,9 @@ class LdapAuthSource < AuthSource
object_filter = Net::LDAP::Filter.eq('objectClass', '*') object_filter = Net::LDAP::Filter.eq('objectClass', '*')
attrs = {} attrs = {}
Rails.logger.debug {
"LDAP initializing search (BASE=#{base_dn}), (FILTER=#{(object_filter & login_filter).to_s})"
}
ldap_con.search(base: base_dn, ldap_con.search(base: base_dn,
filter: object_filter & login_filter, filter: object_filter & login_filter,
attributes: search_attributes) do |entry| attributes: search_attributes) do |entry|
@ -124,7 +127,7 @@ class LdapAuthSource < AuthSource
attrs = { dn: entry.dn } attrs = { dn: entry.dn }
end end
logger.debug "DN found for #{login}: #{attrs[:dn]}" if logger && logger.debug? Rails.logger.debug { "DN found for #{login}: #{attrs[:dn]}" }
end end
attrs attrs

Loading…
Cancel
Save