google-code-export / ruby-activeldap

Automatically exported from code.google.com/p/ruby-activeldap
Other
1 stars 1 forks source link

Problem loading the gem with latest ruby versions #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

I have this class:

  class LdapUser < ActiveLdap::Base
    SAVE_ENVIROMENTS = %w(development test selenium staging)

    ldap_mapping :dn_attribute => 'cn', :prefix => 'ou=Users', :scope => :one

    def self.authenticate(username, password)
      user = self.find(:first, :attribute => 'uid', :value => username)
unless username.blank?
      return user.nil? ? false : ActiveLdap::UserPassword.valid?(password,
user[:userPassword])
    rescue ActiveLdap::ConnectionNotEstablished, ActiveLdap::ConnectionError
      return SAFE_ENVIROMENTS.include?(RAILS_ENV) ? true : false
    end
  end # LdapUser

What is the expected output? What do you see instead?

It just raise a MissingSourceFile exception:

no such file to load: ldap

See attached exception.txt file

What version of the product are you using? On what operating system?

activeldap versions 1.0.1, 1.0.2

* ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
* Debian GNU/Linux lenny/sid

* ruby 1.8.6 (2008-08-08 patchlevel 286) [x86_64-linux]
* Debian GNU/Linux etch

tested with rails versions: 2.x

Please provide any additional information below.

It works fine with old ruby:

* ruby 1.8.5 (2006-08-25) [x86_64-linux]

Original issue reported on code.google.com by jca...@gmail.com on 16 Nov 2008 at 10:50

Attachments:

GoogleCodeExporter commented 9 years ago
Just a rewrite of the class here to avoid word wrapping and make it more clear

class LdapUser < ActiveLdap::Base
    SAVE_ENVIROMENTS = %w(development test selenium staging)

    ldap_mapping :dn_attribute => 'cn', :prefix => 'ou=Users', :scope => :one

    def self.authenticate(username, password)
      unless username.blank?
        user = self.find(:first, :attribute => 'uid', :value => username)
      end
      return user.nil? ? false : ActiveLdap::UserPassword.valid?(password,
                                                       user[:userPassword])
    rescue ActiveLdap::ConnectionNotEstablished, ActiveLdap::ConnectionError
      return SAFE_ENVIROMENTS.include?(RAILS_ENV) ? true : false
    end
  end # LdapUser

Original comment by jca...@gmail.com on 16 Nov 2008 at 10:52

GoogleCodeExporter commented 9 years ago
sorry, typo: Where it says SA(V|F)E_ENVIROMENTS should say: SAFE_ENVIRONMENTS, 
in the
code it is correctly typed

Original comment by jca...@gmail.com on 16 Nov 2008 at 10:59

GoogleCodeExporter commented 9 years ago
Did you install libldap-ruby1.8?

Original comment by kou...@gmail.com on 16 Nov 2008 at 11:12

GoogleCodeExporter commented 9 years ago
Thanks! that solve the problem.

Original comment by jca...@gmail.com on 24 Nov 2008 at 1:40

GoogleCodeExporter commented 9 years ago

Original comment by kou...@gmail.com on 24 Nov 2008 at 1:51