Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WMI in VC++, Access Denied

WMI in VC++, Access Denied

Scheduled Pinned Locked Moved C / C++ / MFC
securityhelpc++databasesysadmin
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tobeymag
    wrote on last edited by
    #1

    Hi all, I am trying to use WMI (just learning) in VC++. However, there seems to be a problem when it comes to connecting to a Remote Host . Which works very well on the local computer. The machine I am trying to connect has Win2K on it and I have WinXP installed on my machine. Now, when I try to execute the following code snippet, it gives me an Access Denied error. Also when I try to query the same through WBEMTEST.exe, everything work fine. Here is the code snippet : - // Initialize Security hrRetVal = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0); // CreateInstance hrRetVal = CoCreateInstance(CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IWbemLocator, (void **) &pWbemLocator); BSTR bsNameSpace = SysAllocString(L"//RemoteComputer/root/cimv2"); BSTR bsUserName = SysAllocString(L"abc"); BSTR bsPassword = SysAllocString(L"123"); // Connect to the Server hrRetVal = pWbemLocator->ConnectServer(bsNameSpace, bsUserName, bsPassword, 0, NULL, NULL, 0, &pWbemServices); // Query the Proxy Blanket for Authorization Level hrRetVal = CoQueryProxyBlanket(pWbemServices, NULL, NULL, NULL, &dwAuthLevel, NULL, NULL, NULL); // Set the Proxy Blanket to the Authorization Level hrRetVal = CoSetProxyBlanket(pWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NAME, NULL, dwAuthLevel, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE); // Execute Query --> Access Denied hrRetVal = pWbemServices->ExecQuery(L"WQL", L"Select * from Win32_Service",

    T 1 Reply Last reply
    0
    • T tobeymag

      Hi all, I am trying to use WMI (just learning) in VC++. However, there seems to be a problem when it comes to connecting to a Remote Host . Which works very well on the local computer. The machine I am trying to connect has Win2K on it and I have WinXP installed on my machine. Now, when I try to execute the following code snippet, it gives me an Access Denied error. Also when I try to query the same through WBEMTEST.exe, everything work fine. Here is the code snippet : - // Initialize Security hrRetVal = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0); // CreateInstance hrRetVal = CoCreateInstance(CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_IWbemLocator, (void **) &pWbemLocator); BSTR bsNameSpace = SysAllocString(L"//RemoteComputer/root/cimv2"); BSTR bsUserName = SysAllocString(L"abc"); BSTR bsPassword = SysAllocString(L"123"); // Connect to the Server hrRetVal = pWbemLocator->ConnectServer(bsNameSpace, bsUserName, bsPassword, 0, NULL, NULL, 0, &pWbemServices); // Query the Proxy Blanket for Authorization Level hrRetVal = CoQueryProxyBlanket(pWbemServices, NULL, NULL, NULL, &dwAuthLevel, NULL, NULL, NULL); // Set the Proxy Blanket to the Authorization Level hrRetVal = CoSetProxyBlanket(pWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NAME, NULL, dwAuthLevel, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE); // Execute Query --> Access Denied hrRetVal = pWbemServices->ExecQuery(L"WQL", L"Select * from Win32_Service",

      T Offline
      T Offline
      tobeymag
      wrote on last edited by
      #2

      Hello, Isn't there anyone who could help me. Thanks -TobeyMag

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups