ldap.patch

Mark Hymers, 2008-03-01 21:58

Download (1.1 KB)

 
b/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
38 34
    login_filter = Net::LDAP::Filter.eq( self.attr_login, login ) 
39 35
    object_filter = Net::LDAP::Filter.eq( "objectClass", "*" ) 
40 36
    dn = String.new
......
81 77
    ) 
82 78
  end
83 79
  
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

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