From: J Date: 2006-02-04T02:53:18+09:00 Subject: Two ActiveLDAP questions 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 # (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