Project

General

Profile

Defect #764 ยป ldap.patch

Mark Hymers, 2008-03-01 21:58

View differences:

app/models/auth_source_ldap.rb
30 30
    return nil if login.blank? || password.blank?
31 31
    attrs = []
32 32
    # get user's DN
33
    ldap_con = initialize_ldap_con(self.account, self.account_password)
33
    if (self.account == "") && (self.account_password == nil)
34
      ldap_con = initialize_anon_ldap_con()
35
    else
36
      ldap_con = initialize_ldap_con(self.account, self.account_password)
37
    end
34 38
    login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) 
35 39
    object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) 
36 40
    dn = String.new
......
77 81
    ) 
78 82
  end
79 83
  
84
  def initialize_anon_ldap_con()
85
    Net::LDAP.new( {:host => self.host,
86
                    :port => self.port,
87
                    :encryption => (self.tls ? :simple_tls : nil)}
88
    )
89
  end
90

  
80 91
  def self.get_attr(entry, attr_name)
81 92
    entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name]
82 93
  end
    (1-1/1)