ConnectServer failure - please help

ConnectServer failure - please help

Post by Graeme Frase » Fri, 16 May 2003 21:12:03



Hello all,
PLease help.  The following code is sample is from www.wbem.co.uk and works
fine for connecting to the local machine.

Start code chunk---------

CoInitializeEx(NULL, COINIT_MULTITHREADED);
HRESULT hr = S_OK;

CComPtr<IWbemLocator> spLoc;
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator,
(LPVOID *) &spLoc);

CComBSTR bstrNamespace(_T("\\\\.\\root\\CIMV2"));
CComPtr<IWbemServices> spServices;

// Connect to CIM
hr = spLoc->ConnectServer(bstrNamespace, NULL, NULL, 0, NULL, 0, 0,
&spServices);

End code chunk -------------

However, when the code is modified to connect to a remote machine it fails.
ConnectServer returns 0x80070005 and causes three exceptions internally.

Start modified code chunk ------------

CoInitializeEx(NULL, COINIT_MULTITHREADED);
HRESULT hr = S_OK;

CComPtr<IWbemLocator> spLoc;
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER, IID_IWbemLocator,
(LPVOID *) &spLoc);

CComBSTR bstrNamespace(_T("\\\\10.0.0.123\\root\\CIMV2"));
CComBSTR bstrUsername(_T("myadminuser"));
CComBSTR bstrPassword(_T("myadminpass"));
CComPtr<IWbemServices> spServices;

// Connect to CIM
hr = spLoc->ConnectServer(bstrNamespace, bstrUsername, bstrPassword, 0,
NULL, 0, 0, &spServices);

End modified code chunk ------------

Any ideas anyone? the  10.0.0.123 doesn't matter.  I've tried stacks of xp
and 2k boxes, and each has an aministrator user with the correct name and
password.  There are no firewalls and all machines have the WMI services
running.

Thanks in advance,
Graeme

 
 
 

ConnectServer failure - please help

Post by [MS] Tim Che » Sun, 18 May 2003 09:11:20


Try    CoInitializeSecurity( NULL, -1, NULL,
NULL,RPC_C_AUTHN_LEVEL_DEFAULT,RPC_C_IMP_LEVEL_IMPERSONATE,NULL, EOAC_NONE,
0);
before CoCreateInstance

This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Quote:> Hello all,
> PLease help.  The following code is sample is from www.wbem.co.uk and
works
> fine for connecting to the local machine.

> Start code chunk---------

> CoInitializeEx(NULL, COINIT_MULTITHREADED);
> HRESULT hr = S_OK;

> CComPtr<IWbemLocator> spLoc;
> hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER,
IID_IWbemLocator,
> (LPVOID *) &spLoc);

> CComBSTR bstrNamespace(_T("\\\\.\\root\\CIMV2"));
> CComPtr<IWbemServices> spServices;

> // Connect to CIM
> hr = spLoc->ConnectServer(bstrNamespace, NULL, NULL, 0, NULL, 0, 0,
> &spServices);

> End code chunk -------------

> However, when the code is modified to connect to a remote machine it
fails.
> ConnectServer returns 0x80070005 and causes three exceptions internally.

> Start modified code chunk ------------

> CoInitializeEx(NULL, COINIT_MULTITHREADED);
> HRESULT hr = S_OK;

> CComPtr<IWbemLocator> spLoc;
> hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_SERVER,
IID_IWbemLocator,
> (LPVOID *) &spLoc);

> CComBSTR bstrNamespace(_T("\\\\10.0.0.123\\root\\CIMV2"));
> CComBSTR bstrUsername(_T("myadminuser"));
> CComBSTR bstrPassword(_T("myadminpass"));
> CComPtr<IWbemServices> spServices;

> // Connect to CIM
> hr = spLoc->ConnectServer(bstrNamespace, bstrUsername, bstrPassword, 0,
> NULL, 0, 0, &spServices);

> End modified code chunk ------------

> Any ideas anyone? the  10.0.0.123 doesn't matter.  I've tried stacks of xp
> and 2k boxes, and each has an aministrator user with the correct name and
> password.  There are no firewalls and all machines have the WMI services
> running.

> Thanks in advance,
> Graeme


 
 
 

1. Please help!!!!Please help!!!!Please help!!!!

All,
when I try to build my program I get
getinfoDlg.obj : error LNK2001: unresolved external symbol

executing link.exe.
every thing looks finne what should I do?  Please Look at the code below
and let me know if anything is wrong.
{
NET_API_STATUS getinfo;
char buffername[30];
LPTSTR username, logon_domain, oth_domains, logon_server;
LPBYTE bufptr;
DWORD prefmaxlen; short one1 = 1;
LPDWORD entriesread, totalentries, resumehandle;
WKSTA_USER_INFO_1 userinfo;

GetDlgItemText(IDC_COMPUTERNAME,m_computer);
strcpy(buffername,m_computer);
m_computer.MakeUpper();

getinfo = NetWkstaUserEnum(buffername, one1, &bufptr, prefmaxlen,

entriesread,totalentries, esumehandle);

username = userinfo.wkui1_username;
logon_domain = userinfo.wkui1_logon_domain;
oth_domains = userinfo.wkui1_oth_domains;
logon_server = userinfo.wkui1_logon_server;

Please help!!!!


2. Audit.rul

3. interactive media mode failure! help please

4. 9 million signals

5. Segment load failure? (Please help)

6. infor

7. Please Help me !!! Please Please Please!!!!!!!!!!!!!!!

8. Looking for NN Character Recognition Resources

9. WBEM_E_ACCESS_DENIED - al pIWbemLocator->ConnectServer call - pls help

10. HELP NEEDED PLEASE PLEASE PLEASE!!!!

11. HELP, HELP Automation Failure

12. HELP with DIBs please : PLEASE

13. please please help me out