Dave Burt
3/28/2006 8:01:00 AM
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