Project

General

Profile

Feature #1913 » 1913_redmine_bind_as_user2.diff

"bind as user, only once" feature for 1.0.1 - Antoine Beaupré, 2010-12-13 16:55

View differences:

app/models/auth_source_ldap.rb 2010-12-13 10:57:06.000000000 -0500
33 33
  
34 34
  def authenticate(login, password)
35 35
    return nil if login.blank? || password.blank?
36
    attrs = get_user_dn(login)
36
    attrs = get_user_dn(login, password)
37 37
    
38 38
    if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
39 39
      logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
......
100 100
  end
101 101

  
102 102
  # Get the user's dn and any attributes for them, given their login
103
  def get_user_dn(login)
104
    ldap_con = initialize_ldap_con(self.account, self.account_password)
103
  def get_user_dn(login, password)
104
    if self.account.include? "$login" then
105
      ldap_con = initialize_ldap_con(self.account.sub("$login", login), password)
106
    else
107
      ldap_con = initialize_ldap_con(self.account, self.account_password)
108
    end
105 109
    login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) 
106 110
    object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) 
107 111
    attrs = {}
(6-6/6)