Re: Log into a remote computer with differnt login credentials
- From: john smith <john@xxxxxxxxx>
- Date: Fri, 03 Feb 2006 16:01:28 -0400
Doug wrote:
I am VERY new to WMI programming. I was searching the net yesterday for examples of accessing the registry on a remote computer with Windows API calls. I came across something that refered to WMI. I spent most of yesterday and this morning going through the online documentation and writing sample code but have not figured out how to do this yet.
We want to write an application that will pull info off a remote computer. All computes have an administrator login and the password is consistent. However, the application we want to run may not be logged on as the administrator. When a remote WMI connection is made, is it possible to supply user credentials (username and password) other than the current credentials of the logged on user (of the computer running the application)?
Can someone provide me with a brief example of how it is done (assume I want to connect as user administrator and password of help)?
tia
Doug
I'm assuming you're using vbscript
set objLocator = CreateObject("WbemScripting.SWbemLocator")
set objWMIService = objLocator.ConnectServer(strComputer,"root/cimv2",strUser,strPass)
objWMIService.Security_.ImpersonationLevel = 3
set whatever = objWMIService.ExecQuery(...)
where:
strComputer is the computer's name
strUser/strPassword is the credentials to log in (impersonate) on that remote PC
Last line is just like your normal queries, but at this point you're impersonating whatever account's credentials you used (whatever being your normal results, and replace ... for your usual query & params obviously)
Hopefully it helps (I can post .NET code too if you want but since this is a Win32 group I'm assuming otherwise)
.
- Prev by Date: RE: Deleting an object from WMI
- Next by Date: Re: Retrieving mailbox size from Exchang 2003 *slow*
- Previous by thread: RE: WMI to SNMP problems
- Next by thread: Re: Log into a remote computer with differnt login credentials
- Index(es):
Relevant Pages
|