以另一个用户身份运行 pywin32 COM 对象

Ste*_*enG 6 python com pywin32

我有一个使用 COM 对象的 Python 程序,我想远程运行它。该程序在本地计算机上运行良好,但是当我在远程计算机上运行该程序并尝试使用 DCOM 对象远程连接到远程计算机上的 COM 对象时,NTLM 身份验证失败(在 Wireshark 捕获中看到)。

该计算机位于 Windows 域中,但我可以在两台计算机上创建任意数量的本地用户。我尝试在两台计算机上创建相同的本地用户,但 DCOM 对象将计算机作为域传递(即尝试使用 进行身份验证Machine2Machine1\user

有什么建议吗?

有没有办法指定pythoncomwin32com指定用于 NTLM 身份验证的不同用户和密码?

我非常愿意回答任何问题并添加尽可能多的细节。

代码:

print "\nConnecting to '%s'" % LAHostNameOrIP ;
try:
    LAConnect = win32com.client.Dispatch("AgtLA.Connect")
    # Fails on the LAConnect.GetInstrument call
    LAInst = LAConnect.GetInstrument(LAHostNameOrIP)
except pythoncom.com_error, (hr, msg, exc, arg):
    print "The AgtLA call failed with code: %d: %s" % (hr, msg)
    if exc is None:
        print "There is no extended error information"
    else:
        wcode, source, text, helpFile, helpId, scode = exc
        print "The source of the error is", source
        print "The error message is", text
        print "More info can be found in %s (id=%d)" % (helpFile, helpId)
    sys.exit(1)
Run Code Online (Sandbox Code Playgroud)