Closed GoogleCodeExporter closed 9 years ago
Just a rewrite of the class here to avoid word wrapping and make it more clear
class LdapUser < ActiveLdap::Base
SAVE_ENVIROMENTS = %w(development test selenium staging)
ldap_mapping :dn_attribute => 'cn', :prefix => 'ou=Users', :scope => :one
def self.authenticate(username, password)
unless username.blank?
user = self.find(:first, :attribute => 'uid', :value => username)
end
return user.nil? ? false : ActiveLdap::UserPassword.valid?(password,
user[:userPassword])
rescue ActiveLdap::ConnectionNotEstablished, ActiveLdap::ConnectionError
return SAFE_ENVIROMENTS.include?(RAILS_ENV) ? true : false
end
end # LdapUser
Original comment by jca...@gmail.com
on 16 Nov 2008 at 10:52
sorry, typo: Where it says SA(V|F)E_ENVIROMENTS should say: SAFE_ENVIRONMENTS,
in the
code it is correctly typed
Original comment by jca...@gmail.com
on 16 Nov 2008 at 10:59
Did you install libldap-ruby1.8?
Original comment by kou...@gmail.com
on 16 Nov 2008 at 11:12
Thanks! that solve the problem.
Original comment by jca...@gmail.com
on 24 Nov 2008 at 1:40
Original comment by kou...@gmail.com
on 24 Nov 2008 at 1:51
Original issue reported on code.google.com by
jca...@gmail.com
on 16 Nov 2008 at 10:50Attachments: