Sha256: 771f59a85372e8c0ca147f98d6b9aa4deadf4c27c59a41b38b990fcf3f63b1ed

Contents?: true

Size: 632 Bytes

Versions: 1

Compression:

Stored size: 632 Bytes

Contents

require 'net/ldap'

module Devise

  # simple adapter for ldap credential checking
  # ::Devise.ldap_host
  module LdapAdapter

    def self.valid_credentials?(login, password)
      login = ::Devise.ldap_login_attribute+'='+login+','+::Devise.ldap_base_dn      
      @encryption = ::Devise.ldap_ssl ? :simple_tls : nil
      ldap = Net::LDAP.new(:encryption => @encryption)
      ldap.host = ::Devise.ldap_host
      ldap.port = ::Devise.ldap_port
      ldap.auth login, password
      if ldap.bind
        true
      else
        # errors.add_to_base(ldap.get_operation_result.message)
        false
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
devise_ldap_authenticatable-0.1.3 lib/devise_ldap_authenticatable/ldap_adapter.rb