Forum: Ruby Searching Active Directory

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.
1323a886cb27e5cb9d07cf0ec7a73850?d=identicon&s=25 Robert Boone (Guest)
on 2006-03-27 18:36
Hello,
   I have been trying to research this myself but I haven't come up with
much. I'm mostly a linux guy so I don't know much about the inner
workings of AD. This is what I'm trying to do, I need to search through
each OU for users then find the value of one of those users attributes.
I've looked at the docs for WIN32OLE and I just don't see how to use it.
I've googled and I've seen some perl examples but the method getObject
in the ruby docs.  I would use perl but those docs aren't complete
either. I could really use some help on this.

Thanks,

Robert Boone
0b561a629b87f0bbf71b45ee5a48febb?d=identicon&s=25 Dave Burt (Guest)
on 2006-03-28 09:59
(Received via mailing list)
Robert Boone wrote:
>   I have been trying to research this myself but I haven't come up with
> much. I'm mostly a linux guy so I don't know much about the inner
> workings of AD. This is what I'm trying to do, I need to search through
> each OU for users then find the value of one of those users attributes.
> I've looked at the docs for WIN32OLE and I just don't see how to use it.
> I've googled and I've seen some perl examples but the method getObject
> in the ruby docs.  I would use perl but those docs aren't complete
> either. I could really use some help on this.

Hi Robert,

This VBScript:

Set x = CreateObject("Foo.Bar")
Set y = GetObject("Foo.Bar")

Translates to this Ruby code:

require 'win32ole'
x = WIN32OLE.new("Foo.Bar")
y = WIN32OLE.connect("Foo.Bar")

Now, Active Directory...

# connect to ADSI
domain = WIN32OLE.connect("WinNT://domain_name_goes_here")
users = []
# collect User instances out of objects in the domain
domain.each {|obj| users << obj if obj.Class == "User" }
# print the FullName attribute of all users whose Name (which should be
unique)
# is "dburt"
puts users.select {|u| u.Name == "dburt" }.map! {|u| u.FullName }

I hope that helps.

Cheers,
Dave
This topic is locked and can not be replied to.