Project

General

Profile

Patch #30757 » auth_source_ldap.rb.diff

Fix for contextless active directory login, on the fly user creation and new user search - Guilherme Chehab, 2019-02-11 15:04

View differences:

app/models/auth_source_ldap.rb (working copy)
53 53
  def authenticate(login, password)
54 54
    return nil if login.blank? || password.blank?
55 55

  
56
    if self.attr_login.downcase == "samaccountname" 
57
      domain = (self.base_dn.gsub(/dc[ |=|\"]*|[\"| ]*/i,'')).gsub(',','.')
58
      self.account= login + "@" + domain
59
      self.account_password = password
60
    end	  
61

  
56 62
    with_timeout do
57 63
      attrs = get_user_dn(login, password)
58 64
      if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
......
93 99
    q = q.to_s.strip
94 100
    return [] unless searchable? && q.present?
95 101

  
102
    if self.attr_login.downcase == "samaccountname"
103
      domain = (self.base_dn.gsub(/dc[ |=|\"]*|[\"| ]*/i,'')).gsub(',','.')
104
      self.account= self.account + "@" + domain
105
    end
106

  
96 107
    results = []
97 108
    search_filter = base_filter & Net::LDAP::Filter.begins(self.attr_login, q)
98 109
    ldap_con = initialize_ldap_con(self.account, self.account_password)
(2-2/2)