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.

1807 lines
47 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // TaskCompareAndPushInformation.cpp
  7. //
  8. // Description:
  9. // CTaskCompareAndPushInformation implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 21-MAR-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "TaskCompareAndPushInformation.h"
  17. #include "ManagedResource.h"
  18. #include "ManagedNetwork.h"
  19. DEFINE_THISCLASS("CTaskCompareAndPushInformation")
  20. // ************************************************************************
  21. //
  22. // Constructor / Destructor
  23. //
  24. // ************************************************************************
  25. //////////////////////////////////////////////////////////////////////////////
  26. //
  27. // HRESULT
  28. // CTaskCompareAndPushInformation::S_HrCreateInstance(
  29. // IUnknown ** ppunkOut
  30. // )
  31. //
  32. //////////////////////////////////////////////////////////////////////////////
  33. HRESULT
  34. CTaskCompareAndPushInformation::S_HrCreateInstance(
  35. IUnknown ** ppunkOut
  36. )
  37. {
  38. TraceFunc( "" );
  39. HRESULT hr = S_OK;
  40. CTaskCompareAndPushInformation * ptcapi = NULL;
  41. Assert( ppunkOut != NULL );
  42. if ( ppunkOut == NULL )
  43. {
  44. hr = THR( E_POINTER );
  45. goto Cleanup;
  46. }
  47. ptcapi = new CTaskCompareAndPushInformation;
  48. if ( ptcapi == NULL )
  49. {
  50. hr = THR( E_OUTOFMEMORY );
  51. goto Cleanup;
  52. }
  53. hr = THR( ptcapi->HrInit() );
  54. if ( FAILED( hr ) )
  55. {
  56. goto Cleanup;
  57. }
  58. hr = THR( ptcapi->TypeSafeQI( IUnknown, ppunkOut ) );
  59. if ( FAILED( hr ) )
  60. {
  61. goto Cleanup;
  62. }
  63. Cleanup:
  64. if ( ptcapi != NULL )
  65. {
  66. ptcapi->Release();
  67. }
  68. HRETURN( hr );
  69. } //*** CTaskCompareAndPushInformation::S_HrCreateInstance
  70. //////////////////////////////////////////////////////////////////////////////
  71. //
  72. // CTaskCompareAndPushInformation::CTaskCompareAndPushInformation
  73. //
  74. //////////////////////////////////////////////////////////////////////////////
  75. CTaskCompareAndPushInformation::CTaskCompareAndPushInformation( void )
  76. : m_cRef( 1 )
  77. {
  78. TraceFunc( "" );
  79. InterlockedIncrement( &g_cObjects );
  80. TraceFuncExit();
  81. } //*** CTaskCompareAndPushInformation::CTaskCompareAndPushInformation
  82. //////////////////////////////////////////////////////////////////////////////
  83. //
  84. // STDMETHODIMP
  85. // CTaskCompareAndPushInformation::HrInit
  86. //
  87. //////////////////////////////////////////////////////////////////////////////
  88. STDMETHODIMP
  89. CTaskCompareAndPushInformation::HrInit( void )
  90. {
  91. TraceFunc( "" );
  92. HRESULT hr = S_OK;
  93. // IUnknown stuff
  94. Assert( m_cRef == 1 );
  95. // IDoTask / ITaskCompareAndPushInformation
  96. Assert( m_cookieCompletion == NULL );
  97. Assert( m_cookieNode == NULL );
  98. Assert( m_pcccb == NULL );
  99. Assert( m_pom == NULL );
  100. Assert( m_hrStatus == S_OK );
  101. Assert( m_bstrNodeName == NULL );
  102. Assert( m_fStop == FALSE );
  103. HRETURN( hr );
  104. } //*** CTaskCompareAndPushInformation::HrInit
  105. //////////////////////////////////////////////////////////////////////////////
  106. //
  107. // CTaskCompareAndPushInformation::~CTaskCompareAndPushInformation
  108. //
  109. //////////////////////////////////////////////////////////////////////////////
  110. CTaskCompareAndPushInformation::~CTaskCompareAndPushInformation()
  111. {
  112. TraceFunc( "" );
  113. if ( m_pcccb != NULL )
  114. {
  115. m_pcccb->Release();
  116. }
  117. if ( m_pom != NULL )
  118. {
  119. m_pom->Release();
  120. }
  121. TraceSysFreeString( m_bstrNodeName );
  122. InterlockedDecrement( &g_cObjects );
  123. TraceFuncExit();
  124. } //*** CTaskCompareAndPushInformation::~CTaskCompareAndPushInformation
  125. // ************************************************************************
  126. //
  127. // IUnknown
  128. //
  129. // ************************************************************************
  130. //////////////////////////////////////////////////////////////////////////////
  131. //++
  132. //
  133. // CTaskCompareAndPushInformation::QueryInterface
  134. //
  135. // Description:
  136. // Query this object for the passed in interface.
  137. //
  138. // Arguments:
  139. // riidIn
  140. // Id of interface requested.
  141. //
  142. // ppvOut
  143. // Pointer to the requested interface.
  144. //
  145. // Return Value:
  146. // S_OK
  147. // If the interface is available on this object.
  148. //
  149. // E_NOINTERFACE
  150. // If the interface is not available.
  151. //
  152. // E_POINTER
  153. // ppvOut was NULL.
  154. //
  155. // Remarks:
  156. // None.
  157. //
  158. //--
  159. //////////////////////////////////////////////////////////////////////////////
  160. STDMETHODIMP
  161. CTaskCompareAndPushInformation::QueryInterface(
  162. REFIID riidIn
  163. , LPVOID * ppvOut
  164. )
  165. {
  166. TraceQIFunc( riidIn, ppvOut );
  167. HRESULT hr = S_OK;
  168. //
  169. // Validate arguments.
  170. //
  171. Assert( ppvOut != NULL );
  172. if ( ppvOut == NULL )
  173. {
  174. hr = THR( E_POINTER );
  175. goto Cleanup;
  176. }
  177. //
  178. // Handle known interfaces.
  179. //
  180. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  181. {
  182. *ppvOut = static_cast< ITaskCompareAndPushInformation * >( this );
  183. } // if: IUnknown
  184. else if ( IsEqualIID( riidIn, IID_IDoTask ) )
  185. {
  186. *ppvOut = TraceInterface( __THISCLASS__, IDoTask, this, 0 );
  187. } // else if: IDoTask
  188. else if ( IsEqualIID( riidIn, IID_ITaskCompareAndPushInformation ) )
  189. {
  190. *ppvOut = TraceInterface( __THISCLASS__, ITaskCompareAndPushInformation, this, 0 );
  191. } // else if: ITaskCompareAndPushInformation
  192. else
  193. {
  194. *ppvOut = NULL;
  195. hr = E_NOINTERFACE;
  196. }
  197. //
  198. // Add a reference to the interface if successful.
  199. //
  200. if ( SUCCEEDED( hr ) )
  201. {
  202. ((IUnknown *) *ppvOut)->AddRef();
  203. } // if: success
  204. Cleanup:
  205. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  206. } //*** CTaskCompareAndPushInformation::QueryInterface
  207. //////////////////////////////////////////////////////////////////////////////
  208. //
  209. // STDMETHODIMP_(ULONG)
  210. // CTaskCompareAndPushInformation::AddRef
  211. //
  212. //////////////////////////////////////////////////////////////////////////////
  213. STDMETHODIMP_( ULONG )
  214. CTaskCompareAndPushInformation::AddRef( void )
  215. {
  216. TraceFunc( "[IUnknown]" );
  217. InterlockedIncrement( &m_cRef );
  218. CRETURN( m_cRef );
  219. } //*** CTaskCompareAndPushInformation::AddRef
  220. //////////////////////////////////////////////////////////////////////////////
  221. //
  222. // STDMETHODIMP_(ULONG)
  223. // CTaskCompareAndPushInformation::Release
  224. //
  225. //////////////////////////////////////////////////////////////////////////////
  226. STDMETHODIMP_( ULONG )
  227. CTaskCompareAndPushInformation::Release( void )
  228. {
  229. TraceFunc( "[IUnknown]" );
  230. LONG cRef;
  231. cRef = InterlockedDecrement( &m_cRef );
  232. if ( cRef == 0 )
  233. {
  234. TraceDo( delete this );
  235. }
  236. CRETURN( cRef );
  237. } //*** CTaskCompareAndPushInformation::Release
  238. //****************************************************************************
  239. //
  240. // ITaskCompareAndPushInformation
  241. //
  242. //****************************************************************************
  243. //////////////////////////////////////////////////////////////////////////////
  244. //
  245. // STDMETHODIMP
  246. // CTaskCompareAndPushInformation::BeginTask
  247. //
  248. //////////////////////////////////////////////////////////////////////////////
  249. STDMETHODIMP
  250. CTaskCompareAndPushInformation::BeginTask( void )
  251. {
  252. TraceFunc( "[IDoTask]" );
  253. HRESULT hr;
  254. ULONG celt;
  255. ULONG celtDummy;
  256. OBJECTCOOKIE cookieCluster;
  257. OBJECTCOOKIE cookieDummy;
  258. BSTR bstrNotification = NULL;
  259. BSTR bstrRemote = NULL; // reused many times
  260. BSTR bstrLocal = NULL; // reused many times
  261. ULONG celtFetched = 0;
  262. IServiceProvider * psp = NULL;
  263. IUnknown * punk = NULL;
  264. IConnectionPointContainer * pcpc = NULL;
  265. IConnectionPoint * pcp = NULL;
  266. IConnectionManager * pcm = NULL;
  267. IClusCfgServer * pccs = NULL;
  268. IStandardInfo * psi = NULL;
  269. INotifyUI * pnui = NULL;
  270. IEnumClusCfgNetworks * peccnLocal = NULL;
  271. IEnumClusCfgNetworks * peccnRemote = NULL;
  272. IEnumClusCfgManagedResources * peccmrLocal = NULL;
  273. IEnumClusCfgManagedResources * peccmrRemote = NULL;
  274. IClusCfgManagedResourceInfo * pccmri[ 10 ] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
  275. IClusCfgManagedResourceInfo * pccmriLocal = NULL;
  276. IClusCfgNetworkInfo * pccni[ 10 ] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
  277. IClusCfgNetworkInfo * pccniLocal = NULL;
  278. TraceInitializeThread( L"TaskCompareAndPushInformation" );
  279. //
  280. // Gather the manager we need to complete our tasks.
  281. //
  282. hr = THR( CoCreateInstance( CLSID_ServiceManager, NULL, CLSCTX_SERVER, TypeSafeParams( IServiceProvider, &psp ) ) );
  283. if ( FAILED( hr ) )
  284. {
  285. goto Cleanup;
  286. } // if:
  287. hr = THR( psp->TypeSafeQS( CLSID_ObjectManager, IObjectManager, &m_pom ) );
  288. if ( FAILED( hr ) )
  289. {
  290. goto Cleanup;
  291. } // if:
  292. hr = THR( psp->TypeSafeQS( CLSID_NotificationManager, IConnectionPointContainer, &pcpc ) );
  293. if ( FAILED( hr ) )
  294. {
  295. goto Cleanup;
  296. } // if:
  297. pcpc = TraceInterface( L"CTaskCompareAndPushInformation!IConnectionPointContainer", IConnectionPointContainer, pcpc, 1 );
  298. hr = THR( pcpc->FindConnectionPoint( IID_INotifyUI, &pcp ) );
  299. if ( FAILED( hr ) )
  300. {
  301. goto Cleanup;
  302. } // if:
  303. pcp = TraceInterface( L"CTaskCompareAndPushInformation!IConnectionPoint", IConnectionPoint, pcp, 1 );
  304. hr = THR( pcp->TypeSafeQI( INotifyUI, &pnui ) );
  305. if ( FAILED( hr ) )
  306. {
  307. goto Cleanup;
  308. } // if:
  309. pnui = TraceInterface( L"CTaskCompareAndPushInformation!INotifyUI", INotifyUI, pnui, 1 );
  310. hr = THR( psp->TypeSafeQS( CLSID_ClusterConnectionManager, IConnectionManager, &pcm ) );
  311. if ( FAILED( hr ) )
  312. {
  313. goto Cleanup;
  314. } // if:
  315. psp->Release(); // release promptly
  316. psp = NULL;
  317. //
  318. // Ask the object manager for the name of the node.
  319. //
  320. hr = THR( m_pom->GetObject( DFGUID_StandardInfo, m_cookieNode, &punk ) );
  321. if ( FAILED( hr ) )
  322. {
  323. goto Cleanup;
  324. } // if:
  325. hr = THR( punk->TypeSafeQI( IStandardInfo, &psi ) );
  326. if ( FAILED( hr ) )
  327. {
  328. goto Cleanup;
  329. } // if:
  330. psi = TraceInterface( L"TaskCompareAndPushInformation!IStandardInfo", IStandardInfo, psi, 1 );
  331. punk->Release();
  332. punk = NULL;
  333. hr = THR( psi->GetName( &m_bstrNodeName ) );
  334. if ( FAILED( hr ) )
  335. {
  336. goto Cleanup;
  337. } // if:
  338. TraceMemoryAddBSTR( m_bstrNodeName );
  339. // done with it.
  340. psi->Release();
  341. psi = NULL;
  342. LogMsg( L"[MT] [CTaskCompareAndPushInformation] Beginning task for node %ws...", m_bstrNodeName );
  343. hr = THR( HrSendStatusReport(
  344. TASKID_Major_Reanalyze
  345. , TASKID_Minor_Comparing_Configuration
  346. , 0
  347. , 1
  348. , 0
  349. , S_OK
  350. , IDS_TASKID_MINOR_COMPARING_CONFIGURATION
  351. ) );
  352. if ( FAILED( hr ) )
  353. {
  354. goto Cleanup;
  355. } // if:
  356. //
  357. // Ask the connection manager for a connection to the node.
  358. //
  359. hr = THR( pcm->GetConnectionToObject( m_cookieNode, &punk ) );
  360. if ( FAILED( hr ) )
  361. {
  362. goto Error;
  363. } // if:
  364. hr = THR( punk->TypeSafeQI( IClusCfgServer, &pccs ) );
  365. if ( FAILED( hr ) )
  366. {
  367. goto Error;
  368. } // if:
  369. punk->Release();
  370. punk = NULL;
  371. //
  372. // Figure out the parent cluster of the node.
  373. //
  374. hr = THR( m_pom->GetObject( DFGUID_StandardInfo, m_cookieNode, &punk ) );
  375. if ( FAILED( hr ) )
  376. {
  377. goto Error;
  378. } // if:
  379. hr = THR( punk->TypeSafeQI( IStandardInfo, &psi ) );
  380. if ( FAILED( hr ) )
  381. {
  382. goto Error;
  383. } // if:
  384. psi = TraceInterface( L"TaskCompareAndPushInformation!IStandardInfo", IStandardInfo, psi, 1 );
  385. punk->Release();
  386. punk = NULL;
  387. hr = THR( psi->GetParent( &cookieCluster ) );
  388. if ( FAILED( hr ) )
  389. {
  390. goto Error;
  391. } // if:
  392. hr = THR( HrVerifyCredentials( pccs, cookieCluster ) );
  393. if ( FAILED( hr ) )
  394. {
  395. goto Error;
  396. } // if:
  397. //
  398. // Tell the UI layer we're starting to gather the resources. There are two steps, managed resources and networks.
  399. //
  400. hr = THR( HrSendStatusReport(
  401. TASKID_Minor_Comparing_Configuration
  402. , TASKID_Minor_Gathering_Managed_Devices
  403. , 0
  404. , 2
  405. , 0
  406. , S_OK
  407. , IDS_TASKID_MINOR_GATHERING_MANAGED_DEVICES
  408. ) );
  409. if ( FAILED( hr ) )
  410. {
  411. goto Cleanup;
  412. } // if:
  413. //
  414. // Ask the connection for the enumer for managed resources.
  415. //
  416. hr = THR( pccs->GetManagedResourcesEnum( &peccmrRemote ) );
  417. if ( FAILED( hr ) )
  418. {
  419. goto Error;
  420. } // if:
  421. peccmrRemote = TraceInterface( L"CTaskCompareAndPushInformation!GetManagedResourceEnum", IEnumClusCfgManagedResources, peccmrRemote, 1 );
  422. //
  423. // Ask the Object Manager for the enumer for managed resources.
  424. //
  425. // Don't wrap - this can fail.
  426. hr = m_pom->FindObject( CLSID_ManagedResourceType,
  427. cookieCluster,
  428. NULL,
  429. DFGUID_EnumManageableResources,
  430. &cookieDummy,
  431. &punk
  432. );
  433. if ( hr == HRESULT_FROM_WIN32( ERROR_NOT_FOUND ) )
  434. {
  435. goto PushNetworks;
  436. }
  437. if ( FAILED( hr ) )
  438. {
  439. Assert( punk == NULL );
  440. THR( hr );
  441. goto Error;
  442. }
  443. hr = THR( punk->TypeSafeQI( IEnumClusCfgManagedResources, &peccmrLocal ) );
  444. if ( FAILED( hr ) )
  445. {
  446. goto Error;
  447. }
  448. peccmrLocal = TraceInterface( L"CTaskCompareAndPushInformation!IEnumClusCfgManagedResources", IEnumClusCfgManagedResources, peccmrLocal, 1 );
  449. punk->Release();
  450. punk = NULL;
  451. //
  452. // Enumerate the next 10 resources.
  453. //
  454. for( ; m_fStop == FALSE; )
  455. {
  456. //
  457. // Get next remote managed resource(s).
  458. //
  459. hr = STHR( peccmrRemote->Next( 10, pccmri, &celtFetched ) );
  460. if ( hr == S_FALSE && celtFetched == 0 )
  461. {
  462. break; // exit loop
  463. }
  464. if ( FAILED( hr ) )
  465. {
  466. goto Error;
  467. }
  468. //
  469. // Loop thru the resource gather information out of each of them
  470. // and then release them.
  471. //
  472. for( celt = 0; ( ( celt < celtFetched ) && ( m_fStop == FALSE ) ); celt ++ )
  473. {
  474. DWORD dwLenRemote;
  475. //
  476. // Error
  477. //
  478. TraceSysFreeString( bstrRemote );
  479. bstrRemote = NULL;
  480. Assert( pccmri[ celt ] != NULL );
  481. //
  482. // Get the UID of the remote resource.
  483. //
  484. hr = THR( pccmri[ celt ]->GetUID( &bstrRemote ) );
  485. if ( FAILED( hr ) )
  486. {
  487. goto Error;
  488. }
  489. TraceMemoryAddBSTR( bstrRemote );
  490. dwLenRemote = SysStringByteLen( bstrRemote );
  491. //
  492. // Try to match this resource with one in the object manager.
  493. //
  494. hr = THR( peccmrLocal->Reset() );
  495. if ( FAILED( hr ) )
  496. {
  497. goto Error;
  498. } // if:
  499. for( ; m_fStop == FALSE; )
  500. {
  501. DWORD dwLenLocal;
  502. //
  503. // Cleanup
  504. //
  505. if ( pccmriLocal != NULL )
  506. {
  507. pccmriLocal->Release();
  508. pccmriLocal = NULL;
  509. } // if:
  510. TraceSysFreeString( bstrLocal );
  511. bstrLocal = NULL;
  512. //
  513. // Get next local managed resource.
  514. //
  515. hr = STHR( peccmrLocal->Next( 1, &pccmriLocal, &celtDummy ) );
  516. if ( hr == S_FALSE )
  517. {
  518. //
  519. // If we exhausted all the devices but did not match the device
  520. // in our cluster configuration, this means something changed
  521. // on the remote node. Send up an error!
  522. //
  523. //
  524. // TODO: gpease 24-MAR-2000
  525. // Find a better error code and SendStatusReport!
  526. //
  527. hr = THR( ERROR_RESOURCE_NOT_FOUND );
  528. goto Error;
  529. }
  530. if ( FAILED( hr ) )
  531. {
  532. goto Error;
  533. }
  534. hr = THR( pccmriLocal->GetUID( &bstrLocal ) );
  535. if ( FAILED( hr ) )
  536. {
  537. goto Error;
  538. }
  539. TraceMemoryAddBSTR( bstrLocal );
  540. dwLenLocal = SysStringByteLen( bstrLocal );
  541. if ( dwLenRemote == dwLenLocal
  542. && memcmp( bstrRemote, bstrLocal, dwLenLocal ) == 0
  543. )
  544. {
  545. Assert( hr == S_OK );
  546. break; // match!
  547. }
  548. } // for: local managed resources...
  549. TraceSysFreeString( bstrLocal );
  550. bstrLocal = NULL;
  551. TraceSysFreeString( bstrRemote );
  552. bstrRemote = NULL;
  553. //
  554. // If we made it here, we have a resource in pccmriLocal that matches
  555. // the resource in pccmri[ celt ].
  556. //
  557. Assert( pccmriLocal != NULL );
  558. //
  559. //
  560. // Push the data down to the node.
  561. //
  562. //
  563. //
  564. // Update the name (if needed).
  565. //
  566. hr = THR( pccmriLocal->GetName( &bstrLocal ) );
  567. if ( FAILED( hr ) )
  568. {
  569. goto Error;
  570. }
  571. TraceMemoryAddBSTR( bstrLocal );
  572. hr = THR( pccmri[ celt ]->GetName( &bstrRemote ) );
  573. if ( FAILED( hr ) )
  574. {
  575. goto Error;
  576. }
  577. TraceMemoryAddBSTR( bstrRemote );
  578. if ( NBSTRCompareCase( bstrLocal, bstrRemote ) != 0 )
  579. {
  580. hr = STHR( pccmri[ celt ]->SetName( bstrLocal ) );
  581. if ( FAILED( hr ) )
  582. {
  583. goto Error;
  584. }
  585. }
  586. //
  587. // Update IsManaged?
  588. //
  589. hr = STHR( pccmriLocal->IsManaged() );
  590. if ( FAILED( hr ) )
  591. {
  592. goto Error;
  593. }
  594. hr = STHR( pccmri[ celt ]->SetManaged( hr == S_OK ) );
  595. if ( FAILED( hr ) )
  596. {
  597. goto Error;
  598. }
  599. //
  600. // I'm not sure that we want to send this back down to the server side object.
  601. // It is its responsibility to know whether or not it is manageable.
  602. //
  603. /*
  604. //
  605. // Update IsManageable?
  606. //
  607. hr = STHR( pccmriLocal->IsManageable() );
  608. if ( FAILED( hr ) )
  609. goto Error;
  610. hr = THR( pccmri[ celt ]->SetManageable( hr == S_OK ) );
  611. if ( FAILED( hr ) )
  612. goto Error;
  613. */
  614. //
  615. // Update IsQuorum?
  616. //
  617. hr = STHR( pccmriLocal->IsQuorumResource() );
  618. if ( FAILED( hr ) )
  619. {
  620. goto Error;
  621. }
  622. hr = THR( pccmri[ celt ]->SetQuorumResource( hr == S_OK ) );
  623. if ( FAILED( hr ) )
  624. {
  625. goto Error;
  626. }
  627. //
  628. // Update private resource data
  629. //
  630. hr = THR( HrExchangePrivateData( pccmriLocal, pccmri[ celt ] ) );
  631. if ( FAILED( hr ) )
  632. {
  633. goto Error;
  634. } // if:
  635. //
  636. // Update DriveLetterMappings
  637. //
  638. //
  639. // KB: gpease 31-JUL-2000
  640. // We currently don't support setting the drive letter mappings
  641. //
  642. // release the interface
  643. pccmri[ celt ]->Release();
  644. pccmri[ celt ] = NULL;
  645. } // for: celt
  646. //
  647. // Need to cleanup from the last iteration...
  648. //
  649. TraceSysFreeString( bstrRemote );
  650. bstrRemote = NULL;
  651. TraceSysFreeString( bstrLocal );
  652. bstrLocal = NULL;
  653. } // for: hr
  654. PushNetworks:
  655. if ( m_fStop == TRUE )
  656. {
  657. goto Error;
  658. } // if:
  659. #if defined(DEBUG)
  660. //
  661. // Make sure the strings are really freed after exitting the loop.
  662. //
  663. Assert( bstrLocal == NULL );
  664. Assert( bstrRemote == NULL );
  665. #endif // DEBUG
  666. //
  667. // Tell the UI layer we're done will gathering the managed resources.
  668. //
  669. hr = THR( HrSendStatusReport(
  670. TASKID_Minor_Comparing_Configuration
  671. , TASKID_Minor_Gathering_Managed_Devices
  672. , 0
  673. , 2
  674. , 1
  675. , S_OK
  676. , IDS_TASKID_MINOR_GATHERING_MANAGED_DEVICES
  677. ) );
  678. if ( FAILED( hr ) )
  679. {
  680. goto Cleanup;
  681. } // if:
  682. //
  683. // Now gather the networks from the node.
  684. //
  685. //
  686. // Ask the connection for the enumer for the networks.
  687. //
  688. hr = THR( pccs->GetNetworksEnum( &peccnRemote ) );
  689. if ( FAILED( hr ) )
  690. {
  691. goto Error;
  692. }
  693. //
  694. // Ask the Object Manager for the enumer for managed resources.
  695. //
  696. hr = THR( m_pom->FindObject( CLSID_NetworkType,
  697. NULL,
  698. NULL,
  699. DFGUID_EnumManageableNetworks,
  700. &cookieDummy,
  701. &punk
  702. ) );
  703. if ( FAILED( hr ) )
  704. {
  705. goto Error;
  706. }
  707. hr = THR( punk->TypeSafeQI( IEnumClusCfgNetworks, &peccnLocal ) );
  708. if ( FAILED( hr ) )
  709. {
  710. goto Error;
  711. }
  712. punk->Release();
  713. punk = NULL;
  714. //
  715. // Enumerate the next 10 networks.
  716. //
  717. for( ; m_fStop == FALSE; )
  718. {
  719. //
  720. // Get the next 10 networks.
  721. //
  722. hr = STHR( peccnRemote->Next( 10, pccni, &celtFetched ) );
  723. if ( hr == S_FALSE && celtFetched == 0 )
  724. {
  725. break; // exit loop
  726. }
  727. if ( FAILED( hr ) )
  728. {
  729. goto Error;
  730. }
  731. //
  732. // Loop thru the networks gather information out of each of them
  733. // and then release them.
  734. //
  735. for( celt = 0; ( ( celt < celtFetched ) && ( m_fStop == FALSE ) ); celt ++ )
  736. {
  737. DWORD dwLenRemote;
  738. //
  739. // Error
  740. //
  741. TraceSysFreeString( bstrRemote );
  742. bstrRemote = NULL;
  743. //
  744. // Get the UID of the remote network.
  745. //
  746. hr = THR( pccni[ celt ]->GetUID( &bstrRemote ) );
  747. if ( FAILED( hr ) )
  748. {
  749. goto Error;
  750. }
  751. TraceMemoryAddBSTR( bstrRemote );
  752. dwLenRemote = SysStringByteLen( bstrRemote );
  753. //
  754. // Try to match this resource with one in the object manager.
  755. //
  756. hr = THR( peccnLocal->Reset() );
  757. if ( FAILED( hr ) )
  758. {
  759. goto Error;
  760. } // if:
  761. for ( ; m_fStop == FALSE; )
  762. {
  763. DWORD dwLenLocal;
  764. //
  765. // Cleanup before next pass...
  766. //
  767. if ( pccniLocal != NULL )
  768. {
  769. pccniLocal->Release();
  770. pccniLocal = NULL;
  771. } // if:
  772. TraceSysFreeString( bstrLocal );
  773. bstrLocal = NULL;
  774. //
  775. // Get next network from the cluster configuration.
  776. //
  777. hr = STHR( peccnLocal->Next( 1, &pccniLocal, &celtDummy ) );
  778. if ( hr == S_FALSE )
  779. {
  780. break;
  781. }
  782. if ( FAILED( hr ) )
  783. {
  784. goto Error;
  785. }
  786. hr = THR( pccniLocal->GetUID( &bstrLocal ) );
  787. if ( FAILED( hr ) )
  788. {
  789. goto Error;
  790. }
  791. TraceMemoryAddBSTR( bstrLocal );
  792. dwLenLocal = SysStringByteLen( bstrLocal );
  793. if ( dwLenRemote == dwLenLocal
  794. && memcmp( bstrRemote, bstrLocal, dwLenLocal ) == 0
  795. )
  796. {
  797. Assert( hr == S_OK );
  798. break; // match!
  799. }
  800. } // for: hr
  801. TraceSysFreeString( bstrLocal );
  802. bstrLocal = NULL;
  803. TraceSysFreeString( bstrRemote );
  804. bstrRemote = NULL;
  805. //
  806. // If we come out of the loop with S_FALSE, that means the
  807. // node has a resource that we did not see during the analysis.
  808. // Send up an error.
  809. //
  810. if ( hr == S_FALSE )
  811. {
  812. LogMsg( L"[MT] Found a resource that was not found during analysis." );
  813. hr = S_OK;
  814. continue;
  815. }
  816. //
  817. // If we made it here, we have a resource in pccniLocal that matches
  818. // the resource in pccmri[ celt ].
  819. //
  820. Assert( pccniLocal != NULL );
  821. //
  822. //
  823. // Push the data down to the node.
  824. //
  825. //
  826. //
  827. // Set Name
  828. //
  829. hr = THR( pccniLocal->GetName( &bstrLocal ) );
  830. if ( FAILED( hr ) )
  831. {
  832. goto Error;
  833. }
  834. TraceMemoryAddBSTR( bstrLocal );
  835. hr = THR( pccni[ celt ]->GetName( &bstrRemote ) );
  836. if ( FAILED( hr ) )
  837. {
  838. goto Error;
  839. }
  840. TraceMemoryAddBSTR( bstrRemote );
  841. if ( NBSTRCompareCase( bstrLocal, bstrRemote ) != 0 )
  842. {
  843. hr = STHR( pccni[ celt ]->SetName( bstrLocal ) );
  844. if ( FAILED( hr ) )
  845. {
  846. goto Error;
  847. }
  848. }
  849. TraceSysFreeString( bstrLocal );
  850. bstrLocal = NULL;
  851. TraceSysFreeString( bstrRemote );
  852. bstrRemote = NULL;
  853. //
  854. // Set Description
  855. //
  856. hr = THR( pccniLocal->GetDescription( &bstrLocal ) );
  857. if ( FAILED( hr ) )
  858. {
  859. goto Error;
  860. }
  861. TraceMemoryAddBSTR( bstrLocal );
  862. hr = THR( pccni[ celt ]->GetDescription( &bstrRemote ) );
  863. if ( FAILED( hr ) )
  864. {
  865. goto Error;
  866. }
  867. TraceMemoryAddBSTR( bstrRemote );
  868. if ( NBSTRCompareCase( bstrLocal, bstrRemote ) != 0 )
  869. {
  870. hr = STHR( pccni[ celt ]->SetDescription( bstrLocal ) );
  871. if ( FAILED( hr ) )
  872. {
  873. goto Error;
  874. }
  875. }
  876. TraceSysFreeString( bstrLocal );
  877. bstrLocal = NULL;
  878. TraceSysFreeString( bstrRemote );
  879. bstrRemote = NULL;
  880. //
  881. // KB: gpease 31-JUL-2000
  882. // We don't support reconfiguring the IP Address remotely because
  883. // our connection to the server will be cut when the IP stack on
  884. // the remote machine reconfigs.
  885. //
  886. //
  887. // Set IsPublic?
  888. //
  889. hr = STHR( pccniLocal->IsPublic() );
  890. if ( FAILED( hr ) )
  891. {
  892. goto Error;
  893. }
  894. hr = STHR( pccni[ celt ]->SetPublic( hr == S_OK ) );
  895. if ( FAILED( hr ) )
  896. {
  897. goto Error;
  898. }
  899. //
  900. // Set IsPrivate?
  901. //
  902. hr = STHR( pccniLocal->IsPrivate() );
  903. if ( FAILED( hr ) )
  904. {
  905. goto Error;
  906. }
  907. hr = STHR( pccni[ celt ]->SetPrivate( hr == S_OK ) );
  908. if ( FAILED( hr ) )
  909. {
  910. goto Error;
  911. }
  912. // release the interface
  913. pccni[ celt ]->Release();
  914. pccni[ celt ] = NULL;
  915. } // for: celt
  916. } // for: hr
  917. //
  918. // Tell the UI that we are done gathering managed resources and networks.
  919. //
  920. hr = THR( HrSendStatusReport(
  921. TASKID_Minor_Comparing_Configuration
  922. , TASKID_Minor_Gathering_Managed_Devices
  923. , 0
  924. , 2
  925. , 2
  926. , S_OK
  927. , IDS_TASKID_MINOR_GATHERING_MANAGED_DEVICES
  928. ) );
  929. if ( FAILED( hr ) )
  930. {
  931. goto Cleanup;
  932. } // if:
  933. #if defined(DEBUG)
  934. //
  935. // Make sure the strings are really freed after exitting the loop.
  936. //
  937. Assert( bstrLocal == NULL );
  938. Assert( bstrRemote == NULL );
  939. #endif // DEBUG
  940. hr = S_OK;
  941. Error:
  942. //
  943. // Tell the UI layer we're done comparing configurations and what the resulting
  944. // status was.
  945. //
  946. THR( HrSendStatusReport(
  947. TASKID_Major_Reanalyze
  948. , TASKID_Minor_Comparing_Configuration
  949. , 0
  950. , 1
  951. , 1
  952. , hr
  953. , IDS_TASKID_MINOR_COMPARING_CONFIGURATION
  954. ) );
  955. Cleanup:
  956. if ( psp != NULL )
  957. {
  958. psp->Release();
  959. } // if:
  960. TraceSysFreeString( bstrNotification );
  961. TraceSysFreeString( bstrRemote );
  962. TraceSysFreeString( bstrLocal );
  963. if ( punk != NULL )
  964. {
  965. punk->Release();
  966. }
  967. if ( m_pom != NULL )
  968. {
  969. HRESULT hr2;
  970. IUnknown * punkTemp = NULL;
  971. hr2 = THR( m_pom->GetObject( DFGUID_StandardInfo, m_cookieCompletion, &punkTemp ) );
  972. if ( SUCCEEDED( hr2 ) )
  973. {
  974. IStandardInfo * psiTemp = NULL;
  975. hr2 = THR( punkTemp->TypeSafeQI( IStandardInfo, &psiTemp ) );
  976. punkTemp->Release();
  977. punkTemp = NULL;
  978. if ( SUCCEEDED( hr2 ) )
  979. {
  980. hr2 = THR( psiTemp->SetStatus( hr ) );
  981. psiTemp->Release();
  982. psiTemp = NULL;
  983. }
  984. } // if: ( SUCCEEDED( hr2 ) )
  985. } // if: ( m_pom != NULL )
  986. if ( pcpc != NULL )
  987. {
  988. pcpc->Release();
  989. }
  990. if ( pcp != NULL )
  991. {
  992. pcp->Release();
  993. }
  994. if ( pcm != NULL )
  995. {
  996. pcm->Release();
  997. }
  998. if ( pccs != NULL )
  999. {
  1000. pccs->Release();
  1001. }
  1002. if ( psi != NULL )
  1003. {
  1004. psi->Release();
  1005. }
  1006. if ( pnui != NULL )
  1007. {
  1008. HRESULT hrTemp;
  1009. LogMsg( L"[TaskCompareAndPushInformation] Sending the completion cookie %ld for node %ws to the notification manager because this task is complete.", m_cookieCompletion, m_bstrNodeName );
  1010. hrTemp = THR( pnui->ObjectChanged( m_cookieCompletion ) );
  1011. if ( FAILED( hrTemp ) )
  1012. {
  1013. LogMsg( L"[TaskCompareAndPushInformation] Error sending the completion cookie %ld for node %ws to the notification manager because this task is complete. (hr=%#08x)", m_cookieCompletion, m_bstrNodeName, hrTemp );
  1014. } // if:
  1015. pnui->Release();
  1016. }
  1017. if ( peccnLocal != NULL )
  1018. {
  1019. peccnLocal->Release();
  1020. }
  1021. if ( peccnRemote != NULL )
  1022. {
  1023. peccnRemote->Release();
  1024. }
  1025. if ( peccmrLocal != NULL )
  1026. {
  1027. peccmrLocal->Release();
  1028. }
  1029. if ( peccmrRemote != NULL )
  1030. {
  1031. peccmrRemote->Release();
  1032. }
  1033. for( celt = 0; celt < 10; celt ++ )
  1034. {
  1035. if ( pccmri[ celt ] != NULL )
  1036. {
  1037. pccmri[ celt ]->Release();
  1038. }
  1039. if ( pccni[ celt ] != NULL )
  1040. {
  1041. pccni[ celt ]->Release();
  1042. }
  1043. } // for: celt
  1044. if ( pccmriLocal != NULL )
  1045. {
  1046. pccmriLocal->Release();
  1047. }
  1048. if ( pccniLocal != NULL )
  1049. {
  1050. pccniLocal->Release();
  1051. }
  1052. LogMsg( L"[MT] [CTaskCompareAndPushInformation] Exiting task. The task was%ws cancelled. (hr = %#08x)", m_fStop == FALSE ? L" not" : L"", hr );
  1053. HRETURN( hr );
  1054. } //*** CTaskCompareAndPushInformation::BeginTask
  1055. //////////////////////////////////////////////////////////////////////////////
  1056. //
  1057. // STDMETHODIMP
  1058. // CTaskCompareAndPushInformation::StopTask
  1059. //
  1060. //////////////////////////////////////////////////////////////////////////////
  1061. STDMETHODIMP
  1062. CTaskCompareAndPushInformation::StopTask( void )
  1063. {
  1064. TraceFunc( "[IDoTask]" );
  1065. HRESULT hr = S_OK;
  1066. m_fStop = TRUE;
  1067. LogMsg( L"[MT] [CTaskCompareAndPushInformation] is being stopped." );
  1068. HRETURN( hr );
  1069. } //*** CTaskCompareAndPushInformation::StopTask
  1070. //////////////////////////////////////////////////////////////////////////////
  1071. //
  1072. // STDMETHODIMP
  1073. // CTaskCompareAndPushInformation::SetCompletionCookie(
  1074. // OBJECTCOOKIE cookieIn
  1075. // )
  1076. //
  1077. //////////////////////////////////////////////////////////////////////////////
  1078. STDMETHODIMP
  1079. CTaskCompareAndPushInformation::SetCompletionCookie(
  1080. OBJECTCOOKIE cookieIn
  1081. )
  1082. {
  1083. TraceFunc( "[ITaskCompareAndPushInformation]" );
  1084. HRESULT hr = S_OK;
  1085. m_cookieCompletion = cookieIn;
  1086. HRETURN( hr );
  1087. } //*** CTaskCompareAndPushInformation::SetCompletionCookie
  1088. //////////////////////////////////////////////////////////////////////////////
  1089. //
  1090. // STDMETHODIMP
  1091. // CTaskCompareAndPushInformation::SetNodeCookie(
  1092. // OBJECTCOOKIE cookieIn
  1093. // )
  1094. //
  1095. //////////////////////////////////////////////////////////////////////////////
  1096. STDMETHODIMP
  1097. CTaskCompareAndPushInformation::SetNodeCookie(
  1098. OBJECTCOOKIE cookieIn
  1099. )
  1100. {
  1101. TraceFunc( "[ITaskCompareAndPushInformation]" );
  1102. HRESULT hr = S_OK;
  1103. m_cookieNode = cookieIn;
  1104. HRETURN( hr );
  1105. } //*** CTaskCompareAndPushInformation::SetNodeCookie
  1106. //****************************************************************************
  1107. //
  1108. // IClusCfgCallback
  1109. //
  1110. //****************************************************************************
  1111. //////////////////////////////////////////////////////////////////////////////
  1112. //
  1113. // STDMETHODIMP
  1114. // CTaskCompareAndPushInformation::SendStatusReport(
  1115. // LPCWSTR pcszNodeNameIn
  1116. // , CLSID clsidTaskMajorIn
  1117. // , CLSID clsidTaskMinorIn
  1118. // , ULONG ulMinIn
  1119. // , ULONG ulMaxIn
  1120. // , ULONG ulCurrentIn
  1121. // , HRESULT hrStatusIn
  1122. // , LPCWSTR pcszDescriptionIn
  1123. // , FILETIME * pftTimeIn
  1124. // , LPCWSTR pcszReferenceIn
  1125. // )
  1126. //
  1127. //////////////////////////////////////////////////////////////////////////////
  1128. STDMETHODIMP
  1129. CTaskCompareAndPushInformation::SendStatusReport(
  1130. LPCWSTR pcszNodeNameIn
  1131. , CLSID clsidTaskMajorIn
  1132. , CLSID clsidTaskMinorIn
  1133. , ULONG ulMinIn
  1134. , ULONG ulMaxIn
  1135. , ULONG ulCurrentIn
  1136. , HRESULT hrStatusIn
  1137. , LPCWSTR pcszDescriptionIn
  1138. , FILETIME * pftTimeIn
  1139. , LPCWSTR pcszReferenceIn
  1140. )
  1141. {
  1142. TraceFunc( "[IClusCfgCallback]" );
  1143. Assert( pcszNodeNameIn != NULL );
  1144. HRESULT hr = S_OK;
  1145. IServiceProvider * psp = NULL;
  1146. IConnectionPointContainer * pcpc = NULL;
  1147. IConnectionPoint * pcp = NULL;
  1148. FILETIME ft;
  1149. if ( m_pcccb == NULL )
  1150. {
  1151. //
  1152. // Collect the manager we need to complete this task.
  1153. //
  1154. hr = THR( CoCreateInstance( CLSID_ServiceManager, NULL, CLSCTX_INPROC_SERVER, TypeSafeParams( IServiceProvider, &psp ) ) );
  1155. if ( FAILED( hr ) )
  1156. {
  1157. goto Cleanup;
  1158. }
  1159. hr = THR( psp->TypeSafeQS( CLSID_NotificationManager, IConnectionPointContainer, &pcpc ) );
  1160. if ( FAILED( hr ) )
  1161. {
  1162. goto Cleanup;
  1163. }
  1164. hr = THR( pcpc->FindConnectionPoint( IID_IClusCfgCallback, &pcp ) );
  1165. if ( FAILED( hr ) )
  1166. {
  1167. goto Cleanup;
  1168. }
  1169. pcp = TraceInterface( L"CConfigurationConnection!IConnectionPoint", IConnectionPoint, pcp, 1 );
  1170. hr = THR( pcp->TypeSafeQI( IClusCfgCallback, &m_pcccb ) );
  1171. if ( FAILED( hr ) )
  1172. {
  1173. goto Cleanup;
  1174. }
  1175. m_pcccb = TraceInterface( L"CConfigurationConnection!IClusCfgCallback", IClusCfgCallback, m_pcccb, 1 );
  1176. psp->Release();
  1177. psp = NULL;
  1178. }
  1179. if ( pftTimeIn == NULL )
  1180. {
  1181. GetSystemTimeAsFileTime( &ft );
  1182. pftTimeIn = &ft;
  1183. } // if:
  1184. //
  1185. // Send the message!
  1186. //
  1187. hr = THR( m_pcccb->SendStatusReport(
  1188. pcszNodeNameIn != NULL ? pcszNodeNameIn : m_bstrNodeName
  1189. , clsidTaskMajorIn
  1190. , clsidTaskMinorIn
  1191. , ulMinIn
  1192. , ulMaxIn
  1193. , ulCurrentIn
  1194. , hrStatusIn
  1195. , pcszDescriptionIn
  1196. , pftTimeIn
  1197. , pcszReferenceIn
  1198. ) );
  1199. Cleanup:
  1200. if ( psp != NULL )
  1201. {
  1202. psp->Release();
  1203. }
  1204. if ( pcpc != NULL )
  1205. {
  1206. pcpc->Release();
  1207. }
  1208. if ( pcp != NULL )
  1209. {
  1210. pcp->Release();
  1211. }
  1212. HRETURN( hr );
  1213. } //*** CTaskCompareAndPushInformation::SendStatusReport
  1214. //////////////////////////////////////////////////////////////////////////////
  1215. //
  1216. // STDMETHODIMP
  1217. // CTaskCompareAndPushInformation::HrSendStatusReport(
  1218. // CLSID clsidTaskMajorIn
  1219. // , CLSID clsidTaskMinorIn
  1220. // , ULONG ulMinIn
  1221. // , ULONG ulMaxIn
  1222. // , ULONG ulCurrentIn
  1223. // , HRESULT hrStatusIn
  1224. // , UINT nDescriptionIn
  1225. // )
  1226. //
  1227. //////////////////////////////////////////////////////////////////////////////
  1228. STDMETHODIMP
  1229. CTaskCompareAndPushInformation::HrSendStatusReport(
  1230. CLSID clsidTaskMajorIn
  1231. , CLSID clsidTaskMinorIn
  1232. , ULONG ulMinIn
  1233. , ULONG ulMaxIn
  1234. , ULONG ulCurrentIn
  1235. , HRESULT hrStatusIn
  1236. , UINT nDescriptionIn
  1237. )
  1238. {
  1239. TraceFunc( "[IClusCfgCallback]" );
  1240. HRESULT hr = S_OK;
  1241. BSTR bstrDescription = NULL;
  1242. THR( HrLoadStringIntoBSTR( g_hInstance, nDescriptionIn, &bstrDescription ) );
  1243. hr = THR( SendStatusReport(
  1244. m_bstrNodeName
  1245. , clsidTaskMajorIn
  1246. , clsidTaskMinorIn
  1247. , ulMinIn
  1248. , ulMaxIn
  1249. , ulCurrentIn
  1250. , hrStatusIn
  1251. , bstrDescription != NULL ? bstrDescription : L"<unknown>"
  1252. , NULL
  1253. , NULL
  1254. ) );
  1255. TraceSysFreeString( bstrDescription );
  1256. HRETURN( hr );
  1257. } //*** CTaskCompareAndPushInformation::HrSendStatusReport
  1258. //////////////////////////////////////////////////////////////////////////////
  1259. //
  1260. // HRESULT
  1261. // CTaskCompareAndPushInformation::HrVerifyCredentials(
  1262. // IClusCfgServer * pccsIn
  1263. // )
  1264. //
  1265. //////////////////////////////////////////////////////////////////////////////
  1266. HRESULT
  1267. CTaskCompareAndPushInformation::HrVerifyCredentials(
  1268. IClusCfgServer * pccsIn,
  1269. OBJECTCOOKIE cookieClusterIn
  1270. )
  1271. {
  1272. TraceFunc( "" );
  1273. HRESULT hr;
  1274. BSTR bstrAccountName = NULL;
  1275. BSTR bstrAccountPassword = NULL;
  1276. BSTR bstrAccountDomain = NULL;
  1277. IUnknown * punk = NULL;
  1278. IClusCfgClusterInfo * pccci = NULL;
  1279. IClusCfgCredentials * piccc = NULL;
  1280. IClusCfgVerify * pccv = NULL;
  1281. hr = THR( HrSendStatusReport(
  1282. TASKID_Major_Reanalyze
  1283. , TASKID_Minor_Validating_Credentials
  1284. , 0
  1285. , 1
  1286. , 0
  1287. , S_OK
  1288. , IDS_TASKID_MINOR_VALIDATING_CREDENTIALS
  1289. ) );
  1290. if ( FAILED( hr ) )
  1291. {
  1292. goto Cleanup;
  1293. }
  1294. //
  1295. // Ask the object manager for the cluster configuration object.
  1296. //
  1297. hr = THR( m_pom->GetObject( DFGUID_ClusterConfigurationInfo, cookieClusterIn, &punk ) );
  1298. if ( FAILED( hr ) )
  1299. {
  1300. goto Cleanup;
  1301. }
  1302. hr = THR( punk->TypeSafeQI( IClusCfgClusterInfo, &pccci ) );
  1303. if ( FAILED( hr ) )
  1304. {
  1305. goto Cleanup;
  1306. }
  1307. hr = THR( pccci->GetClusterServiceAccountCredentials( &piccc ) );
  1308. if ( FAILED( hr ) )
  1309. {
  1310. goto Cleanup;
  1311. }
  1312. hr = THR( pccsIn->TypeSafeQI( IClusCfgVerify, &pccv ) );
  1313. if ( FAILED( hr ) )
  1314. {
  1315. goto Cleanup;
  1316. }
  1317. hr = THR( piccc->GetCredentials( &bstrAccountName, &bstrAccountDomain, &bstrAccountPassword ) );
  1318. if ( FAILED( hr ) )
  1319. {
  1320. goto Cleanup;
  1321. }
  1322. TraceMemoryAddBSTR( bstrAccountName );
  1323. TraceMemoryAddBSTR( bstrAccountDomain );
  1324. TraceMemoryAddBSTR( bstrAccountPassword );
  1325. //
  1326. // The server component reports the exact failure, if any, to the UI.
  1327. //
  1328. hr = THR( pccv->VerifyCredentials( bstrAccountName, bstrAccountDomain, bstrAccountPassword ) );
  1329. SecureZeroMemory( bstrAccountPassword, SysStringLen( bstrAccountPassword ) * sizeof( *bstrAccountPassword ) );
  1330. if ( FAILED( hr ) )
  1331. {
  1332. goto Cleanup;
  1333. }
  1334. Cleanup:
  1335. //
  1336. // The server side function does its own error reporting and it's okay to double report here because
  1337. // there could have been a network problem that prevents the server side from either being contacted
  1338. // or being able to report the status.
  1339. //
  1340. THR( HrSendStatusReport(
  1341. TASKID_Major_Reanalyze
  1342. , TASKID_Minor_Validating_Credentials
  1343. , 0
  1344. , 1
  1345. , 1
  1346. , hr
  1347. , IDS_TASKID_MINOR_VALIDATING_CREDENTIALS
  1348. ) );
  1349. TraceSysFreeString( bstrAccountName );
  1350. TraceSysFreeString( bstrAccountDomain );
  1351. TraceSysFreeString( bstrAccountPassword );
  1352. if ( punk != NULL )
  1353. {
  1354. punk->Release();
  1355. }
  1356. if ( piccc != NULL )
  1357. {
  1358. piccc->Release();
  1359. }
  1360. if ( pccci != NULL )
  1361. {
  1362. pccci->Release();
  1363. }
  1364. if ( pccv != NULL )
  1365. {
  1366. pccv->Release();
  1367. }
  1368. HRETURN( hr );
  1369. } //*** CTaskCompareAndPushInformation::HrVerifyCredentials
  1370. //////////////////////////////////////////////////////////////////////////////
  1371. //
  1372. // HRESULT
  1373. // CTaskCompareAndPushInformation::HrExchangePrivateData(
  1374. // IClusCfgManagedResourceInfo * piccmriSrcIn
  1375. // , IClusCfgManagedResourceInfo * piccmriDstIn
  1376. // )
  1377. //
  1378. //////////////////////////////////////////////////////////////////////////////
  1379. HRESULT
  1380. CTaskCompareAndPushInformation::HrExchangePrivateData(
  1381. IClusCfgManagedResourceInfo * piccmriSrcIn
  1382. , IClusCfgManagedResourceInfo * piccmriDstIn
  1383. )
  1384. {
  1385. TraceFunc( "" );
  1386. Assert( piccmriSrcIn != NULL );
  1387. Assert( piccmriDstIn != NULL );
  1388. HRESULT hr = S_OK;
  1389. HRESULT hrSrcQI = S_OK;
  1390. HRESULT hrDstQI = S_OK;
  1391. IClusCfgManagedResourceData * piccmrdSrc = NULL;
  1392. IClusCfgManagedResourceData * piccmrdDst = NULL;
  1393. BYTE * pbPrivateData = NULL;
  1394. DWORD cbPrivateData = 0;
  1395. hrSrcQI = piccmriSrcIn->TypeSafeQI( IClusCfgManagedResourceData, &piccmrdSrc );
  1396. if ( hrSrcQI == E_NOINTERFACE )
  1397. {
  1398. LogMsg( L"[MT] The cluster managed resource has no support for IClusCfgManagedResourceData." );
  1399. goto Cleanup;
  1400. } // if:
  1401. else if ( FAILED( hrSrcQI ) )
  1402. {
  1403. hr = THR( hrSrcQI );
  1404. goto Cleanup;
  1405. } // if:
  1406. hrDstQI = piccmriDstIn->TypeSafeQI( IClusCfgManagedResourceData, &piccmrdDst );
  1407. if ( hrDstQI == E_NOINTERFACE )
  1408. {
  1409. LogMsg( L"[MT] The new node resource has no support for IClusCfgManagedResourceData." );
  1410. goto Cleanup;
  1411. } // if:
  1412. else if ( FAILED( hrDstQI ) )
  1413. {
  1414. hr = THR( hrDstQI );
  1415. goto Cleanup;
  1416. } // if:
  1417. Assert( ( hrSrcQI == S_OK ) && ( piccmrdSrc != NULL ) );
  1418. Assert( ( hrDstQI == S_OK ) && ( piccmrdDst != NULL ) );
  1419. cbPrivateData = 512; // start with a reasonable amout
  1420. pbPrivateData = (BYTE *) TraceAlloc( 0, cbPrivateData );
  1421. if ( pbPrivateData == NULL )
  1422. {
  1423. hr = THR( E_OUTOFMEMORY );
  1424. goto Cleanup;
  1425. } // if:
  1426. hr = piccmrdSrc->GetResourcePrivateData( pbPrivateData, &cbPrivateData );
  1427. if ( hr == HR_RPC_INSUFFICIENT_BUFFER )
  1428. {
  1429. TraceFree( pbPrivateData );
  1430. pbPrivateData = NULL;
  1431. pbPrivateData = (BYTE *) TraceAlloc( 0, cbPrivateData );
  1432. if ( pbPrivateData == NULL )
  1433. {
  1434. hr = THR( E_OUTOFMEMORY );
  1435. goto Cleanup;
  1436. } // if:
  1437. hr = piccmrdSrc->GetResourcePrivateData( pbPrivateData, &cbPrivateData );
  1438. } // if:
  1439. if ( hr == S_OK )
  1440. {
  1441. hr = THR( piccmrdDst->SetResourcePrivateData( pbPrivateData, cbPrivateData ) );
  1442. if ( FAILED( hr ) )
  1443. {
  1444. goto Cleanup;
  1445. } // if:
  1446. } // if:
  1447. else if ( hr == S_FALSE )
  1448. {
  1449. hr = S_OK;
  1450. } // else if:
  1451. else
  1452. {
  1453. THR( hr );
  1454. goto Cleanup;
  1455. } // if:
  1456. Cleanup:
  1457. if ( piccmrdSrc != NULL )
  1458. {
  1459. piccmrdSrc->Release();
  1460. } // if:
  1461. if ( piccmrdDst != NULL )
  1462. {
  1463. piccmrdDst->Release();
  1464. } // if:
  1465. TraceFree( pbPrivateData );
  1466. HRETURN( hr );
  1467. } //*** CTaskCompareAndPushInformation::HrExchangePrivateData