Forum: Ruby Active Directory and Ruby

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A99d18bdbe7936f65e51e9602e2e2115?d=identicon&s=25 Bruno Sousa (brgsousa)
on 2008-11-18 14:28
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
D68c97e8e2f1653b54c24493caf236ae?d=identicon&s=25 Stephen Celis (Guest)
on 2008-11-18 14:40
(Received via mailing list)
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
A99d18bdbe7936f65e51e9602e2e2115?d=identicon&s=25 Bruno Sousa (brgsousa)
on 2008-11-18 15:24
Stephen Celis wrote:
> 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

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
A99d18bdbe7936f65e51e9602e2e2115?d=identicon&s=25 Bruno Sousa (brgsousa)
on 2008-11-18 15:36
ruby --version
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
76d5176f2419e5984d7680d1951c0b5e?d=identicon&s=25 Aldric Giacomoni (Guest)
on 2008-11-18 17:10
(Received via mailing list)
Bruno Sousa wrote:
> Stephen Celis wrote:
>> 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.

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
31ab75f7ddda241830659630746cdd3a?d=identicon&s=25 Austin Ziegler (austin)
on 2008-11-19 04:05
(Received via mailing list)
On Tue, Nov 18, 2008 at 9:20 AM, Bruno Sousa <brgsousa@gmail.com> 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
A99d18bdbe7936f65e51e9602e2e2115?d=identicon&s=25 Bruno Sousa (brgsousa)
on 2008-11-19 19:08
Aldric Giacomoni wrote:
> Bruno Sousa wrote:
>> Stephen Celis wrote:
>>> 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.
>
> 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
This topic is locked and can not be replied to.