[Ruby-activeldap-discuss] Putting the LDAP records into a Hash?

Kouhei Sutou kou at cozmixng.org
Tue Aug 19 22:41:17 EDT 2008


Hi,

2008/8/20 Matt Mencel <MR-Mencel at wiu.edu>:
>
> ----- "Kouhei Sutou" <kou at cozmixng.org> wrote:
>
>> Hi,
>>
>> 2008/8/19 Matt Mencel <MR-Mencel at wiu.edu>:
>>
>> > I'm needing the LDAP query which returns a list of objects....that
>> query is returned to "courses"...I need that to be a Hash with the
>> indexes being the object DNs and the values being arrays of object
>> attributes.
>>
>> Did you try ActiveLdap::Base.find?
>>
>>  courses = Course.find(:all,
>>    :base => 'ou=courses,dc=wiu,dc=edu',
>>    :filter => course_filter,
>>    :scope => :sub,
>>  )
>>  courses.each do |course|
>>    p course.dn
>>    p course.cn
>>    p course.wiu_course_days
>>  end
>>
>
> I have no problems iterating through the list of objects....but I need to be able to reach into the list with the specific DN that I am looking for...
>
>
> find_dn = 'cn=111111,ou=courses,dc=wiu,dc=edu'
> course_I_want = courses.fetch(find_dn) #fetch this indexed item from the Hash
>
>
> So 'courses' has to be a Hash.  So if ActiveLdap won't naturally return a Hash I have to convert what it is returning to a Hash (which I have been able to do).
>
> If I'm doing it wrong let me know, but what I've coded seems to be working.

What about this?

course_you_want = Course.find(find_dn,
    :base => 'ou=courses,dc=wiu,dc=edu',
    :filter => course_filter,
    :scope => :sub,
 )

Do you need a course list too?


Thanks,
--
kou


More information about the Ruby-activeldap-discuss mailing list