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.
Bruno S. (Guest)
on 2008-11-18 15: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
Stephen C. (Guest)
on 2008-11-18 15:40
(Received via mailing list)
Hi,

On Nov 18, 2008, at 7:24 AM, Bruno S. 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
Bruno S. (Guest)
on 2008-11-18 16:24
Stephen C. wrote:
> Hi,
>
> On Nov 18, 2008, at 7:24 AM, Bruno S. 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
Bruno S. (Guest)
on 2008-11-18 16:36
ruby --version
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
Aldric G. (Guest)
on 2008-11-18 18:10
(Received via mailing list)
Bruno S. wrote:
> Stephen C. wrote:
>> Hi,
>>
>> On Nov 18, 2008, at 7:24 AM, Bruno S. 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
Austin Z. (Guest)
on 2008-11-19 05:05
(Received via mailing list)
On Tue, Nov 18, 2008 at 9:20 AM, Bruno S. <removed_email_address@domain.invalid> 
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
Bruno S. (Guest)
on 2008-11-19 20:08
Aldric G. wrote:
> Bruno S. wrote:
>> Stephen C. wrote:
>>> Hi,
>>>
>>> On Nov 18, 2008, at 7:24 AM, Bruno S. 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.