Active Directory and Ruby


#1

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


#2

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


#3

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


#4

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


#5

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


#6

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


#7

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