freireag (owner)

Fork Of

Revisions

  • 6520ac Bruno A... Tue Oct 07 13:47:51 -0700 2008
  • 97b47d dookie Tue Oct 07 13:44:09 -0700 2008
  • ade3d1 dookie Tue Oct 07 13:43:12 -0700 2008
gist: 35396 Download_button fork
public
Public Clone URL: git://gist.github.com/35396.git
Embed All Files: show embed
ldap.yml #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
 
 
user.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
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