I am using WMI in VC++. But there is to be a problem when i try to connect to a Remote Host . The machine I am trying to connect has Windows 2000 on it and I have Windows XP installed on my machine. Here is the code - // 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"//impartials/root/cimv2"); BSTR bsUserName = SysAllocString(L"dchauhan"); BSTR bsPassword = SysAllocString(L"rajvada"); // 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 hrRetVal = pWbemServices->ExecQuery(L"WQL", L"Select * from Win32_Service", WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumObject); Over here, i receive an Access Denied error. I am not getting what is the problem. Any help would be appreciated. TobeyMag
tobeymag
Posts
-
Access Denied for Remote Host -
WMI in VC++, Access DeniedHello, Isn't there anyone who could help me. Thanks -TobeyMag
-
WMI in VC++, Access DeniedHi 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",
-
Sockets in DllIt is not working. I've probably tried all the combinations. Now, since it is an extension Dll, I am calling AfxInitExtensionModule and AfxTermExtensionModule from DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH respectively. But still the problem persists. ie the dll does not respond when I try to create the socket. Plz check it out, if you could. Thanks
-
Sockets in DllI am developing an SNMP Agent. I want to use sockets to send/recieve data, for which I need the services of a socket. The code works fine, ie compiles correclty. #include "Connector.h" // The file that defines of the CAsyncSocket derived class Connector Connector Cn; // Entry Point for the DLL BOOL APIENTRY DllMain(...) .. { WSADATA wsaData; long Events = FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE | FD_ACCEPT; WSAStartup(MAKEWORD(1,1),&wsaData); AfxSocketInit(); switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: /* The problem lies here. If I don't use this line then the Agent will send traps correctly. But when I create this socket nothing happens. The Agent does not send traps. It kind of just stops working. Cn.Create(128,SOCK_DGRAM,Events,"127.0.0.1"); break; ... } I dont seem to know what is the problem. Please Reply as soon as possible as I am working on a project. Thanks
-
Use Sockets in a DLLThat problem has been solved. I was not deriving CAsyncSocket class as public(goofed up). But still I have a problem. I want to use the socket in an Extension Dll, that is used by the SNMP Service. Yes, I am developing an SNMP Agent. I want to use sockets to send/recieve data, for which I need the services of a socket. #include "Connector.h" // The file that comprises of the CAsyncSocket derived class Connector Cn; // Entry Point for the DLL BOOL APIENTRY DllMain(...) .. { WSADATA wsaData; long Events = FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE | FD_ACCEPT; WSAStartup(MAKEWORD(1,1),&wsaData); AfxSocketInit(); switch(ul_reason_for_call) { case DLL_PROCESS_ATTACH: /* The problem lies here. If I don't use this line tha Agent will send traps correctly. But when I create this socket nothing happens. The Agent does not send traps *1 Cn.Create(128,SOCK_DGRAM,Events,"127.0.0.1"); break; I dont seem to know what is the problem. Please Reply as soon as possible as I am working on a project. Thanks
-
Use Sockets in a DLLHi, I am writing a DLL in VC++, which needs to send and receive messsages using sockets. Everything goes until I create the Socket using the Object of the CAsyncSocket derived class. The error message it gives me is this : error2248 : Cannot access public member 'Create' of CAsync Socket I've checked the MSDN Error Code. But all I get is that it needs to keep the same state.:sigh: Please reply as soon as possible.