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.

1498 lines
34 KiB

  1. //***************************************************************************
  2. //
  3. // File:
  4. //
  5. // Module: MS SNMP Provider
  6. //
  7. // Purpose:
  8. //
  9. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #include <precomp.h>
  13. #include "csmir.h"
  14. #include "smir.h"
  15. #include <helper.h>
  16. #include "handles.h"
  17. #include "classfac.h"
  18. #include <textdef.h>
  19. #include "bstring.h"
  20. #include "evtcons.h"
  21. #ifdef ICECAP_PROFILE
  22. #include <icapexp.h>
  23. #endif
  24. #include <cominit.h>
  25. extern BOOL g_initialised ;
  26. //BSTR Helpers
  27. SCODE CopyBSTR(BSTR *pDst, BSTR *pSrc)
  28. {
  29. if(*pDst)
  30. SysFreeString(*pDst);
  31. if(*pSrc)
  32. {
  33. *pDst = SysAllocString(*pSrc);
  34. return S_OK;
  35. }
  36. else
  37. return E_INVALIDARG;
  38. }
  39. // {74864DA1-0630-11d0-A5B6-00AA00680C3F}
  40. //DEFINE_GUID(CLSID_MosGateway,
  41. //0x74864da1, 0x630, 0x11d0, 0xa5, 0xb6, 0x0, 0xaa, 0x0, 0x68, 0xc, 0x3f);
  42. BOOL SetKeyAndValue(wchar_t* pszKey, wchar_t* pszSubkey, wchar_t* pszValueName, wchar_t* pszValue);
  43. SmirClassFactoryHelper :: SmirClassFactoryHelper()
  44. : pGroupHandleClassFactory(NULL), pClassHandleClassFactory(NULL),
  45. pModHandleClassFactory(NULL), pSMIRClassFactory(NULL),
  46. pNotificationClassHandleClassFactory(NULL), pExtNotificationClassHandleClassFactory(NULL)
  47. {
  48. }
  49. SmirClassFactoryHelper :: ~SmirClassFactoryHelper()
  50. {
  51. if(NULL != pGroupHandleClassFactory)
  52. pGroupHandleClassFactory->Release();
  53. if(NULL != pClassHandleClassFactory)
  54. pClassHandleClassFactory->Release();
  55. if(NULL != pModHandleClassFactory)
  56. pModHandleClassFactory->Release();
  57. if(NULL != pNotificationClassHandleClassFactory)
  58. pNotificationClassHandleClassFactory->Release();
  59. if(NULL != pExtNotificationClassHandleClassFactory)
  60. pExtNotificationClassHandleClassFactory->Release();
  61. if(NULL != pSMIRClassFactory )
  62. {
  63. pSMIRClassFactory->Release();
  64. }
  65. }
  66. SCODE SmirClassFactoryHelper :: CreateInstance(REFCLSID rclsid,REFIID riid, LPVOID * ppv)
  67. {
  68. CSMIRGenericClassFactory *ppClassFactory = NULL ;
  69. SCODE result = S_OK;
  70. *ppv=NULL;
  71. if((CLSID_SMIR_Database==rclsid)||
  72. (IID_IConnectionPointContainer==rclsid))
  73. {
  74. ppClassFactory = new CSMIRClassFactory(rclsid);
  75. }
  76. else if(CLSID_SMIR_ModHandle == rclsid)
  77. {
  78. ppClassFactory = new CModHandleClassFactory(rclsid);
  79. }
  80. else if(CLSID_SMIR_GroupHandle == rclsid)
  81. {
  82. ppClassFactory = new CGroupHandleClassFactory(rclsid);
  83. }
  84. else if(CLSID_SMIR_ClassHandle == rclsid)
  85. {
  86. ppClassFactory = new CClassHandleClassFactory(rclsid);
  87. }
  88. else if(CLSID_SMIR_NotificationClassHandle == rclsid)
  89. {
  90. ppClassFactory = new CNotificationClassHandleClassFactory(rclsid);
  91. }
  92. else if(CLSID_SMIR_ExtNotificationClassHandle == rclsid)
  93. {
  94. ppClassFactory = new CExtNotificationClassHandleClassFactory(rclsid);
  95. }
  96. ppClassFactory->AddRef();
  97. result = ppClassFactory->CreateInstance (NULL ,riid ,ppv);
  98. ppClassFactory->Release();
  99. if((S_OK != result)||(*ppv == NULL))
  100. {
  101. return result;
  102. }
  103. return result;
  104. }
  105. /* CSmirAccess
  106. *A simple class to open and create the smir - extended to opan any namespace
  107. */
  108. void CSmirAccess :: ShutDown ()
  109. {
  110. if (CSmir::sm_ConnectionObjects != NULL)
  111. {
  112. CSmir::sm_ConnectionObjects->Release ();
  113. CSmir::sm_ConnectionObjects = NULL ;
  114. }
  115. if(NULL != g_pClassFactoryHelper)
  116. {
  117. delete g_pClassFactoryHelper;
  118. g_pClassFactoryHelper = NULL;
  119. }
  120. //SMIR requires re-initialization!
  121. g_initialised = FALSE ;
  122. }
  123. STDMETHODIMP CSmirAccess :: Init ()
  124. {
  125. return S_OK;
  126. }
  127. STDMETHODIMP CSmirAccess :: Open (
  128. CSmir *a_Smir ,
  129. IWbemServices **server,
  130. BSTR ObjectPath,
  131. BOOL relativeToSMIR
  132. )
  133. {
  134. IWbemServices *returnedServ = NULL ;
  135. *server=NULL;
  136. if (relativeToSMIR && (ObjectPath == NULL))
  137. {
  138. return WBEM_E_FAILED;
  139. }
  140. if(FAILED(Connect(a_Smir, &returnedServ, ObjectPath, relativeToSMIR)))
  141. {
  142. return WBEM_E_FAILED;
  143. }
  144. *server = returnedServ;
  145. return S_OK;
  146. }
  147. STDMETHODIMP CSmirAccess :: Open(
  148. CSmir *a_Smir ,
  149. IWbemServices **server,
  150. ISmirClassHandle *hClass,
  151. eOpenType eType
  152. )
  153. {
  154. if(NULL == server)
  155. return WBEM_E_FAILED;
  156. SCODE returnCode=S_OK;
  157. BSTR szTModstr = NULL;
  158. BSTR szTGroupstr = NULL;
  159. hClass->GetModuleName(&szTModstr);
  160. hClass->GetGroupName(&szTGroupstr);
  161. wchar_t *pTGroupNSString = NULL ;
  162. if(eType == eGroup)
  163. {
  164. hClass->GetGroupName(&szTGroupstr);
  165. pTGroupNSString = new wchar_t[wcslen(SMIR_NAMESPACE)+wcslen(BACKSLASH_STR)
  166. +wcslen(szTModstr)+wcslen(BACKSLASH_STR)+wcslen(szTGroupstr)+1];
  167. }
  168. else
  169. {
  170. hClass->GetGroupName(&szTGroupstr);
  171. pTGroupNSString = new wchar_t[wcslen(SMIR_NAMESPACE)+wcslen(BACKSLASH_STR)
  172. +wcslen(szTModstr)+1];
  173. }
  174. if(NULL != pTGroupNSString)
  175. {
  176. wcscpy(pTGroupNSString,szTModstr);
  177. //<module name>
  178. if(eType == eGroup)
  179. {
  180. wcscat(pTGroupNSString,BACKSLASH_STR);
  181. wcscat(pTGroupNSString,szTGroupstr);
  182. // <module name>\<group name>
  183. }
  184. CBString t_Str ( pTGroupNSString ) ;
  185. SCODE result= CSmirAccess :: Open(
  186. a_Smir,
  187. server,
  188. t_Str.GetString (),
  189. TRUE
  190. );
  191. delete [] pTGroupNSString;
  192. if ((FAILED(result))||(NULL == server))
  193. {
  194. //if we can't open the namespace the group handle must be invalid
  195. returnCode = result;
  196. }
  197. }
  198. else
  199. {
  200. returnCode= E_OUTOFMEMORY;
  201. }
  202. if(FAILED(returnCode))
  203. {
  204. FormatProviderErrorMsg(__FILE__,__LINE__,returnCode);
  205. returnCode = (returnCode==E_OUTOFMEMORY?E_OUTOFMEMORY:WBEM_E_FAILED);
  206. }
  207. //free the string we got from hGroup
  208. SysFreeString(szTModstr);
  209. SysFreeString(szTGroupstr);
  210. return returnCode;
  211. }
  212. STDMETHODIMP CSmirAccess :: Open(
  213. CSmir *a_Smir ,
  214. IWbemServices **server,
  215. ISmirGroupHandle *hGroup,
  216. eOpenType eType
  217. )
  218. {
  219. if(NULL == server)
  220. return WBEM_E_FAILED;
  221. SCODE returnCode=S_OK;
  222. BSTR szTModstr=NULL;
  223. BSTR szTGroupstr=NULL;
  224. hGroup->GetModuleName(&szTModstr);
  225. wchar_t *pTGroupNSString = NULL;
  226. if(eType == eGroup)
  227. {
  228. hGroup->GetName(&szTGroupstr);
  229. pTGroupNSString =new wchar_t[wcslen(SMIR_NAMESPACE)+wcslen(BACKSLASH_STR)
  230. +wcslen(szTModstr)+wcslen(BACKSLASH_STR)+wcslen(szTGroupstr)+1];
  231. }
  232. else
  233. {
  234. pTGroupNSString =new wchar_t[wcslen(SMIR_NAMESPACE)+wcslen(BACKSLASH_STR)
  235. +wcslen(szTModstr)+1];
  236. }
  237. if(NULL != pTGroupNSString)
  238. {
  239. wcscpy(pTGroupNSString,szTModstr);
  240. // <module name>
  241. if(eType == eGroup)
  242. {
  243. wcscat(pTGroupNSString,BACKSLASH_STR);
  244. wcscat(pTGroupNSString,szTGroupstr);
  245. }
  246. // <module name>\<group name>
  247. CBString t_BStr ( pTGroupNSString ) ;
  248. SCODE result= CSmirAccess :: Open (
  249. a_Smir,
  250. server,
  251. t_BStr.GetString (),
  252. TRUE
  253. );
  254. delete [] pTGroupNSString;
  255. if ((FAILED(result))||(NULL == server))
  256. {
  257. //if we can't open the namespace the group handle must be invalid
  258. returnCode = result;
  259. }
  260. }
  261. else
  262. {
  263. returnCode = E_OUTOFMEMORY;
  264. }
  265. if(FAILED(returnCode))
  266. {
  267. FormatProviderErrorMsg(__FILE__,__LINE__,returnCode);
  268. returnCode = (returnCode==E_OUTOFMEMORY?E_OUTOFMEMORY:WBEM_E_FAILED);
  269. }
  270. //free the strings we got from hModule and hGroup
  271. SysFreeString(szTModstr);
  272. SysFreeString(szTGroupstr);
  273. return returnCode;
  274. }
  275. STDMETHODIMP CSmirAccess :: Open (
  276. CSmir *a_Smir ,
  277. IWbemServices **server,
  278. ISmirModHandle *hMod
  279. )
  280. {
  281. if(NULL == server)
  282. return WBEM_E_FAILED;
  283. SCODE returnCode=S_OK;
  284. //open the module name space
  285. //build the object path
  286. BSTR szTstr=NULL;
  287. hMod->GetName(&szTstr);
  288. wchar_t *pTstring = new wchar_t[wcslen(SMIR_NAMESPACE)+wcslen(BACKSLASH_STR)+wcslen(szTstr)+1];
  289. if(NULL != pTstring)
  290. {
  291. wcscpy(pTstring,szTstr);
  292. // <module name>
  293. CBString t_BStr ( pTstring ) ;
  294. SCODE res = CSmirAccess :: Open (
  295. a_Smir,
  296. server,
  297. t_BStr.GetString (),
  298. TRUE
  299. );
  300. //clean up
  301. delete [] pTstring;
  302. if (FAILED(res)||(NULL == server))
  303. {
  304. returnCode = res;
  305. }
  306. }
  307. else
  308. {
  309. returnCode = E_OUTOFMEMORY;
  310. }
  311. //free the string we got from hGroup
  312. SysFreeString(szTstr);
  313. if(FAILED(returnCode))
  314. {
  315. returnCode = (returnCode==E_OUTOFMEMORY?E_OUTOFMEMORY:WBEM_E_FAILED);
  316. }
  317. return S_OK;
  318. }
  319. STDMETHODIMP CSmirAccess :: Connect (
  320. IN CSmir *a_Smir ,
  321. OUT IWbemServices **a_Server,
  322. IN BSTR a_Namespace ,
  323. IN BOOL a_RelativeToSMIR
  324. )
  325. {
  326. //I only have one point of failure so don't use the garbage collector
  327. *a_Server = NULL;
  328. //open the namespace (default is the smir)
  329. HRESULT t_Result;
  330. ISMIRWbemConfiguration *t_Configuration = NULL ;
  331. IWbemServices *t_Service = NULL ;
  332. IWbemContext *t_Context = NULL;
  333. t_Result = a_Smir->QueryInterface (
  334. IID_ISMIRWbemConfiguration ,
  335. ( void **) & t_Configuration
  336. ) ;
  337. if ( SUCCEEDED ( t_Result ) )
  338. {
  339. t_Configuration->GetContext ( & t_Context ) ;
  340. t_Result = t_Configuration->GetServices ( & t_Service ) ;
  341. if ( SUCCEEDED ( t_Result ) )
  342. {
  343. t_Result = WbemSetProxyBlanket(t_Service,
  344. RPC_C_AUTHN_DEFAULT,
  345. RPC_C_AUTHZ_DEFAULT,
  346. COLE_DEFAULT_PRINCIPAL,
  347. RPC_C_AUTHN_LEVEL_DEFAULT,
  348. RPC_C_IMP_LEVEL_DEFAULT,
  349. NULL,
  350. EOAC_DYNAMIC_CLOAKING);
  351. if ( FAILED ( t_Result ) && t_Result != E_NOINTERFACE )
  352. {
  353. t_Service->Release();
  354. t_Service = NULL;
  355. }
  356. else
  357. {
  358. t_Result = S_OK ;
  359. }
  360. }
  361. else
  362. {
  363. t_Result = t_Configuration->Authenticate (
  364. NULL,
  365. NULL,
  366. NULL,
  367. NULL,
  368. 0 ,
  369. NULL ,
  370. TRUE
  371. ) ;
  372. if ( SUCCEEDED ( t_Result ) )
  373. {
  374. t_Result = t_Configuration->GetServices ( & t_Service ) ;
  375. if ( SUCCEEDED ( t_Result ) )
  376. {
  377. t_Result = WbemSetProxyBlanket(t_Service,
  378. RPC_C_AUTHN_DEFAULT,
  379. RPC_C_AUTHZ_DEFAULT,
  380. COLE_DEFAULT_PRINCIPAL,
  381. RPC_C_AUTHN_LEVEL_DEFAULT,
  382. RPC_C_IMP_LEVEL_DEFAULT,
  383. NULL,
  384. EOAC_DYNAMIC_CLOAKING);
  385. if ( FAILED ( t_Result ) && t_Result != E_NOINTERFACE )
  386. {
  387. t_Service->Release();
  388. t_Service = NULL;
  389. }
  390. else
  391. {
  392. t_Result = S_OK ;
  393. }
  394. }
  395. }
  396. }
  397. t_Configuration->Release () ;
  398. }
  399. if ( SUCCEEDED ( t_Result ) )
  400. {
  401. if( a_Namespace != NULL )
  402. {
  403. CBString t_BStr ( a_Namespace ) ;
  404. if ( a_RelativeToSMIR )
  405. {
  406. t_Result = t_Service->OpenNamespace (
  407. t_BStr.GetString (),
  408. 0,
  409. t_Context,
  410. a_Server,
  411. NULL
  412. );
  413. if ( SUCCEEDED ( t_Result ) )
  414. {
  415. t_Result = WbemSetProxyBlanket(*a_Server,
  416. RPC_C_AUTHN_DEFAULT,
  417. RPC_C_AUTHZ_DEFAULT,
  418. COLE_DEFAULT_PRINCIPAL,
  419. RPC_C_AUTHN_LEVEL_DEFAULT,
  420. RPC_C_IMP_LEVEL_DEFAULT,
  421. NULL,
  422. EOAC_DYNAMIC_CLOAKING);
  423. if ( FAILED ( t_Result ) && t_Result != E_NOINTERFACE )
  424. {
  425. (*a_Server)->Release();
  426. (*a_Server) = NULL;
  427. }
  428. else
  429. {
  430. t_Result = S_OK ;
  431. }
  432. }
  433. }
  434. else
  435. {
  436. t_Result = WBEM_E_FAILED ;
  437. }
  438. t_Service->Release () ;
  439. }
  440. else
  441. {
  442. *a_Server = t_Service ;
  443. }
  444. }
  445. if ( t_Context )
  446. t_Context->Release();
  447. return t_Result ;
  448. }
  449. STDMETHODIMP CSmirAccess :: GetContext (
  450. IN CSmir *a_Smir ,
  451. OUT IWbemContext **a_Context
  452. )
  453. {
  454. //I only have one point of failure so don't use the garbage collector
  455. *a_Context = NULL;
  456. //open the namespace (default is the smir)
  457. HRESULT t_Result;
  458. ISMIRWbemConfiguration *t_Configuration = NULL ;
  459. t_Result = a_Smir->QueryInterface (
  460. IID_ISMIRWbemConfiguration ,
  461. ( void **) & t_Configuration
  462. ) ;
  463. if ( SUCCEEDED ( t_Result ) )
  464. {
  465. t_Result = t_Configuration->GetContext ( a_Context ) ;
  466. t_Configuration->Release () ;
  467. }
  468. return t_Result ;
  469. }
  470. void FormatProviderErrorMsg(char*file, int line, SCODE errorCode)
  471. {
  472. //use the strings
  473. switch (errorCode)
  474. {
  475. case WBEM_NO_ERROR:
  476. break;
  477. case WBEM_S_NO_MORE_DATA:
  478. break;
  479. case WBEM_E_FAILED:
  480. break;
  481. case WBEM_E_NOT_FOUND:
  482. break;
  483. case WBEM_E_ACCESS_DENIED:
  484. break;
  485. case WBEM_E_PROVIDER_FAILURE:
  486. break;
  487. case WBEM_E_TYPE_MISMATCH:
  488. break;
  489. case WBEM_E_OUT_OF_MEMORY:
  490. break;
  491. case WBEM_E_INVALID_CONTEXT:
  492. break;
  493. case WBEM_E_INVALID_PARAMETER:
  494. break;
  495. case WBEM_E_NOT_AVAILABLE:
  496. break;
  497. case WBEM_E_CRITICAL_ERROR:
  498. break;
  499. case WBEM_E_INVALID_STREAM:
  500. break;
  501. case WBEM_E_NOT_SUPPORTED:
  502. break;
  503. case WBEM_E_INVALID_SUPERCLASS:
  504. break;
  505. case WBEM_E_INVALID_NAMESPACE:
  506. break;
  507. case WBEM_E_INVALID_OBJECT:
  508. break;
  509. case WBEM_E_INVALID_CLASS:
  510. break;
  511. case WBEM_E_PROVIDER_NOT_FOUND:
  512. break;
  513. case WBEM_E_INVALID_PROVIDER_REGISTRATION:
  514. break;
  515. case WBEM_E_PROVIDER_LOAD_FAILURE:
  516. break;
  517. case WBEM_E_INITIALIZATION_FAILURE:
  518. break;
  519. case WBEM_E_INVALID_OPERATION:
  520. break;
  521. case WBEM_E_INVALID_QUERY:
  522. break;
  523. case WBEM_E_INVALID_QUERY_TYPE:
  524. break;
  525. case E_INVALIDARG:
  526. break;
  527. case E_UNEXPECTED:
  528. break;
  529. case E_OUTOFMEMORY:
  530. break;
  531. default:
  532. break;
  533. }
  534. }
  535. SCODE CGroupToClassAssociator :: Associate (
  536. CSmir *a_Smir,
  537. BSTR szModuleName,
  538. BSTR szGroupName,
  539. ISmirClassHandle *hClass
  540. )
  541. {
  542. if ((NULL == hClass)||(NULL==szModuleName)||(NULL==szGroupName))
  543. return WBEM_E_FAILED;
  544. IWbemServices *moServ = NULL ;
  545. IWbemContext *moContext = NULL ;
  546. SCODE result= CSmirAccess :: GetContext (a_Smir , &moContext);
  547. //open the root\default\SMIR namespace
  548. CSmirAccess :: Open(a_Smir,&moServ);
  549. IWbemClassObject *pClass = NULL ;
  550. CBString t_BStr ( SMIR_GROUP_ASSOC_CLASS_NAME ) ;
  551. result = moServ->GetObject(t_BStr.GetString (), 0,
  552. moContext,&pClass, NULL);
  553. if ((FAILED(result))||(NULL == pClass))
  554. {
  555. if ( moContext )
  556. moContext->Release () ;
  557. moServ->Release();
  558. return WBEM_E_FAILED;
  559. }
  560. IWbemClassObject *pInst = NULL ;
  561. result = pClass->SpawnInstance ( 0 , &pInst ) ;
  562. pClass->Release ();
  563. if ((FAILED(result))||(NULL==pInst))
  564. {
  565. if ( moContext )
  566. moContext->Release () ;
  567. moServ->Release();
  568. return WBEM_E_FAILED;
  569. }
  570. VARIANT v;
  571. VariantInit(&v);
  572. //Get the class name
  573. result = ((CSmirClassHandle*)hClass)->m_pIMosClass->Get(OLEMS_CLASS_PROP,
  574. RESERVED_WBEM_FLAG, &v,NULL,NULL);
  575. if ((FAILED(result))|(V_VT(&v) != VT_BSTR))
  576. {
  577. if ( moContext )
  578. moContext->Release () ;
  579. pInst->Release();
  580. moServ->Release();
  581. return WBEM_E_FAILED;
  582. }
  583. BSTR szClassName = SysAllocString(V_BSTR(&v));
  584. VariantClear(&v);
  585. /****************give it a Name property**********************************/
  586. CString associationClassName(CString(szClassName)
  587. +CString(SMIR_GROUP_ASSOC_CLASS_NAME_POSTFIX));
  588. V_VT(&v) = VT_BSTR;
  589. V_BSTR(&v)=associationClassName.AllocSysString();
  590. result = pInst->Put(SMIR_X_ASSOC_NAME_PROP,RESERVED_WBEM_FLAG, &v,0);
  591. VariantClear(&v);
  592. if (FAILED(result))
  593. {
  594. if ( moContext )
  595. moContext->Release () ;
  596. SysFreeString(szClassName);
  597. pInst->Release();
  598. moServ->Release();
  599. return WBEM_E_FAILED;
  600. }
  601. /****************give it a class property**********************************/
  602. //get the fully qualified class name
  603. //classes = "\\\\.\\root\\default\\SMIR:MS_SNMP_RFC1213_MIB_atTable";
  604. CString classPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  605. +CString(COLON_STR)
  606. +CString(szClassName));
  607. //don't need this anymore
  608. SysFreeString(szClassName);
  609. V_VT(&v) = VT_BSTR;
  610. V_BSTR(&v)=classPath.AllocSysString();
  611. result = pInst->Put(SMIR_X_ASSOC_CLASS_PROP,RESERVED_WBEM_FLAG, &v,0);
  612. VariantClear(&v);
  613. if (FAILED(result))
  614. {
  615. if ( moContext )
  616. moContext->Release () ;
  617. pInst->Release();
  618. moServ->Release();
  619. return WBEM_E_FAILED;
  620. }
  621. /****************give it a group property**********************************/
  622. //get the fully qualified class name
  623. //group = "\\\\.\\root\\default\\SMIR\\RFC1213_MIB:Group=\"atV1ObjectGroup\"";
  624. CString groupPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  625. +CString(BACKSLASH_STR)
  626. +CString(szModuleName)
  627. +CString(COLON_STR)
  628. +CString(GROUP_NAMESPACE_NAME)
  629. +CString(DOT_STR)
  630. +CString(OLEMS_NAME_PROP)
  631. +CString(EQUALS_STR)
  632. +CString(QUOTE_STR)
  633. +CString(szGroupName)
  634. +CString(QUOTE_STR));
  635. V_VT(&v) = VT_BSTR;
  636. V_BSTR(&v)=groupPath.AllocSysString();
  637. result = pInst->Put(SMIR_GROUP_ASSOC_GROUP_PROP,RESERVED_WBEM_FLAG, &v,0);
  638. VariantClear(&v);
  639. if (FAILED(result))
  640. {
  641. if ( moContext )
  642. moContext->Release () ;
  643. pInst->Release();
  644. moServ->Release();
  645. return WBEM_E_FAILED;
  646. }
  647. //now save it
  648. result = moServ->PutInstance(pInst, RESERVED_WBEM_FLAG, moContext,NULL);
  649. if ( moContext )
  650. moContext->Release () ;
  651. pInst->Release();
  652. moServ->Release();
  653. /*the query to find the classes is
  654. *associators of {\\.\root\default\SMIR\RFC1316-MIB:Group="charV1ObjectGroup"}
  655. *or
  656. *associators of {\\.\root\default\SMIR\RFC1213-MIB:Group="atV1ObjectGroup"}
  657. */
  658. return S_OK;
  659. }
  660. SCODE CModuleToClassAssociator :: Associate (
  661. CSmir *a_Smir,
  662. BSTR szModuleName,
  663. ISmirClassHandle *hClass
  664. )
  665. {
  666. if ((NULL == hClass)||(NULL==szModuleName))
  667. return WBEM_E_FAILED;
  668. IWbemServices * moServ = NULL ;
  669. IWbemContext *moContext = NULL ;
  670. SCODE result= CSmirAccess :: GetContext (a_Smir , &moContext);
  671. //open the root\default\SMIR namespace
  672. CSmirAccess :: Open(a_Smir,&moServ);
  673. //get an object
  674. IWbemClassObject *pClass = NULL ;
  675. CBString t_BStr ( SMIR_MODULE_ASSOC_CLASS_NAME ) ;
  676. result = moServ->GetObject(t_BStr.GetString (), 0,
  677. moContext,&pClass, NULL);
  678. if ((FAILED(result))||(NULL == pClass))
  679. {
  680. if ( moContext )
  681. moContext->Release () ;
  682. moServ->Release();
  683. return WBEM_E_FAILED;
  684. }
  685. IWbemClassObject *pInst = NULL ;
  686. result = pClass->SpawnInstance ( 0 , &pInst ) ;
  687. pClass->Release ();
  688. if ((FAILED(result))||(NULL==pInst))
  689. {
  690. if ( moContext )
  691. moContext->Release () ;
  692. moServ->Release();
  693. return WBEM_E_FAILED;
  694. }
  695. VARIANT v;
  696. VariantInit(&v);
  697. //Get the class name
  698. result = ((CSmirClassHandle*)hClass)->m_pIMosClass->Get(OLEMS_CLASS_PROP,
  699. RESERVED_WBEM_FLAG, &v,NULL,NULL);
  700. if ((FAILED(result))|(V_VT(&v) != VT_BSTR))
  701. {
  702. if ( moContext )
  703. moContext->Release () ;
  704. moServ->Release();
  705. pInst->Release();
  706. return WBEM_E_FAILED;
  707. }
  708. BSTR szClassName = SysAllocString(V_BSTR(&v));
  709. VariantClear(&v);
  710. /****************give it a Name property**********************************/
  711. V_VT(&v) = VT_BSTR;
  712. CString associationClassName(CString(szClassName)
  713. +CString(SMIR_MODULE_ASSOC_CLASS_NAME_POSTFIX));
  714. V_BSTR(&v)=associationClassName.AllocSysString();
  715. result = pInst->Put(SMIR_X_ASSOC_NAME_PROP,RESERVED_WBEM_FLAG, &v,0);
  716. VariantClear(&v);
  717. if (FAILED(result))
  718. {
  719. SysFreeString(szClassName);
  720. if ( moContext )
  721. moContext->Release () ;
  722. moServ->Release();
  723. pInst->Release();
  724. return WBEM_E_FAILED;
  725. }
  726. /****************give it a class property**********************************/
  727. //get the fully qualified class name
  728. //classes = "\\\\.\\root\\default\\SMIR:MS_SNMP_RFC1213_MIB_atTable";
  729. CString classPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  730. +CString(COLON_STR)
  731. +CString(szClassName));
  732. SysFreeString(szClassName);
  733. V_VT(&v) = VT_BSTR;
  734. V_BSTR(&v)=classPath.AllocSysString();
  735. result = pInst->Put(SMIR_X_ASSOC_CLASS_PROP,RESERVED_WBEM_FLAG, &v,0);
  736. VariantClear(&v);
  737. if (FAILED(result))
  738. {
  739. if ( moContext )
  740. moContext->Release () ;
  741. moServ->Release();
  742. pInst->Release();
  743. return WBEM_E_FAILED;
  744. }
  745. /****************give it a group property**********************************/
  746. //get the fully qualified class name
  747. //group = "\\\\.\\root\\default\\SMIR:Module=\"RFC1213_MIB\"";
  748. CString groupPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  749. +CString(COLON_STR)
  750. +CString(MODULE_NAMESPACE_NAME)
  751. +CString(DOT_STR)
  752. +CString(OLEMS_NAME_PROP)
  753. +CString(EQUALS_STR)
  754. +CString(QUOTE_STR)
  755. +CString(szModuleName)
  756. +CString(QUOTE_STR));
  757. V_VT(&v) = VT_BSTR;
  758. V_BSTR(&v)=groupPath.AllocSysString();
  759. result = pInst->Put(SMIR_MODULE_ASSOC_MODULE_PROP,RESERVED_WBEM_FLAG, &v,0);
  760. VariantClear(&v);
  761. if (FAILED(result))
  762. {
  763. if ( moContext )
  764. moContext->Release () ;
  765. pInst->Release();
  766. moServ->Release();
  767. return WBEM_E_FAILED;
  768. }
  769. //now save it
  770. result = moServ->PutInstance(pInst, RESERVED_WBEM_FLAG, moContext,NULL);
  771. if ( moContext )
  772. moContext->Release () ;
  773. pInst->Release();
  774. moServ->Release();
  775. /*the query to find the classes is
  776. *associators of {\\.\root\default\SMIR:Module="RFC1213_MIB"}
  777. */
  778. return S_OK;
  779. }
  780. SCODE CModuleToNotificationClassAssociator :: Associate (
  781. CSmir *a_Smir,
  782. BSTR szModuleName,
  783. ISmirNotificationClassHandle *hClass
  784. )
  785. {
  786. if ((NULL == hClass)||(NULL==szModuleName))
  787. return WBEM_E_FAILED;
  788. IWbemServices * moServ = NULL ;
  789. IWbemContext *moContext = NULL ;
  790. SCODE result= CSmirAccess :: GetContext (a_Smir , &moContext);
  791. //open the root\default\SMIR namespace
  792. CSmirAccess :: Open(a_Smir,&moServ);
  793. //get an object
  794. IWbemClassObject *pClass = NULL ;
  795. CBString t_BStr ( SMIR_MODULE_ASSOC_NCLASS_NAME ) ;
  796. result = moServ->GetObject(t_BStr.GetString (), 0,
  797. moContext,&pClass, NULL);
  798. if ((FAILED(result))||(NULL == pClass))
  799. {
  800. if ( moContext )
  801. moContext->Release () ;
  802. moServ->Release();
  803. return WBEM_E_FAILED;
  804. }
  805. IWbemClassObject *pInst = NULL ;
  806. result = pClass->SpawnInstance ( 0 , &pInst ) ;
  807. pClass->Release ();
  808. if ((FAILED(result))||(NULL==pInst))
  809. {
  810. if ( moContext )
  811. moContext->Release () ;
  812. moServ->Release();
  813. return WBEM_E_FAILED;
  814. }
  815. VARIANT v;
  816. VariantInit(&v);
  817. //Get the class name
  818. result = ((CSmirNotificationClassHandle*)hClass)->m_pIMosClass->Get(OLEMS_CLASS_PROP,
  819. RESERVED_WBEM_FLAG, &v,NULL,NULL);
  820. if ((FAILED(result))|(V_VT(&v) != VT_BSTR))
  821. {
  822. if ( moContext )
  823. moContext->Release () ;
  824. moServ->Release();
  825. pInst->Release();
  826. return WBEM_E_FAILED;
  827. }
  828. BSTR szClassName = SysAllocString(V_BSTR(&v));
  829. VariantClear(&v);
  830. /****************give it a Name property**********************************/
  831. V_VT(&v) = VT_BSTR;
  832. CString associationClassName(CString(szClassName)
  833. +CString(SMIR_MODULE_ASSOC_CLASS_NAME_POSTFIX));
  834. V_BSTR(&v)=associationClassName.AllocSysString();
  835. result = pInst->Put(SMIR_X_ASSOC_NAME_PROP,RESERVED_WBEM_FLAG, &v,0);
  836. VariantClear(&v);
  837. if (FAILED(result))
  838. {
  839. SysFreeString(szClassName);
  840. if ( moContext )
  841. moContext->Release () ;
  842. moServ->Release();
  843. pInst->Release();
  844. return WBEM_E_FAILED;
  845. }
  846. /****************give it a class property**********************************/
  847. //get the fully qualified class name
  848. //classes = "\\\\.\\root\\default\\SMIR:MS_SNMP_RFC1213_MIB_atTable";
  849. CString classPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  850. +CString(COLON_STR)
  851. +CString(szClassName));
  852. SysFreeString(szClassName);
  853. V_VT(&v) = VT_BSTR;
  854. V_BSTR(&v)=classPath.AllocSysString();
  855. result = pInst->Put(SMIR_X_ASSOC_CLASS_PROP,RESERVED_WBEM_FLAG, &v,0);
  856. VariantClear(&v);
  857. if (FAILED(result))
  858. {
  859. if ( moContext )
  860. moContext->Release () ;
  861. moServ->Release();
  862. pInst->Release();
  863. return WBEM_E_FAILED;
  864. }
  865. /****************give it a module property**********************************/
  866. //get the fully qualified class name
  867. //module = "\\\\.\\root\\default\\SMIR:Module=\"RFC1213_MIB\"";
  868. CString modPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  869. +CString(COLON_STR)
  870. +CString(MODULE_NAMESPACE_NAME)
  871. +CString(DOT_STR)
  872. +CString(OLEMS_NAME_PROP)
  873. +CString(EQUALS_STR)
  874. +CString(QUOTE_STR)
  875. +CString(szModuleName)
  876. +CString(QUOTE_STR));
  877. V_VT(&v) = VT_BSTR;
  878. V_BSTR(&v)=modPath.AllocSysString();
  879. result = pInst->Put(SMIR_MODULE_ASSOC_MODULE_PROP,RESERVED_WBEM_FLAG, &v,0);
  880. VariantClear(&v);
  881. if (FAILED(result))
  882. {
  883. if ( moContext )
  884. moContext->Release () ;
  885. pInst->Release();
  886. moServ->Release();
  887. return WBEM_E_FAILED;
  888. }
  889. //now save it
  890. result = moServ->PutInstance(pInst, RESERVED_WBEM_FLAG, moContext,NULL);
  891. if ( moContext )
  892. moContext->Release () ;
  893. pInst->Release();
  894. moServ->Release();
  895. /*the query to find the classes is
  896. *associators of {\\.\root\default\SMIR:Module="RFC1213_MIB"}
  897. */
  898. return S_OK;
  899. }
  900. SCODE CModuleToExtNotificationClassAssociator :: Associate(
  901. CSmir *a_Smir,
  902. BSTR szModuleName,
  903. ISmirExtNotificationClassHandle *hClass
  904. )
  905. {
  906. if ((NULL == hClass)||(NULL==szModuleName))
  907. return WBEM_E_FAILED;
  908. IWbemServices * moServ = NULL ;
  909. IWbemContext *moContext = NULL ;
  910. SCODE result= CSmirAccess :: GetContext (a_Smir , &moContext);
  911. //open the root\default\SMIR namespace
  912. CSmirAccess :: Open(a_Smir,&moServ);
  913. //get an object
  914. IWbemClassObject *pClass = NULL ;
  915. CBString t_BStr ( SMIR_MODULE_ASSOC_EXTNCLASS_NAME ) ;
  916. result = moServ->GetObject(t_BStr.GetString (), 0,
  917. moContext,&pClass, NULL);
  918. if ((FAILED(result))||(NULL == pClass))
  919. {
  920. if ( moContext )
  921. moContext->Release () ;
  922. moServ->Release();
  923. return WBEM_E_FAILED;
  924. }
  925. IWbemClassObject *pInst = NULL ;
  926. result = pClass->SpawnInstance ( 0 , &pInst ) ;
  927. pClass->Release ();
  928. if ((FAILED(result))||(NULL==pInst))
  929. {
  930. if ( moContext )
  931. moContext->Release () ;
  932. moServ->Release();
  933. return WBEM_E_FAILED;
  934. }
  935. VARIANT v;
  936. VariantInit(&v);
  937. //Get the class name
  938. result = ((CSmirExtNotificationClassHandle*)hClass)->m_pIMosClass->Get(OLEMS_CLASS_PROP,
  939. RESERVED_WBEM_FLAG, &v,NULL,NULL);
  940. if ((FAILED(result))|(V_VT(&v) != VT_BSTR))
  941. {
  942. if ( moContext )
  943. moContext->Release () ;
  944. moServ->Release();
  945. pInst->Release();
  946. return WBEM_E_FAILED;
  947. }
  948. BSTR szClassName = SysAllocString(V_BSTR(&v));
  949. VariantClear(&v);
  950. /****************give it a Name property**********************************/
  951. V_VT(&v) = VT_BSTR;
  952. CString associationClassName(CString(szClassName)
  953. +CString(SMIR_MODULE_ASSOC_CLASS_NAME_POSTFIX));
  954. V_BSTR(&v)=associationClassName.AllocSysString();
  955. result = pInst->Put(SMIR_X_ASSOC_NAME_PROP,RESERVED_WBEM_FLAG, &v,0);
  956. VariantClear(&v);
  957. if (FAILED(result))
  958. {
  959. if ( moContext )
  960. moContext->Release () ;
  961. SysFreeString(szClassName);
  962. moServ->Release();
  963. pInst->Release();
  964. return WBEM_E_FAILED;
  965. }
  966. /****************give it a class property**********************************/
  967. //get the fully qualified class name
  968. //classes = "\\\\.\\root\\default\\SMIR:MS_SNMP_RFC1213_MIB_atTable";
  969. CString classPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  970. +CString(COLON_STR)
  971. +CString(szClassName));
  972. SysFreeString(szClassName);
  973. V_VT(&v) = VT_BSTR;
  974. V_BSTR(&v)=classPath.AllocSysString();
  975. result = pInst->Put(SMIR_X_ASSOC_CLASS_PROP,RESERVED_WBEM_FLAG, &v,0);
  976. VariantClear(&v);
  977. if (FAILED(result))
  978. {
  979. if ( moContext )
  980. moContext->Release () ;
  981. moServ->Release();
  982. pInst->Release();
  983. return WBEM_E_FAILED;
  984. }
  985. /****************give it a module property**********************************/
  986. //get the fully qualified class name
  987. //module = "\\\\.\\root\\default\\SMIR:Module=\"RFC1213_MIB\"";
  988. CString modPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  989. +CString(COLON_STR)
  990. +CString(MODULE_NAMESPACE_NAME)
  991. +CString(DOT_STR)
  992. +CString(OLEMS_NAME_PROP)
  993. +CString(EQUALS_STR)
  994. +CString(QUOTE_STR)
  995. +CString(szModuleName)
  996. +CString(QUOTE_STR));
  997. V_VT(&v) = VT_BSTR;
  998. V_BSTR(&v)=modPath.AllocSysString();
  999. result = pInst->Put(SMIR_MODULE_ASSOC_MODULE_PROP,RESERVED_WBEM_FLAG, &v,0);
  1000. VariantClear(&v);
  1001. if (FAILED(result))
  1002. {
  1003. if ( moContext )
  1004. moContext->Release () ;
  1005. pInst->Release();
  1006. moServ->Release();
  1007. return WBEM_E_FAILED;
  1008. }
  1009. //now save it
  1010. result = moServ->PutInstance(pInst, RESERVED_WBEM_FLAG, moContext,NULL);
  1011. if ( moContext )
  1012. moContext->Release () ;
  1013. pInst->Release();
  1014. moServ->Release();
  1015. /*the query to find the classes is
  1016. *associators of {\\.\root\default\SMIR:Module="RFC1213_MIB"}
  1017. */
  1018. return S_OK;
  1019. }
  1020. SCODE CSMIRToClassAssociator :: Associate (
  1021. CSmir *a_Smir,
  1022. ISmirClassHandle *hClass
  1023. )
  1024. {
  1025. if (NULL == hClass)
  1026. return WBEM_E_FAILED;
  1027. IWbemServices * moServ = NULL ;
  1028. IWbemContext *moContext = NULL ;
  1029. SCODE result= CSmirAccess :: GetContext (a_Smir , &moContext);
  1030. //open the root\default\SMIR namespace
  1031. CSmirAccess :: Open(a_Smir,&moServ);
  1032. //get an object
  1033. IWbemClassObject *pClass = NULL;
  1034. CBString t_BStr ( SMIR_ASSOC_CLASS_NAME ) ;
  1035. result = moServ->GetObject(t_BStr.GetString () , 0,
  1036. NULL,&pClass, NULL);
  1037. if ((FAILED(result))||(NULL == pClass))
  1038. {
  1039. if ( moContext )
  1040. moContext->Release () ;
  1041. moServ->Release();
  1042. return WBEM_E_FAILED;
  1043. }
  1044. //make an instance
  1045. IWbemClassObject *pInst = NULL ;
  1046. result = pClass->SpawnInstance ( 0 , &pInst ) ;
  1047. pClass->Release ();
  1048. if ((FAILED(result))||(NULL==pInst))
  1049. {
  1050. if ( moContext )
  1051. moContext->Release () ;
  1052. moServ->Release();
  1053. return WBEM_E_FAILED;
  1054. }
  1055. VARIANT v;
  1056. VariantInit(&v);
  1057. //get the class name
  1058. result = ((CSmirClassHandle*)hClass)->m_pIMosClass->Get(OLEMS_CLASS_PROP, RESERVED_WBEM_FLAG, &v,NULL,NULL);
  1059. if ((FAILED(result))|(V_VT(&v) != VT_BSTR))
  1060. {
  1061. if ( moContext )
  1062. moContext->Release () ;
  1063. pInst->Release();
  1064. moServ->Release();
  1065. return WBEM_E_FAILED;
  1066. }
  1067. BSTR szClassName = SysAllocString(V_BSTR(&v));
  1068. VariantClear(&v);
  1069. /****************give it a class property**********************************/
  1070. //get the fully qualified class name
  1071. //classes = "\\\\.\\root\\default\\SMIR:MS_SNMP_RFC1213_MIB_atTable";
  1072. CString classPath(CString(SMIR_NAMESPACE_FROM_ROOT)
  1073. +CString(COLON_STR)
  1074. +CString(szClassName));
  1075. V_VT(&v) = VT_BSTR;
  1076. V_BSTR(&v)=classPath.AllocSysString();
  1077. result = pInst->Put(SMIR_X_ASSOC_CLASS_PROP,RESERVED_WBEM_FLAG, &v,0);
  1078. VariantClear(&v);
  1079. if (FAILED(result))
  1080. {
  1081. if ( moContext )
  1082. moContext->Release () ;
  1083. pInst->Release();
  1084. moServ->Release();
  1085. return WBEM_E_FAILED;
  1086. }
  1087. /****************give it a Name property**********************************/
  1088. V_VT(&v) = VT_BSTR;
  1089. CString associationClassName(CString(szClassName)
  1090. +CString(SMIR_ASSOC_CLASS_NAME_POSTFIX));
  1091. SysFreeString(szClassName);
  1092. V_BSTR(&v)=associationClassName.AllocSysString();
  1093. result = pInst->Put(SMIR_X_ASSOC_NAME_PROP,RESERVED_WBEM_FLAG, &v,0);
  1094. VariantClear(&v);
  1095. if (FAILED(result))
  1096. {
  1097. if ( moContext )
  1098. moContext->Release () ;
  1099. pInst->Release();
  1100. moServ->Release();
  1101. return WBEM_E_FAILED;
  1102. }
  1103. /****************give it a smir property**********************************/
  1104. //get the fully qualified class name
  1105. //smir = "\\\\.\\root\\default\\SMIR";
  1106. CString smirPath(SMIR_CLASS_ASSOCIATION_ENDPOINT);
  1107. V_VT(&v) = VT_BSTR;
  1108. V_BSTR(&v)=smirPath.AllocSysString();
  1109. result = pInst->Put(SMIR_ASSOC_SMIR_PROP,RESERVED_WBEM_FLAG, &v,0);
  1110. VariantClear(&v);
  1111. if (FAILED(result))
  1112. {
  1113. if ( moContext )
  1114. moContext->Release () ;
  1115. pInst->Release();
  1116. moServ->Release();
  1117. return WBEM_E_FAILED;
  1118. }
  1119. //now save it
  1120. result = moServ->PutInstance(pInst, RESERVED_WBEM_FLAG, moContext,NULL);
  1121. if ( moContext )
  1122. moContext->Release () ;
  1123. pInst->Release();
  1124. moServ->Release();
  1125. /*the query to find the classes is
  1126. *associators of {\\.\root\default\SMIR\RFC1316-MIB:Group="charV1ObjectGroup"}
  1127. *or
  1128. *associators of {\\.\root\default\SMIR\RFC1213-MIB:Group="atV1ObjectGroup"}
  1129. */
  1130. return S_OK;
  1131. }
  1132. SCODE CNotificationMapper :: Map (
  1133. CSmir *a_Smir,
  1134. IWbemClassObject *pObj,
  1135. enum NotificationMapperType type
  1136. )
  1137. {
  1138. if (NULL == pObj)
  1139. return WBEM_E_FAILED;
  1140. IWbemServices * moServ = NULL;
  1141. IWbemContext *moContext = NULL ;
  1142. SCODE result= CSmirAccess :: GetContext (a_Smir , &moContext);
  1143. //open the root\default\SMIR namespace
  1144. result = CSmirAccess :: Open(a_Smir,&moServ);
  1145. if ((FAILED(result)) || (NULL == moServ))
  1146. {
  1147. if ( moContext )
  1148. moContext->Release () ;
  1149. return WBEM_E_FAILED;
  1150. }
  1151. //get an object
  1152. IWbemClassObject *pClass = NULL;
  1153. if (SNMP_NOTIFICATION_CLASS == type)
  1154. {
  1155. CBString t_BStr ( SMIR_NOTIFICATION_MAPPER ) ;
  1156. result = moServ->GetObject(t_BStr.GetString (), 0, moContext, &pClass, NULL);
  1157. }
  1158. else if (SNMP_EXT_NOTIFICATION_CLASS == type)
  1159. {
  1160. CBString t_BStr ( SMIR_EXT_NOTIFICATION_MAPPER ) ;
  1161. result = moServ->GetObject(t_BStr.GetString (), 0, moContext,&pClass, NULL);
  1162. }
  1163. if ((FAILED(result))||(NULL == pClass))
  1164. {
  1165. moServ->Release();
  1166. if ( moContext )
  1167. moContext->Release () ;
  1168. return WBEM_E_FAILED;
  1169. }
  1170. IWbemClassObject *pInst = NULL ;
  1171. result = pClass->SpawnInstance ( 0 , &pInst ) ;
  1172. pClass->Release ();
  1173. if ((FAILED(result))||(NULL==pInst))
  1174. {
  1175. if ( moContext )
  1176. moContext->Release () ;
  1177. moServ->Release();
  1178. return WBEM_E_FAILED;
  1179. }
  1180. VARIANT v;
  1181. VariantInit(&v);
  1182. //Get the class name
  1183. result = pObj->Get(OLEMS_CLASS_PROP, RESERVED_WBEM_FLAG, &v, NULL, NULL);
  1184. if ((FAILED(result))|(V_VT(&v) != VT_BSTR))
  1185. {
  1186. if ( moContext )
  1187. moContext->Release () ;
  1188. moServ->Release();
  1189. pInst->Release();
  1190. return WBEM_E_FAILED;
  1191. }
  1192. /****************Set the eventclass property********************************/
  1193. result = pInst->Put(SMIR_NOTIFICATION_CLASS_PROP,RESERVED_WBEM_FLAG, &v,0);
  1194. VariantClear(&v);
  1195. if (FAILED(result))
  1196. {
  1197. if ( moContext )
  1198. moContext->Release () ;
  1199. moServ->Release();
  1200. pInst->Release();
  1201. return WBEM_E_FAILED;
  1202. }
  1203. //Get the trapoid
  1204. result = pObj->Get(TRAPOID_PROP, RESERVED_WBEM_FLAG, &v, NULL, NULL);
  1205. if ((FAILED(result))|(V_VT(&v) != VT_BSTR))
  1206. {
  1207. if ( moContext )
  1208. moContext->Release () ;
  1209. moServ->Release();
  1210. pInst->Release();
  1211. return WBEM_E_FAILED;
  1212. }
  1213. /****************Set the trapoid property********************************/
  1214. result = pInst->Put(SMIR_NOTIFICATION_TRAP_PROP,RESERVED_WBEM_FLAG, &v,0);
  1215. VariantClear(&v);
  1216. if (FAILED(result))
  1217. {
  1218. if ( moContext )
  1219. moContext->Release () ;
  1220. moServ->Release();
  1221. pInst->Release();
  1222. return WBEM_E_FAILED;
  1223. }
  1224. //now save it
  1225. result = moServ->PutInstance(pInst, RESERVED_WBEM_FLAG, moContext,NULL);
  1226. if ( moContext )
  1227. moContext->Release () ;
  1228. pInst->Release();
  1229. moServ->Release();
  1230. return S_OK;
  1231. }