For Programmers: Free Programming Magazines  


Home > Archive > Ruby > August 2005 > win32ole, adsi and computer info









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author win32ole, adsi and computer info
Berger, Daniel

2005-08-30, 7:02 pm

Hi all,

Ruby 1.8.2
Windows XP

I'm trying to get computer hardware information about a specific user on
a specific domain. I can see how to get user info and computer info,
but I don't see how to get computer info based on a userid. I was
messing around with something like this:

adsi =3D WIN32OLE.connect("WinNT://#{domain}")
schema =3D WIN32OLE.connect(adsi.schema)

if schema.container
adsi.filter =3D ["computer"]
adsi.each{ |obj|
p obj.name
}
else
puts "No container"
end

However, I'd rather not iterate over the entire domain.

Plus, I can't tell what methods are available to "obj", i.e. if there's
a way to tie it back to a user and/or get more detailed hardware info.
If I try to call obj.ole_methods, I get "'ole_methods': Failed to
GetTypeInfo (RuntimeError)". I get that for all of the ole_ methods on
'obj'.

Any ideas on how I can get computer info for a specific userid? Or why
obj#ole_methods fails?

Thanks.

Dan



dave.burt@gmail.com

2005-08-30, 9:57 pm

Hi Dan,

Your variable, schema, is an IADsClass representing the class of adsi
(a Domain) - it has methods MandatoryProperties (empty) and
OptionalProperties (useful).

And there's the long way:

You can use obj.Class (or cLaSs or any other case variation from class,
which is a Ruby method) or obj.invoke("class") to find out what adsi's
class is. (i.e. "Computer")

Then you can find the class in the list here:
http://msdn.microsoft.com/library/e...ts_of_winnt.asp

Then you can follow the links to the documentation on each of the
interfaces the class. (For Computer: IADs,
IADsComputer,
IADsComputerOperations,
IADsContainer,
IADsPropertyList)

But that documentation is useful.

User objects are meant to have a LoginWorkstations property and a
SeeAlso; both of these seem not to work for me; I get "The directory
property cannot be found in the cache."

Session objects should be obtainable from a "LanmanServer" or
fso = WIN32OLE.connect("WinNT://computer_name/LanmanServer")
ss = fso.Sessions
That much works, but I can't get anything useful out of ss using each.
The Sessions contained in that collection should have Computer and User
properties. Maybe I don't have sufficient priveleges on the domain to
get this info (I'm only a developer here).

If you get it to work, please let me know.

Cheers,
Dave

x1

2005-08-30, 9:57 pm

Same here... I'm def interested!

On 8/30/05, dave.burt@gmail.com <dave.burt@gmail.com> wrote:
>
> Hi Dan,
>
> Your variable, schema, is an IADsClass representing the class of adsi
> (a Domain) - it has methods MandatoryProperties (empty) and
> OptionalProperties (useful).
>
> And there's the long way:
>
> You can use obj.Class (or cLaSs or any other case variation from class,
> which is a Ruby method) or obj.invoke("class") to find out what adsi's
> class is. (i.e. "Computer")
>
> Then you can find the class in the list here:
>
> http://msdn.microsoft.com/library/e...ts_of_winnt.asp
>
> Then you can follow the links to the documentation on each of the
> interfaces the class. (For Computer: IADs,
> IADsComputer,
> IADsComputerOperations,
> IADsContainer,
> IADsPropertyList)
>
> But that documentation is useful.
>
> User objects are meant to have a LoginWorkstations property and a
> SeeAlso; both of these seem not to work for me; I get "The directory
> property cannot be found in the cache."
>
> Session objects should be obtainable from a "LanmanServer" or
> fso = WIN32OLE.connect("WinNT://computer_name/LanmanServer")
> ss = fso.Sessions
> That much works, but I can't get anything useful out of ss using each.
> The Sessions contained in that collection should have Computer and User
> properties. Maybe I don't have sufficient priveleges on the domain to
> get this info (I'm only a developer here).
>
> If you get it to work, please let me know.
>
> Cheers,
> Dave
>
>
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com