Active_Ldap Base Config Question

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?

Thanks

jack

···

--
Posted via http://www.ruby-forum.com/.

Haven't used that particular gem (I use ActiveDirectory myself) but it looks
like just a namespace issue. You haven't included the namespace therefore
you would require the full object path e.g. ActiveLdap::Group.find(:all,
"*")

···

On Thu, Nov 12, 2009 at 5:39 AM, jackster the jackle <johnsheahan@att.net>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?

Thanks

jack
--
Posted via http://www.ruby-forum.com/\.

Hi,

In <f17e4a070c8efbdc879559a9eb7ea0ef@ruby-forum.com>
  "Active_Ldap Base Config Question" on Thu, 12 Nov 2009 03:39:28 +0900,

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 Google Code Archive - Long-term storage for Google Code Project Hosting.

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,

···

jackster the jackle <johnsheahan@att.net> wrote:
--
kou

Putting in the full object path renders the same error message, I'm
afraid.

To be honest, I don't have a preference toward Active_Ldap, I just
thought that it was the most common way to do AD lookups but if
ActiveDirectory works for you, can you please give me a link to the
binary (unleass it's a gem?) and perhaps a sample of a base config?

thanks

jack

···

--
Posted via http://www.ruby-forum.com/.

Ah, my bad. For every complex problem there is a solution that is clear,
simple and wrong :slight_smile:

The ActiveDirectory lib works for me but hasn't been updated in a while. It
can be found at:

http://code.google.com/p/ruby-activedirectory/

Setup is fairly much the same:

ActiveDirectory::Base.server_settings = {
    :host => "hostname or ip address",
    :port => 3268,
    :username => "username",
    :password => "password",
    :domain => "your.ad.domain.here",
    :base_dn => "DC=your,DC=base,DC=dn"
}

But I get the feeling that you might have the same issue. I seem to remember
that this was a rails+gem version problem since I had this this same issue
with the activedirectory gem once upon a time. What version of rails are you
using? Did you upgrade it recently?

···

On Thu, Nov 12, 2009 at 7:21 AM, jackster the jackle <johnsheahan@att.net>wrote:

Putting in the full object path renders the same error message, I'm
afraid.

To be honest, I don't have a preference toward Active_Ldap, I just
thought that it was the most common way to do AD lookups but if
ActiveDirectory works for you, can you please give me a link to the
binary (unleass it's a gem?) and perhaps a sample of a base config?

thanks

jack
--
Posted via http://www.ruby-forum.com/\.

Sorry I just assumed: are you running rails? That's what I was using it with
so I just made the assumption. Better question: What version of ruby and gem
are you running?

···

On Thu, Nov 12, 2009 at 8:37 AM, Sven Schott <sven.schott@gmail.com> wrote:

Ah, my bad. For every complex problem there is a solution that is clear,
simple and wrong :slight_smile:

The ActiveDirectory lib works for me but hasn't been updated in a while. It
can be found at:

http://code.google.com/p/ruby-activedirectory/

Setup is fairly much the same:

ActiveDirectory::Base.server_settings = {
    :host => "hostname or ip address",
    :port => 3268,
    :username => "username",
    :password => "password",
    :domain => "your.ad.domain.here",
    :base_dn => "DC=your,DC=base,DC=dn"
}

But I get the feeling that you might have the same issue. I seem to
remember that this was a rails+gem version problem since I had this this
same issue with the activedirectory gem once upon a time. What version of
rails are you using? Did you upgrade it recently?

On Thu, Nov 12, 2009 at 7:21 AM, jackster the jackle <johnsheahan@att.net>wrote:

Putting in the full object path renders the same error message, I'm
afraid.

To be honest, I don't have a preference toward Active_Ldap, I just
thought that it was the most common way to do AD lookups but if
ActiveDirectory works for you, can you please give me a link to the
binary (unleass it's a gem?) and perhaps a sample of a base config?

thanks

jack
--
Posted via http://www.ruby-forum.com/\.

Sven Schott wrote:

Sorry I just assumed: are you running rails? That's what I was using it
with
so I just made the assumption. Better question: What version of ruby and
gem
are you running?

Yes, I'm running this directly through ruby version 1.8.6.

Gems is version 1.3.5

thanks

···

--
Posted via http://www.ruby-forum.com/\.

I just installed and tried it and got the same thing. I read the docs and
found that you need to subclass Base to get a mapping. e.g.

class User < ActiveLdap::Base
ldap_mapping
end

And the config is different. So here is what I got so far:

require 'active_ldap'

ActiveLdap::Base.setup_connection(
    :host => "hostname",
    :bind_dn => "username",
    :password => "passwords",
    :base => "DC=your,DC=ldap,DC=base"
)

class User < ActiveLdap::Base
ldap_mapping
end

That gets me the connection at least.

···

On Thu, Nov 12, 2009 at 8:44 AM, Sven Schott <sven.schott@gmail.com> wrote:

Sorry I just assumed: are you running rails? That's what I was using it
with so I just made the assumption. Better question: What version of ruby
and gem are you running?

On Thu, Nov 12, 2009 at 8:37 AM, Sven Schott <sven.schott@gmail.com>wrote:

Ah, my bad. For every complex problem there is a solution that is clear,
simple and wrong :slight_smile:

The ActiveDirectory lib works for me but hasn't been updated in a while.
It can be found at:

Google Code Archive - Long-term storage for Google Code Project Hosting.

Setup is fairly much the same:

ActiveDirectory::Base.server_settings = {
    :host => "hostname or ip address",
    :port => 3268,
    :username => "username",
    :password => "password",
    :domain => "your.ad.domain.here",
    :base_dn => "DC=your,DC=base,DC=dn"
}

But I get the feeling that you might have the same issue. I seem to
remember that this was a rails+gem version problem since I had this this
same issue with the activedirectory gem once upon a time. What version of
rails are you using? Did you upgrade it recently?

On Thu, Nov 12, 2009 at 7:21 AM, jackster the jackle <johnsheahan@att.net >> > wrote:

Putting in the full object path renders the same error message, I'm
afraid.

To be honest, I don't have a preference toward Active_Ldap, I just
thought that it was the most common way to do AD lookups but if
ActiveDirectory works for you, can you please give me a link to the
binary (unleass it's a gem?) and perhaps a sample of a base config?

thanks

jack
--
Posted via http://www.ruby-forum.com/\.

unfortunately, that doesn't give me a tcp connection either....but
thanks for the effort

jack

···

--
Posted via http://www.ruby-forum.com/.