I am writing some code to do wmi query and method execution on remote machine. My login credential is a domain admin. When I run in application mode, every works fine. When I run as service, it won t work which is expected since the default account service uses isLocal System. When I set the service to run as my credential, the remote wmi is working fine as well.
然而,这并不可取,因此,我试图通过向IWbemLocator提供用户名称和密码,与现役的边远大米连接起来。 链接器。 我能够成功地得到IWbemservices的反对。 然而,当我试图从IWbem Servicess物体中找回这几类物体时,我有错误:
//IWbemServices *pSvc
const bstr_t objectPath("stdRegProv");
const bstr_t methodName("GetStringValue");
IWbemClassObject *pClass = NULL;
HRESULT hr = pSvc->GetObject(objectPath, 0, NULL, &pClass, NULL);
The returned hr is 0x80041003 which is "access is denied" from this link: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394559%28v=vs.85%29.aspx.
一般来说,如果我提供错误的用户名称和密码,我将在IWbemLocator被拒绝进入。 链接器。 因此,我在此感到迷惑不解的是,尽管我无法得到IWbemClass的连接是好的。 反对。 因为如果我利用我的领域作为服务账户来工作,就必须有一些安全差别。 我的WMI联线代码以MSDN的样本代码为基础: