From: Kouhei Sutou Date: 2009-11-12T23:46:27+09:00 Subject: Re: Active_Ldap Base Config Question Hi, In "Active_Ldap Base Config Question" on Thu, 12 Nov 2009 03:39:28 +0900, jackster the jackle wrote: > I haven't done much with polling AD in the past but I am now trying to > write a basic script using active_ldap that pulls a list of users from > AD. The following code I have here doesn't work but the thing that > bothers me the most is that when I use a sniffer on the AD server, I > don't see any attempt by the script to communicate with the server. > > require 'rubygems' > require 'active_ldap' > > ActiveLdap::Base.setup_connection( > :host => "10.1.1.1", > :user => "admin", > :password => "password", > :base => "dc=voice,dc=company,dc=com" > ) > all_users = Group.find(:all, '*') > puts all_users > > > The actual error I get is: > > /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:443:in > `load_missing_constant': uninitialized constant Group (NameError) > > Any ideas as to why this basic config isn't working? You need to define your Group class: class Group < ActiveLdap::Base ldap_mapping :dn_attribute => "cn", :classes => ['posixGroup'] # Inspired by ActiveRecord, this tells ActiveLDAP that the # LDAP entry has a attribute which contains one or more of # some class |:class_name| where the attributes name is # |:local_key|. This means that it will call # :class_name.new(value_of(:local_key)) to create the objects. has_many :members, :class_name => "User", :wrap => "memberUid" has_many :primary_members, :class_name => 'User', :foreign_key => 'gidNumber', :primary_key => 'gidNumber' end # Group # from http://code.google.com/p/ruby-activeldap/source/browse/trunk/examples/objects/group.rb I confused the lines: > all_users = Group.find(:all, '*') > puts all_users Did you want to write like the following? all_groups = Group.all puts all_groups Thanks, -- kou