Bind_as_user_LDAP.diff

Bind as user for head (r3686) - Markus Peter, 2010-04-21 00:44

Download (1.11 KB)

View differences:

auth_source_ldap.rb (copie de travail)
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 = {}