3

我正在尝试使用 wmi4j 连接远程 Windows Server 2012 机器,但出现“访问被拒绝”错误。但我可以用 WMI Explorer 2016 程序成功连接这台远程机器。

这是代码;

private static String server = "****";
private static String username = "**\\Administrator";
private static String password = "pass";
private static String namespace = "root\\cimv2";

SWbemLocator locator = new SWbemLocator(server,username,password,namespace);
SWbemServices services = locator.connectServer(); //this line throws exception

我还授予所有权限(https://social.technet.microsoft.com/Forums/office/en-US/4f33837b-1cb1-4648-85b1-3ba87cbfe93e/wmi-remote-access-denied?forum=winserverManagement

编辑:堆栈跟踪;

cn.chenlichao.wmi4j.WMIException: Access is denied, please check whether the [domain-username-password] are correct. Also, if not already done please check the GETTING STARTED and FAQ sections in readme.htm. They provide information on how to correctly configure the Windows machine for DCOM access, so as to avoid such exceptions.  [0x00000005]
at cn.chenlichao.wmi4j.SWbemLocator.connectServer(SWbemLocator.java:165)
at cn.chenlichao.wmi4j.SWbemLocator.connectServer(SWbemLocator.java:177)
at com.mycompany.javacombridge.JACOB.main(JACOB.java:60)
4

0 回答 0