Using WMI to correctly identify the current user on a remote syste
From: DCC (DCC_at_discussions.microsoft.com)
Date: 10/06/04
- Next message: DCC: "Using WMI to correctly identify the current user on a remote syste"
- Previous message: Primetime: "Updating MIME type in IIS 6.0 via script"
- Next in thread: Torgeir Bakken \(MVP\): "Re: Using WMI to correctly identify the current user on a remote syste"
- Reply: Torgeir Bakken \(MVP\): "Re: Using WMI to correctly identify the current user on a remote syste"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 6 Oct 2004 14:17:02 -0700
I'm working on a status script for deployment in our W2kSP4 and WXPSP1
environment. The script runs on an app server and does the following:
- query active directory for all machines in a particular OU
- iterate through the collection and obtain the required information
- write the information to a SQL database
I'm using WMI to retreive the OS, RAM, uptime and last reboot for each
system without any trouble. However, when I try to determine if a user is
logged into the remote system I receive faulty data (but no errors). Here's
a stand-alone vbs code sample (from MS) that exibits the strange behavior:
-------------------------------------------------------
strComputer = "RemoteComputer"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colComputer
Wscript.Echo objComputer.UserName
Next
------------------------------------------------------
The code is being executed on a system that is part of the domain and in the
context of a user who has local admin rights on all the target systems.
This code returns the proper domain and user information *only* if the user
logged into the remote system is an administrator. If the user is not an
administrator, the code returns "null" (as if no user were logged in).
I've run this against several hundred machines and the behavior is
consistent: any user who has local admin on the system they are using will
be properly identified and logged. Any user who does not have admin is
logged as "null" by the script.
I'd really appreciate any help you could provide. There are several other
methods that could be used to obtain this data, but I'd like to know why this
code isn't working as I would expect.
Thanks!
- Next message: DCC: "Using WMI to correctly identify the current user on a remote syste"
- Previous message: Primetime: "Updating MIME type in IIS 6.0 via script"
- Next in thread: Torgeir Bakken \(MVP\): "Re: Using WMI to correctly identify the current user on a remote syste"
- Reply: Torgeir Bakken \(MVP\): "Re: Using WMI to correctly identify the current user on a remote syste"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|