Sha256: 811a315b404b0a9cebfd1167fda6792ab4b10555cbb8a519be63baadf014d5d1

Contents?: true

Size: 1.34 KB

Versions: 17

Compression:

Stored size: 1.34 KB

Contents

module Castronaut
  module Adapters
    module Ldap
      
      class User 
        begin
          require "net/ldap"
        rescue LoadError
          begin
            gem 'ruby-net-ldap', '~> 0.0.4'
          rescue Gem::LoadError
            $stderr.puts "How can you have any pudding if you don\'t install ruby-net-ldap?"
            exit(0)
          end
        end
        
        def self.authenticate(username, password)
          return false if password.blank?
          
          connection = Net::LDAP.new
          connection.host = Castronaut.config.cas_adapter['host']
          connection.port = Castronaut.config.cas_adapter['port']
          
          prefix = Castronaut.config.cas_adapter['prefix']
          base = Castronaut.config.cas_adapter['base']
          
          connection.authenticate("#{prefix}#{username}, #{base}", password)
          if connection.bind
            return Castronaut::AuthenticationResult.new(username, nil)            
          else
            Castronaut.config.logger.info "#{self} - Unable to authenticate username #{username} because #{connection.get_operation_result.message} : code #{connection.get_operation_result.code}"
            return Castronaut::AuthenticationResult.new(username, "Unable to authenticate the username #{username}")
          end
        end

      end
    
    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
3mix-castronaut-0.5.0.2 lib/castronaut/adapters/ldap/user.rb
masover-castronaut-0.4.4.4 lib/castronaut/adapters/ldap/user.rb
masover-castronaut-0.4.4.5 lib/castronaut/adapters/ldap/user.rb
masover-castronaut-0.5.0.1 lib/castronaut/adapters/ldap/user.rb
p8-castronaut-0.6.1.1 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.4.2 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.4.3 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.4.4 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.4.5 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.4.6 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.5.0 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.5.1 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.5.2 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.5.3 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.5.4 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.6.0 lib/castronaut/adapters/ldap/user.rb
relevance-castronaut-0.6.1 lib/castronaut/adapters/ldap/user.rb