ajmorris (owner)

Revisions

  • e09e2e ajmorris Mon Nov 17 13:11:36 -0800 2008
gist: 25905 Download_button fork
public
Public Clone URL: git://gist.github.com/25905.git
Embed All Files: show embed
at_ldap.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'rubygems'
require 'net/ldap'
 
module Merb::Authentication::Strategies
  class AtLdap < Merb::Authentication::Strategy
    def run!( login, password )
      initialize_ldap_connection unless @ldap
 
      @ldap.bind_as(
        :base => "cn=#{login},ou=cats,o=gwu",
        :filter => Net::LDAP::Filter.eq( "sn", "*" ),
        :scope => Net::LDAP::SearchScope_BaseObject,
        :password => password
      )
    end
    
    def initialize_ldap_connection
      @ldap = Net::LDAP.new
      @ldap.host = '128.164.60.16'
    end
    
  end
end