Active Directory and Ruby

Hi everyone,
I want retrieve a list of all users from a Active Directory. How can I
do that?

I'm running this script on the AD Server.

Regards

···

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

Hi,

···

On Nov 18, 2008, at 7:24 AM, Bruno Sousa wrote:

Hi everyone,
I want retrieve a list of all users from a Active Directory. How can I
do that?

I'm running this script on the AD Server.

http://activedirectory.rubyforge.org/ seems to be a good resource. Googled: active directory ruby.

Stephen

Stephen Celis wrote:

Hi,

Hi everyone,
I want retrieve a list of all users from a Active Directory. How can I
do that?

I'm running this script on the AD Server.

http://activedirectory.rubyforge.org/ seems to be a good resource.
Googled: active directory ruby.

Stephen

I've tried that:
gem install activedirectory
irb
irb(main):001:0> gem 'activedirectory'
=> true
irb(main):002:0> ActiveDirectory::Base.server_settings = {
    :host => "server.example.com",
    :username => "username",
    :password => "password",
    :domain => "example.com",
    :base_dn => "DC=example,DC=com"
  }

NameError: uninitialized constant ActiveDirectory
  from (irb):2
  from :0

I don't know what is happenning

···

On Nov 18, 2008, at 7:24 AM, Bruno Sousa wrote:

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

ruby --version
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]

···

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

Bruno Sousa wrote:

Stephen Celis wrote:

Hi,

Hi everyone,
I want retrieve a list of all users from a Active Directory. How can I
do that?

I'm running this script on the AD Server.

net-ldap worked very well for me.

require 'rubygems' # just in case
require 'net/ldap' # http://rubyfurnace.com/docs/ruby-net-ldap-0.0.4/
require 'pp'

ldap = Net::LDAP.new :host => "server.example.com",
  :port => 389,
  :auth => { :method => :simple,
    :username => "username",
    :password => "password" }
treebase = "dc=example,dc=dom"
filter = Net::LDAP::Filter.eq("objectCategory", "user")
ldap.search ( :base => treebase, :filter => filter) do |entry|
  pp entry
end

puts ldap.get_operation_result

···

On Nov 18, 2008, at 7:24 AM, Bruno Sousa wrote:

I've tried that:
gem install activedirectory
irb
irb(main):001:0> gem 'activedirectory'
=> true

You forgot to require 'activedirectory'.

Gem simply forces the gem's load path into the current $LOAD_PATH.

-austin

···

On Tue, Nov 18, 2008 at 9:20 AM, Bruno Sousa <brgsousa@gmail.com> wrote:

irb(main):002:0> ActiveDirectory::Base.server_settings = {
   :host => "server.example.com",
   :username => "username",
   :password => "password",
   :domain => "example.com",
   :base_dn => "DC=example,DC=com"
}

NameError: uninitialized constant ActiveDirectory
from (irb):2
from :0

I don't know what is happenning
--
Posted via http://www.ruby-forum.com/\.

--
Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/
               * austin@halostatue.ca * You are in a maze of twisty little passages, all alike. // halo • statue
               * austin@zieglers.ca

Aldric Giacomoni wrote:

Bruno Sousa wrote:

Stephen Celis wrote:

Hi,

Hi everyone,
I want retrieve a list of all users from a Active Directory. How can I
do that?

I'm running this script on the AD Server.

net-ldap worked very well for me.

require 'rubygems' # just in case
require 'net/ldap' # http://rubyfurnace.com/docs/ruby-net-ldap-0.0.4/
require 'pp'

ldap = Net::LDAP.new :host => "server.example.com",
  :port => 389,
  :auth => { :method => :simple,
    :username => "username",
    :password => "password" }
treebase = "dc=example,dc=dom"
filter = Net::LDAP::Filter.eq("objectCategory", "user")
ldap.search ( :base => treebase, :filter => filter) do |entry|
  pp entry
end

puts ldap.get_operation_result

Thanks a lot, that was perfect.
ActiveDirectory gem was buggy, while ldap library works perfectly

···

On Nov 18, 2008, at 7:24 AM, Bruno Sousa wrote:

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