Searching Active Directory

R

Robert Boone

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
 
D

Dave Burt

Robert said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,204
Messages
2,571,062
Members
47,669
Latest member
johnmaxwell

Latest Threads

Top