English 中文(简体)
A. 远程机器在运行时的连接
原标题:Connect to WMI of remote machine when running as a service
  • 时间:2012-05-16 14:20:34
  •  标签:
  • c++
  • wmi

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的样本代码为基础:

问题回答

WMI kind of strips some security rights; you need to either set up your account as "Trusted for delegation", which is extremely powerful and not recommended, or sign your code. Alternatively you can pass explicit permissions to the process.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签