Forum: Ruby Two ActiveLDAP questions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F711ae43c5343e3e6be572b38f74864b?d=identicon&s=25 unknown (Guest)
on 2006-02-03 18:55
(Received via mailing list)
Two questions about ActiveLDAP:

------------
Question #1:
When I create an ActiveLDAP::Base object, the dn attribute used in the
mapping does not get an accessor method.  For example:

#!/usr/local/bin/ruby
require 'activeldap'

class Person < ActiveLDAP::Base
  ldap_mapping :dnattr => 'uid', :prefix => 'ou=People'
end

ActiveLDAP::Base.connect(
  :host => 'localhost',
  :port => 40003,
  :base => 'dc=cusys,dc=edu',
  :bind_format => 'uid=admin,dc=cusys,dc=edu',
  :password_block => Proc.new { 'SecretWord' },
  :allow_anonymous => false
)

for person in Person.find_all(:attribute => 'givenName', :value =>
'Puppy', :objects => true) do
  puts "DN: " + person.dn
  puts "CN: " +  person.cn[0]
  puts "UID: " + person.uid[0]
end

##END CODE

There is definitely a uid attribute in the LDAP.  But when I run the
above, I get this:

DN: uid=PBarksalot,ou=People,dc=cusys,dc=edu
CN: Puppy Barksalot
/usr/local/lib/ruby/site_ruby/1.8/activeldap/base.rb:846:in
`method_missing': undefined method `uid' for #<Person:0xb7565dac>
(NoMethodError)
        from ./test.rb:24
        from ./test.rb:21:in `each'
        from ./test.rb:21

When I do a person.inspect, I see a data member called "nil" that
points to the string that should be in "uid":

......@data={"cn"=>["Puppy Barksalot"], nil=>["PBarksalot"],
"sn"=>["Barksalot"], "objectClass"=>["top", "person",
"organizationalPerson", "inetorgperson"]}>

Can anyone help me out?

------------
Question #2:

I'm trying to use ActiveLDAP in Rails, just like the above but with the
relevant code snippets distributed to config, models, views and so on.
I can get my application to query the LDAP successfully; a
person.inspect shows all the attributes' values are returned.  However,
none of the accessor methods are created.  The collection that should
hold them, @attr_methods, is empty.

Has anyone seen/solved this?

Thanks.

Justin
This topic is locked and can not be replied to.