Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

820 lines
22 KiB

  1. //***************************************************************************
  2. //
  3. // ENUM.CPP
  4. //
  5. // Module: WBEM Instance provider
  6. //
  7. // Purpose: Enumerate metabase tree
  8. //
  9. // Copyright (c)1998 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #include "iisprov.h"
  13. ///////////////////////////////////////
  14. //
  15. // CEnum class
  16. //
  17. ///////////////////////////////////////
  18. CEnum::CEnum()
  19. {
  20. m_pInstMgr = NULL;
  21. m_pNamespace = NULL;
  22. m_pAssociation = NULL;
  23. m_pParsedObject = NULL;
  24. m_hKey = NULL;
  25. }
  26. CEnum::~CEnum()
  27. {
  28. if(m_hKey)
  29. m_metabase.CloseKey(m_hKey);
  30. if(m_pInstMgr)
  31. delete m_pInstMgr;
  32. }
  33. void CEnum::Init(
  34. IWbemObjectSink FAR* a_pHandler,
  35. CWbemServices* a_pNamespace,
  36. ParsedObjectPath* a_pParsedObject,
  37. LPWSTR a_pszKey,
  38. WMI_ASSOCIATION* a_pAssociation
  39. )
  40. {
  41. if (!a_pHandler || !a_pNamespace || !a_pParsedObject)
  42. throw WBEM_E_FAILED;
  43. m_pInstMgr = new CWbemInstanceMgr(a_pHandler);
  44. THROW_ON_FALSE(m_pInstMgr);
  45. m_pNamespace = a_pNamespace;
  46. m_pAssociation = a_pAssociation;
  47. m_pParsedObject = a_pParsedObject;
  48. m_hKey = m_metabase.OpenKey(a_pszKey, false); // read only
  49. }
  50. void CEnum::SetObjectPath(
  51. LPCWSTR a_pszPropertyName,
  52. LPCWSTR a_pszObjectPath,
  53. IWbemClassObject* a_pObj
  54. )
  55. {
  56. _bstr_t t_bstr(a_pszPropertyName);
  57. _variant_t t_v(a_pszObjectPath);
  58. HRESULT t_hr = a_pObj->Put(t_bstr, 0, &t_v, 0);
  59. THROW_ON_ERROR(t_hr);
  60. }
  61. void CEnum::PingObject()
  62. {
  63. IWbemClassObject* t_pObj = NULL;
  64. try
  65. {
  66. CUtils obj;
  67. HRESULT hr = obj.GetObjectAsync(m_pNamespace, &t_pObj, m_pParsedObject, m_metabase);
  68. if(SUCCEEDED(hr) && t_pObj)
  69. {
  70. m_pInstMgr->Indicate(t_pObj);
  71. t_pObj->Release();
  72. }
  73. }
  74. catch(...)
  75. {
  76. }
  77. }
  78. void CEnum::PingAssociation(
  79. LPCWSTR a_pszLeftKeyPath
  80. )
  81. {
  82. HRESULT t_hr;
  83. IWbemClassObject* t_pObj = NULL;
  84. IWbemClassObject* t_pClass = NULL;
  85. LPWSTR t_pszObjectPath = NULL;
  86. CObjectPathParser t_PathParser(e_ParserAcceptRelativeNamespace);
  87. WCHAR t_LeftName[20];
  88. WCHAR t_RightName[20];
  89. if(m_pAssociation->at == at_ElementSetting)
  90. {
  91. lstrcpyW(t_LeftName, L"Element");
  92. lstrcpyW(t_RightName, L"Setting");
  93. }
  94. else if(m_pAssociation->at == at_Component)
  95. {
  96. lstrcpyW(t_LeftName, L"GroupComponent");
  97. lstrcpyW(t_RightName, L"PartComponent");
  98. }
  99. else
  100. return;
  101. try
  102. {
  103. t_hr = m_pNamespace->GetObject(
  104. m_pAssociation->pszAssociationName,
  105. 0,
  106. NULL,
  107. &t_pClass,
  108. NULL
  109. );
  110. THROW_ON_ERROR(t_hr);
  111. t_hr = t_pClass->SpawnInstance(0, &t_pObj);
  112. t_pClass->Release();
  113. THROW_ON_ERROR(t_hr);
  114. //
  115. // first right side
  116. //
  117. if (!m_pParsedObject->SetClassName(m_pAssociation->pcRight->pszClassName))
  118. throw WBEM_E_FAILED;
  119. if (t_PathParser.Unparse(m_pParsedObject,&t_pszObjectPath))
  120. throw WBEM_E_FAILED;
  121. SetObjectPath(t_RightName, t_pszObjectPath, t_pObj);
  122. if(t_pszObjectPath)
  123. {
  124. delete [] t_pszObjectPath;
  125. t_pszObjectPath = NULL;
  126. }
  127. //
  128. // then left side
  129. //
  130. if (m_pAssociation->at == at_Component || m_pAssociation->fFlags & ASSOC_EXTRAORDINARY)
  131. {
  132. // clear keyref first
  133. m_pParsedObject->ClearKeys();
  134. // add a keyref
  135. _variant_t t_vt;
  136. if(m_pAssociation->pcLeft->eKeyType == IIsComputer)
  137. t_vt = L"LM"; // IIsComputer.Name = "LM"
  138. else
  139. t_vt = a_pszLeftKeyPath;
  140. THROW_ON_FALSE(m_pParsedObject->AddKeyRef(m_pAssociation->pcLeft->pszKeyName,&t_vt));
  141. }
  142. if (!m_pParsedObject->SetClassName(m_pAssociation->pcLeft->pszClassName))
  143. throw WBEM_E_FAILED;
  144. if (t_PathParser.Unparse(m_pParsedObject,&t_pszObjectPath))
  145. throw WBEM_E_FAILED;
  146. SetObjectPath(t_LeftName, t_pszObjectPath, t_pObj);
  147. if(t_pszObjectPath)
  148. {
  149. delete [] t_pszObjectPath;
  150. t_pszObjectPath = NULL;
  151. }
  152. if(t_pObj)
  153. {
  154. m_pInstMgr->Indicate(t_pObj);
  155. t_pObj->Release();
  156. t_pObj = NULL;
  157. }
  158. }
  159. catch (...)
  160. {
  161. if(t_pszObjectPath)
  162. delete [] t_pszObjectPath;
  163. if(t_pObj)
  164. t_pObj->Release();
  165. }
  166. }
  167. void CEnum::DoPing(
  168. LPCWSTR a_pszKeyName,
  169. LPCWSTR a_pszKeyPath,
  170. LPCWSTR a_pszParentKeyPath
  171. )
  172. {
  173. // add keyref
  174. _variant_t t_v(a_pszKeyPath);
  175. THROW_ON_FALSE(m_pParsedObject->AddKeyRef(a_pszKeyName,&t_v));
  176. // ping
  177. if (!m_pAssociation)
  178. PingObject();
  179. else
  180. PingAssociation(a_pszParentKeyPath);
  181. // clear keyref
  182. m_pParsedObject->ClearKeys();
  183. }
  184. void CEnum::Recurse(
  185. LPCWSTR a_pszMetabasePath,
  186. enum_KEY_TYPE a_eParentKeyType,
  187. LPCWSTR a_pszLeftPath,
  188. LPCWSTR a_pszKeyName,
  189. enum_KEY_TYPE a_eKeyType
  190. )
  191. {
  192. DWORD t_i = 0;
  193. HRESULT t_hr;
  194. WCHAR t_szSubKey[METADATA_MAX_NAME_LEN];
  195. enum_KEY_TYPE t_eSubKeyType;
  196. do
  197. {
  198. t_eSubKeyType = a_eKeyType;
  199. t_hr = m_metabase.EnumKeys(
  200. m_hKey,
  201. a_pszMetabasePath,
  202. t_szSubKey,
  203. &t_i,
  204. t_eSubKeyType
  205. );
  206. t_i++;
  207. if( t_hr == ERROR_SUCCESS)
  208. {
  209. _bstr_t t_bstrMetabasePath;
  210. if(a_pszMetabasePath)
  211. {
  212. t_bstrMetabasePath = a_pszMetabasePath;
  213. t_bstrMetabasePath += L"/";
  214. }
  215. t_bstrMetabasePath += t_szSubKey;
  216. if( t_eSubKeyType == a_eKeyType &&
  217. !( m_pAssociation &&
  218. (m_pAssociation->at == at_Component || m_pAssociation->fFlags & ASSOC_EXTRAORDINARY) &&
  219. m_pAssociation->pcLeft->eKeyType != a_eParentKeyType
  220. )
  221. )
  222. {
  223. DoPing(a_pszKeyName, t_bstrMetabasePath, a_pszLeftPath);
  224. }
  225. else if( a_eKeyType == TYPE_AdminACL || // AdminACL
  226. a_eKeyType == TYPE_AdminACE
  227. )
  228. {
  229. if( !(m_pAssociation &&
  230. m_pAssociation->at == at_AdminACL &&
  231. m_pAssociation->pcLeft->eKeyType != t_eSubKeyType &&
  232. lstrcmpiW(m_pAssociation->pszAssociationName, L"IIs_AdminACL_ACE")
  233. )
  234. )
  235. {
  236. DoPingAdminACL(a_eKeyType, a_pszKeyName, t_bstrMetabasePath);
  237. }
  238. }
  239. else if( a_eKeyType == TYPE_IPSecurity ) // IPSecurity
  240. {
  241. if( !(m_pAssociation &&
  242. m_pAssociation->at == at_IPSecurity &&
  243. m_pAssociation->pcLeft->eKeyType != t_eSubKeyType
  244. )
  245. )
  246. {
  247. DoPingIPSecurity(a_eKeyType, a_pszKeyName, t_bstrMetabasePath);
  248. }
  249. }
  250. // recusive
  251. if(ContinueRecurse(t_eSubKeyType, a_eKeyType))
  252. {
  253. LPCWSTR t_pszLeftPath = a_pszLeftPath;
  254. // if the association is extraordinary (see schema.h for explanation)
  255. if (m_pAssociation && m_pAssociation->fFlags & ASSOC_EXTRAORDINARY)
  256. {
  257. // When the left endpoint of the assoc. is found freeze the
  258. // parent key type and path.
  259. if (a_pszLeftPath != NULL || (a_eParentKeyType == IIsComputer && a_eParentKeyType == m_pAssociation->pcLeft->eKeyType))
  260. {
  261. t_eSubKeyType = a_eParentKeyType;
  262. }
  263. if (t_eSubKeyType == m_pAssociation->pcLeft->eKeyType && a_pszLeftPath == NULL)
  264. {
  265. t_pszLeftPath = t_bstrMetabasePath;
  266. }
  267. }
  268. else
  269. {
  270. // this is the parent path, because the next thing we are doing is
  271. // calling recurse.
  272. t_pszLeftPath = t_bstrMetabasePath;
  273. }
  274. Recurse(t_bstrMetabasePath, t_eSubKeyType, t_pszLeftPath, a_pszKeyName, a_eKeyType);
  275. }
  276. }
  277. }while(t_hr == ERROR_SUCCESS);
  278. }
  279. // DESC: You are looking for a_eKeyType by traversing thru the tree. You are
  280. // currently at a_eParentKeyType and need to determine if you should keep
  281. // on going.
  282. // COMM: This seems very similar to CMetabase::CheckKey
  283. bool CEnum::ContinueRecurse(
  284. enum_KEY_TYPE a_eParentKeyType,
  285. enum_KEY_TYPE a_eKeyType
  286. )
  287. {
  288. bool bRet = false;
  289. switch(a_eKeyType)
  290. {
  291. case IIsLogModule:
  292. if( a_eParentKeyType == IIsLogModules )
  293. bRet = true;
  294. break;
  295. case IIsFtpInfo:
  296. if( a_eParentKeyType == IIsFtpService )
  297. bRet = true;
  298. break;
  299. case IIsFtpServer:
  300. if( a_eParentKeyType == IIsFtpService )
  301. bRet = true;
  302. break;
  303. case IIsFtpVirtualDir:
  304. if( a_eParentKeyType == IIsFtpService ||
  305. a_eParentKeyType == IIsFtpServer ||
  306. a_eParentKeyType == IIsFtpVirtualDir
  307. )
  308. bRet = true;
  309. break;
  310. case IIsWebInfo:
  311. if( a_eParentKeyType == IIsWebService )
  312. bRet = true;
  313. break;
  314. case IIsFilters:
  315. if( a_eParentKeyType == IIsWebService ||
  316. a_eParentKeyType == IIsWebServer
  317. )
  318. bRet = true;
  319. break;
  320. case IIsFilter:
  321. if( a_eParentKeyType == IIsWebService ||
  322. a_eParentKeyType == IIsWebServer ||
  323. a_eParentKeyType == IIsFilters
  324. )
  325. bRet = true;
  326. break;
  327. case IIsCompressionSchemes:
  328. if( a_eParentKeyType == IIsWebService ||
  329. a_eParentKeyType == IIsWebServer ||
  330. a_eParentKeyType == IIsFilters
  331. )
  332. bRet = true;
  333. break;
  334. case IIsCompressionScheme:
  335. if( a_eParentKeyType == IIsWebService ||
  336. a_eParentKeyType == IIsWebServer ||
  337. a_eParentKeyType == IIsFilters ||
  338. a_eParentKeyType == IIsCompressionSchemes )
  339. bRet = true;
  340. break;
  341. case IIsWebServer:
  342. if( a_eParentKeyType == IIsWebService )
  343. bRet = true;
  344. break;
  345. case IIsCertMapper:
  346. if( a_eParentKeyType == IIsWebService ||
  347. a_eParentKeyType == IIsWebServer
  348. )
  349. bRet = true;
  350. break;
  351. case IIsWebVirtualDir:
  352. if( a_eParentKeyType == IIsWebService ||
  353. a_eParentKeyType == IIsWebServer ||
  354. a_eParentKeyType == IIsWebVirtualDir ||
  355. a_eParentKeyType == IIsWebDirectory
  356. )
  357. bRet = true;
  358. break;
  359. case IIsWebDirectory:
  360. if( a_eParentKeyType == IIsWebService ||
  361. a_eParentKeyType == IIsWebServer ||
  362. a_eParentKeyType == IIsWebVirtualDir ||
  363. a_eParentKeyType == IIsWebDirectory
  364. )
  365. bRet = true;
  366. break;
  367. case IIsWebFile:
  368. if( a_eParentKeyType == IIsWebService ||
  369. a_eParentKeyType == IIsWebServer ||
  370. a_eParentKeyType == IIsWebVirtualDir ||
  371. a_eParentKeyType == IIsWebDirectory
  372. )
  373. bRet = true;
  374. break;
  375. case TYPE_AdminACL:
  376. case TYPE_AdminACE:
  377. if( a_eParentKeyType == IIsWebService ||
  378. a_eParentKeyType == IIsWebServer ||
  379. a_eParentKeyType == IIsWebVirtualDir ||
  380. a_eParentKeyType == IIsWebDirectory ||
  381. a_eParentKeyType == IIsFtpService ||
  382. a_eParentKeyType == IIsFtpServer ||
  383. a_eParentKeyType == IIsFtpVirtualDir
  384. )
  385. bRet = true;
  386. break;
  387. case TYPE_IPSecurity:
  388. if( a_eParentKeyType == IIsWebService ||
  389. a_eParentKeyType == IIsWebServer ||
  390. a_eParentKeyType == IIsWebVirtualDir ||
  391. a_eParentKeyType == IIsWebDirectory ||
  392. a_eParentKeyType == IIsFtpService ||
  393. a_eParentKeyType == IIsFtpServer ||
  394. a_eParentKeyType == IIsFtpVirtualDir
  395. )
  396. bRet = true;
  397. break;
  398. default:
  399. break;
  400. }
  401. return bRet;
  402. }
  403. void CEnum::DoPingAdminACL(
  404. enum_KEY_TYPE a_eKeyType,
  405. LPCWSTR a_pszKeyName,
  406. LPCWSTR a_pszKeyPath
  407. )
  408. {
  409. // add keyref
  410. _variant_t t_v(a_pszKeyPath);
  411. THROW_ON_FALSE(m_pParsedObject->AddKeyRef(a_pszKeyName,&t_v));
  412. if(a_eKeyType == TYPE_AdminACE)
  413. {
  414. EnumACE(a_pszKeyPath);
  415. }
  416. else if(a_eKeyType == TYPE_AdminACL)
  417. {
  418. // ping
  419. if (!m_pAssociation)
  420. PingObject();
  421. else
  422. PingAssociationAdminACL(a_pszKeyPath);
  423. }
  424. // clear keyref
  425. m_pParsedObject->ClearKeys();
  426. }
  427. // for AdminACL
  428. void CEnum::EnumACE(
  429. LPCWSTR pszKeyPath
  430. )
  431. {
  432. HRESULT hr = S_OK;
  433. _variant_t var;
  434. IEnumVARIANT* pEnum = NULL;
  435. ULONG lFetch;
  436. BSTR bstrTrustee;
  437. IDispatch* pDisp = NULL;
  438. IADsAccessControlEntry* pACE = NULL;
  439. _bstr_t bstrMbPath;
  440. WMI_CLASS* pWMIClass;
  441. // get the metabase path of the object
  442. BOOL fClass = FALSE;
  443. if(m_pAssociation)
  444. fClass = CUtils::GetClass(m_pAssociation->pcLeft->pszClassName,&pWMIClass);
  445. else
  446. fClass = CUtils::GetClass(m_pParsedObject->m_pClass,&pWMIClass);
  447. if(!fClass)
  448. return;
  449. CUtils::GetMetabasePath(NULL,m_pParsedObject,pWMIClass,bstrMbPath);
  450. // open ADSI
  451. CAdminACL objACL;
  452. hr = objACL.OpenSD(bstrMbPath);
  453. if(SUCCEEDED(hr))
  454. hr = objACL.GetACEEnum(&pEnum);
  455. if ( FAILED(hr) )
  456. return;
  457. //////////////////////////////////////////////
  458. // Enumerate ACEs
  459. //////////////////////////////////////////////
  460. hr = pEnum->Next( 1, &var, &lFetch );
  461. while( hr == S_OK )
  462. {
  463. if ( lFetch == 1 )
  464. {
  465. if ( VT_DISPATCH != V_VT(&var) )
  466. {
  467. break;
  468. }
  469. pDisp = V_DISPATCH(&var);
  470. /////////////////////////////
  471. // Get the individual ACE
  472. /////////////////////////////
  473. hr = pDisp->QueryInterface(
  474. IID_IADsAccessControlEntry,
  475. (void**)&pACE
  476. );
  477. if ( SUCCEEDED(hr) )
  478. {
  479. hr = pACE->get_Trustee(&bstrTrustee);
  480. if( SUCCEEDED(hr) )
  481. {
  482. // add keyref
  483. _variant_t t_v(bstrTrustee);
  484. //m_pParsedObject->RemoveKeyRef(L"Trustee");
  485. THROW_ON_FALSE(m_pParsedObject->AddKeyRefEx(L"Trustee",&t_v));
  486. // ping
  487. if (!m_pAssociation)
  488. PingObject();
  489. else
  490. PingAssociationAdminACL(pszKeyPath);
  491. }
  492. SysFreeString(bstrTrustee);
  493. pACE->Release();
  494. }
  495. }
  496. hr = pEnum->Next( 1, &var, &lFetch );
  497. }
  498. pEnum->Release();
  499. }
  500. void CEnum::PingAssociationAdminACL(
  501. LPCWSTR a_pszLeftKeyPath
  502. )
  503. {
  504. HRESULT t_hr;
  505. IWbemClassObject* t_pObj = NULL;
  506. IWbemClassObject* t_pClass = NULL;
  507. LPWSTR t_pszObjectPath = NULL;
  508. CObjectPathParser t_PathParser(e_ParserAcceptRelativeNamespace);
  509. WCHAR t_LeftName[20];
  510. WCHAR t_RightName[20];
  511. _bstr_t bstrMbPath;
  512. WMI_CLASS* pWMIClass;
  513. if(m_pAssociation->at != at_AdminACL)
  514. return;
  515. // get the metabase path of the object
  516. if (CUtils::GetClass(m_pAssociation->pcLeft->pszClassName,&pWMIClass))
  517. {
  518. CUtils::GetMetabasePath(NULL,m_pParsedObject,pWMIClass,bstrMbPath);
  519. }
  520. else
  521. return;
  522. // check if AdminACL existed
  523. CAdminACL objACL;
  524. t_hr = objACL.OpenSD(bstrMbPath);
  525. objACL.CloseSD();
  526. if(FAILED(t_hr))
  527. return;
  528. // set the key name
  529. lstrcpyW(t_LeftName, L"GroupComponent");
  530. lstrcpyW(t_RightName, L"PartComponent");
  531. try
  532. {
  533. t_hr = m_pNamespace->GetObject(
  534. m_pAssociation->pszAssociationName,
  535. 0,
  536. NULL,
  537. &t_pClass,
  538. NULL
  539. );
  540. THROW_ON_ERROR(t_hr);
  541. t_hr = t_pClass->SpawnInstance(0, &t_pObj);
  542. t_pClass->Release();
  543. THROW_ON_ERROR(t_hr);
  544. //
  545. // first right side
  546. //
  547. if (!m_pParsedObject->SetClassName(m_pAssociation->pcRight->pszClassName))
  548. throw WBEM_E_FAILED;
  549. if (t_PathParser.Unparse(m_pParsedObject,&t_pszObjectPath))
  550. throw WBEM_E_FAILED;
  551. SetObjectPath(t_RightName, t_pszObjectPath, t_pObj);
  552. if(t_pszObjectPath)
  553. {
  554. delete [] t_pszObjectPath;
  555. t_pszObjectPath = NULL;
  556. }
  557. //
  558. // then left side
  559. //
  560. if(!lstrcmpiW(m_pAssociation->pszAssociationName, L"IIs_AdminACL_ACE"))
  561. {
  562. // clear keyref first
  563. m_pParsedObject->ClearKeys();
  564. // add a keyref
  565. _variant_t t_vt = a_pszLeftKeyPath;
  566. THROW_ON_FALSE(m_pParsedObject->AddKeyRef(m_pAssociation->pcLeft->pszKeyName,&t_vt));
  567. }
  568. if (!m_pParsedObject->SetClassName(m_pAssociation->pcLeft->pszClassName))
  569. throw WBEM_E_FAILED;
  570. if (t_PathParser.Unparse(m_pParsedObject,&t_pszObjectPath))
  571. throw WBEM_E_FAILED;
  572. SetObjectPath(t_LeftName, t_pszObjectPath, t_pObj);
  573. if(t_pszObjectPath)
  574. {
  575. delete [] t_pszObjectPath;
  576. t_pszObjectPath = NULL;
  577. }
  578. if(t_pObj)
  579. {
  580. m_pInstMgr->Indicate(t_pObj);
  581. t_pObj->Release();
  582. t_pObj = NULL;
  583. }
  584. }
  585. catch (...)
  586. {
  587. if(t_pszObjectPath)
  588. delete [] t_pszObjectPath;
  589. if(t_pObj)
  590. t_pObj->Release();
  591. }
  592. }
  593. // for IPSecurity
  594. void CEnum::DoPingIPSecurity(
  595. enum_KEY_TYPE a_eKeyType,
  596. LPCWSTR a_pszKeyName,
  597. LPCWSTR a_pszKeyPath
  598. )
  599. {
  600. // add keyref
  601. _variant_t t_v(a_pszKeyPath);
  602. THROW_ON_FALSE(m_pParsedObject->AddKeyRef(a_pszKeyName,&t_v));
  603. // ping
  604. if (!m_pAssociation)
  605. PingObject();
  606. else
  607. PingAssociationIPSecurity(a_pszKeyPath);
  608. // clear keyref
  609. m_pParsedObject->ClearKeys();
  610. }
  611. // for IPSecurity
  612. void CEnum::PingAssociationIPSecurity(
  613. LPCWSTR a_pszLeftKeyPath
  614. )
  615. {
  616. HRESULT t_hr;
  617. IWbemClassObject* t_pObj = NULL;
  618. IWbemClassObject* t_pClass = NULL;
  619. LPWSTR t_pszObjectPath = NULL;
  620. CObjectPathParser t_PathParser(e_ParserAcceptRelativeNamespace);
  621. WCHAR t_LeftName[20];
  622. WCHAR t_RightName[20];
  623. _bstr_t bstrMbPath;
  624. WMI_CLASS* pWMIClass;
  625. if(m_pAssociation->at != at_IPSecurity)
  626. return;
  627. // get the metabase path of the object
  628. if (CUtils::GetClass(m_pAssociation->pcLeft->pszClassName,&pWMIClass))
  629. {
  630. CUtils::GetMetabasePath(NULL,m_pParsedObject,pWMIClass,bstrMbPath);
  631. }
  632. else
  633. return;
  634. // check if IPSecurity existed
  635. CIPSecurity objIPsec;
  636. t_hr = objIPsec.OpenSD(bstrMbPath);
  637. objIPsec.CloseSD();
  638. if(FAILED(t_hr))
  639. return;
  640. // set the key name
  641. lstrcpyW(t_LeftName, L"Element");
  642. lstrcpyW(t_RightName, L"Setting");
  643. try
  644. {
  645. t_hr = m_pNamespace->GetObject(
  646. m_pAssociation->pszAssociationName,
  647. 0,
  648. NULL,
  649. &t_pClass,
  650. NULL
  651. );
  652. THROW_ON_ERROR(t_hr);
  653. t_hr = t_pClass->SpawnInstance(0, &t_pObj);
  654. t_pClass->Release();
  655. THROW_ON_ERROR(t_hr);
  656. //
  657. // first right side
  658. //
  659. if (!m_pParsedObject->SetClassName(m_pAssociation->pcRight->pszClassName))
  660. throw WBEM_E_FAILED;
  661. if (t_PathParser.Unparse(m_pParsedObject,&t_pszObjectPath))
  662. throw WBEM_E_FAILED;
  663. SetObjectPath(t_RightName, t_pszObjectPath, t_pObj);
  664. if(t_pszObjectPath)
  665. {
  666. delete [] t_pszObjectPath;
  667. t_pszObjectPath = NULL;
  668. }
  669. //
  670. // then left side
  671. //
  672. if (!m_pParsedObject->SetClassName(m_pAssociation->pcLeft->pszClassName))
  673. throw WBEM_E_FAILED;
  674. if (t_PathParser.Unparse(m_pParsedObject,&t_pszObjectPath))
  675. throw WBEM_E_FAILED;
  676. SetObjectPath(t_LeftName, t_pszObjectPath, t_pObj);
  677. if(t_pszObjectPath)
  678. {
  679. delete [] t_pszObjectPath;
  680. t_pszObjectPath = NULL;
  681. }
  682. if(t_pObj)
  683. {
  684. m_pInstMgr->Indicate(t_pObj);
  685. t_pObj->Release();
  686. t_pObj = NULL;
  687. }
  688. }
  689. catch (...)
  690. {
  691. if(t_pszObjectPath)
  692. delete [] t_pszObjectPath;
  693. if(t_pObj)
  694. t_pObj->Release();
  695. }
  696. }