连接到不同域上的远程服务器——如何输入用户名和密码? [英] Connecting to a Remote Server on a different domain -- how do I enter the username and password?

查看:60
本文介绍了连接到不同域上的远程服务器——如何输入用户名和密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 vbscript,用于解析远程机器上的信息.

I have a vbscript where I am parsing information on a remote machine.

我有这行代码用于连接strComputer 定义为我们要连接的服务器的名称.

I have this line of code for the connection strComputer is defined to be the name of the server we are connecting to.

Set objWmiService = GetObject("winmgmts:{impersonationLevel=impersonate!\\" & strComputer & "\root\cimv2")

只要我在与远程服务器相同的域上执行脚本,脚本就会运行得很好.我的要求是能够从一个域运行脚本以访问不同域中的远程计算机.

As long as I am executing the script on the SAME domain as the remote server, the script will run just fine. My requirement is to be able to run the script from one domain to access a remote computer on a different domain.

为此,我需要提供用户名和密码.我认为用户名中必须包含域?

To do this, I need to provide a username and password. I think the username must have the domain as part of it?

无论如何,这可能吗?如果是这样,我如何以及在哪里输入用户名和密码?我可以简单地将其添加为参数.

Anyways, Is this possible? If so, how and where do I enter the username and password for this? I can simply add it as an argument.

推荐答案

根据 微软 应该是可能的.但是,您需要针对远程域进行身份验证,例如像这样:

According to Microsoft it should be possible. You need to authenticate against the remote domain, though, e.g. like this:

computer = "..."
username = "OTHERDOMAIN\user"
password = "..."

Set locator = CreateObject("WbemScripting.SWbemLocator")
Set wmi = locator.ConnectServer(computer, "root\cimv2", username, password)
wmi.Security_.ImpersonationLevel = 3

这篇关于连接到不同域上的远程服务器——如何输入用户名和密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆