Sha256: 142426b0afe0d7acc4240593c32fb327e0f1d07e31cd1e0184bb075cba5c0235

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

require 'net/ldap'

module Devise

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

    def self.valid_credentials?(login, attributes, password)
      login = "#{::Devise.ldap_login_attribute}=#{login},"
      login += "#{attributes}," unless attributes.nil?
      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
        false
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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