Two ActiveLDAP questions

J

J

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', :eek:bjects => 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top