Re: Log into a remote computer with differnt login credentials

Tech-Archive recommends: Fix windows errors by optimizing your registry



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)
.



Relevant Pages

  • Some 80041001 Generic Failure accessing remote WMI
    ... "win32_BaseService" class remotely using WMI. ... We need to retrieve some WMI information from a remote computer running ... Windows 2003 SP1 without using an Administrator user. ...
    (microsoft.public.win32.programmer.wmi)
  • Re: create user accounts with wmi.
    ... If you are able to bind to the computer with the credentials, ... credentials have Administrative privileges on the computer, ... ' Specify credentials on the remote computer. ... ' Bind to remote computer. ...
    (microsoft.public.scripting.vbscript)
  • Re: WNetAddConnection3 question
    ... I map the C drive of a remote computer using the WNetAddConnection3. ... And now I have some question about the credentials. ... If I set the flag but does not check the ...
    (microsoft.public.win32.programmer.networks)
  • WNetAddConnection3 question
    ... I map the C drive of a remote computer using the WNetAddConnection3. ... And now I have some question about the credentials. ... If I set the flag but does not check the ...
    (microsoft.public.win32.programmer.networks)
  • Re: Connection with differents credentials
    ... I don't know but I read that if you use the IP address of the remote computer instead ... of the name you may be able to connect with a different set of credentials. ... > Windows computer with differents credentials ... > By default Windows authorize only one credential between ...
    (microsoft.public.win2000.security)