Obviously I am missing something and I don’t know what it is…
I am following the instructions at
http://rubyforge.org/docman/view.php/381/114/activeldap_rb.html
and also here…
http://wiki.rubyonrails.org/rails/pages/HowtoAuthenticateViaLdap
my model looks exactly like this…
class LdapUser < ActiveRecord::Base
ldap_mapping :dnattr => ‘uid’, :prefix => ‘People’, :classes =>
[‘top’,‘account’]
#belongs_to :groups, :class_name => ‘Groups’, :foreign_key =>
‘memberUid’, :local_key => ‘uid’
def self.login(username, password)
begin
ActiveLDAP::Base.connect(
:host => “srv1.azapple.com”,
:port => 389,
:base => “dc=azapple,dc=com”,
:bind_format => “uid=#{username},ou=People,dc=azapple,dc=com”,
:password_block => Proc.new { password },
:allow_anonymous => false
)
ActiveLDAP::Base.close
return true
rescue ActiveLDAP::AuthenticationError
return false
end
end
end
which makes sense to me since this works…
$ ldapsearch -x -h srv1.azapple.com -W
-D ‘uid=craig,ou=People,dc=azapple,dc=com’
-b ‘dc=azapple,dc=com’ ‘(uid=craig)’
but the web page gives me this error about the ldap_mapping…
NoMethodError in Login#login
undefined method `ldap_mapping’ for LdapUser:Class
RAILS_ROOT: script/…/config/…
Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:991:in
`method_missing’
and it seems that no matter what I put into the ldap_mapping line in my
model, the error is the same.
Hints?
Craig