Re: WMI Methods in C++

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



You have to set your impersonation level before you can make calls to WMI. After you call:

hres = ppiWmiLoc->ConnectServer(bstrserv, NULL, NULL, 0, NULL, 0, 0, &pSvc)

You need to call:

hRes = CoSetProxyBlanket(pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);

That should get you fixed up (I hope).

Later,
Chris

luke_21 wrote:
For example for that code, I have no error about the execution of
Method, but I have Error code 1346 as Returned Value from
SetStringValue function.
It says that : Either a required impersonation level was not provided,
or the provided impersonation level is invalid. But can't understand
what that could say ....

.



Relevant Pages

  • RE: WINS MMC Error
    ... Either a required impersonation level was not provided, ... Based on my experience, if the problematic server is a Win2003, you may ... or the provided impersonation level is invalid. ...
    (microsoft.public.windows.server.networking)
  • Re: Getting logged in user from a service?
    ... WMI *will* provide access to the same information by ... specifying "identity" as the impersonation level (which apparently is ... something different than "SecurityIdentification" in the WinAPI - see here ... (wink, wink) ...
    (microsoft.public.dotnet.languages.csharp)
  • LOGON32_LOGON_NETWORK_CLEARTEXT, ImpersonateLoggedOnUser and access HKLM
    ... Outlook"), STANDARD_RIGHTS_READ | KEY_QUERY_VALUE) ... returns "Either a required impersonation level was not provided, ... provided impersonation level is invalid.". ...
    (microsoft.public.platformsdk.security)
  • Re: WMI Methods in C++
    ... WMI. ... but I have Error code 1346 as Returned Value from ... Either a required impersonation level was not provided, ... or the provided impersonation level is invalid. ...
    (microsoft.public.win32.programmer.wmi)
  • Re: WINS MMC Error
    ... Either a required impersonation level was not ... connection, either press F5, or on the Action menu, click Refresh. ... "The WINS server you specified cannot be located. ...
    (microsoft.public.windows.server.networking)