Skip to content

Instantly share code, notes, and snippets.

@azisaka
Created October 7, 2008 20:43
Show Gist options
  • Save azisaka/15381 to your computer and use it in GitHub Desktop.
Save azisaka/15381 to your computer and use it in GitHub Desktop.
development:
host: 192.168.0.1
port: 389
base: dc=gaiz,dc=com,dc=br
bind_dn: cn=admin,dc=gaiz,dc=com,dc=br
password: gaiz
test:
host: 127.0.0.1
port: 389
base: dc=test,dc=local,dc=net
bind_dn: cn=admin,dc=local,dc=net
password: secret
production:
host: 127.0.0.1
port: 389
method: :tls
base: dc=production,dc=local,dc=net
bind_dn: cn=admin,dc=local,dc=net
password: secret
class User < ActiveLdap::Base
ldap_mapping :dn_attribute =>"uid"
def self.authenticate(login, password)
return nil if login.blank? || password.blank?
u = find(:all, login).first # need to get the salt
u && u.authenticated?(password) ? u : nil
end
def authenticated?(password)
self.userPassword == password and Group.tecnology.include? self.uid
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment