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.

1196 lines
27 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ClusterConfiguration.cpp
  7. //
  8. // Description:
  9. // CClusterConfiguration implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-FEB-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "ClusterConfiguration.h"
  17. #include "ManagedNetwork.h"
  18. DEFINE_THISCLASS("CClusterConfiguration")
  19. // ************************************************************************
  20. //
  21. // Constructor / Destructor
  22. //
  23. // ************************************************************************
  24. //////////////////////////////////////////////////////////////////////////////
  25. //++
  26. //
  27. // HRESULT
  28. // CClusterConfiguration::S_HrCreateInstance(
  29. // IUnknown ** ppunkOut
  30. // )
  31. //
  32. //--
  33. //////////////////////////////////////////////////////////////////////////////
  34. HRESULT
  35. CClusterConfiguration::S_HrCreateInstance(
  36. IUnknown ** ppunkOut
  37. )
  38. {
  39. TraceFunc( "" );
  40. HRESULT hr = S_OK;
  41. CClusterConfiguration * pcc = NULL;
  42. Assert( ppunkOut != NULL );
  43. if ( ppunkOut == NULL )
  44. {
  45. hr = THR( E_POINTER );
  46. goto Cleanup;
  47. }
  48. pcc = new CClusterConfiguration;
  49. if ( pcc == NULL )
  50. {
  51. hr = THR( E_OUTOFMEMORY );
  52. goto Cleanup;
  53. }
  54. hr = THR( pcc->HrInit() );
  55. if ( FAILED( hr ) )
  56. {
  57. goto Cleanup;
  58. }
  59. hr = THR( pcc->TypeSafeQI( IUnknown, ppunkOut ) );
  60. if ( FAILED( hr ) )
  61. {
  62. goto Cleanup;
  63. }
  64. Cleanup:
  65. if ( pcc != NULL )
  66. {
  67. pcc->Release();
  68. }
  69. HRETURN( hr );
  70. } //*** CClusterConfiguration::S_HrCreateInstance
  71. //////////////////////////////////////////////////////////////////////////////
  72. //++
  73. //
  74. // CClusterConfiguration::CClusterConfiguration
  75. //
  76. //--
  77. //////////////////////////////////////////////////////////////////////////////
  78. CClusterConfiguration::CClusterConfiguration( void )
  79. : m_cRef( 1 )
  80. {
  81. TraceFunc( "" );
  82. InterlockedIncrement( &g_cObjects );
  83. TraceFuncExit();
  84. } //*** CClusterConfiguration::CClusterConfiguration
  85. //////////////////////////////////////////////////////////////////////////////
  86. //++
  87. //
  88. // STDMETHODIMP
  89. // CClusterConfiguration::HrInit
  90. //
  91. //--
  92. //////////////////////////////////////////////////////////////////////////////
  93. STDMETHODIMP
  94. CClusterConfiguration::HrInit( void )
  95. {
  96. TraceFunc( "" );
  97. HRESULT hr = S_OK;
  98. // IUnknown stuff
  99. Assert( m_cRef == 1 );
  100. // IClusCfgClusterInfo
  101. Assert( m_bstrClusterName == NULL );
  102. Assert( m_ulIPAddress == 0 );
  103. Assert( m_ulSubnetMask == 0 );
  104. Assert( m_picccServiceAccount == NULL );
  105. Assert( m_punkNetwork == NULL );
  106. Assert( m_ecmCommitChangesMode == cmUNKNOWN );
  107. Assert( m_bstrClusterBindingString == NULL );
  108. // IExtendObjectManager
  109. HRETURN( hr );
  110. } //*** CClusterConfiguration::HrInit
  111. //////////////////////////////////////////////////////////////////////////////
  112. //++
  113. //
  114. // CClusterConfiguration::~CClusterConfiguration
  115. //
  116. //--
  117. //////////////////////////////////////////////////////////////////////////////
  118. CClusterConfiguration::~CClusterConfiguration( void )
  119. {
  120. TraceFunc( "" );
  121. TraceSysFreeString( m_bstrClusterName );
  122. TraceSysFreeString( m_bstrClusterBindingString );
  123. if ( m_picccServiceAccount != NULL )
  124. {
  125. m_picccServiceAccount->Release();
  126. }
  127. if ( m_punkNetwork != NULL )
  128. {
  129. m_punkNetwork->Release();
  130. }
  131. InterlockedDecrement( &g_cObjects );
  132. TraceFuncExit();
  133. } //*** CClusterConfiguration::~CClusterConfiguration
  134. // ************************************************************************
  135. //
  136. // IUnknown
  137. //
  138. // ************************************************************************
  139. //////////////////////////////////////////////////////////////////////////////
  140. //++
  141. //
  142. // CClusterConfiguration::QueryInterface
  143. //
  144. // Description:
  145. // Query this object for the passed in interface.
  146. //
  147. // Arguments:
  148. // riidIn
  149. // Id of interface requested.
  150. //
  151. // ppvOut
  152. // Pointer to the requested interface.
  153. //
  154. // Return Value:
  155. // S_OK
  156. // If the interface is available on this object.
  157. //
  158. // E_NOINTERFACE
  159. // If the interface is not available.
  160. //
  161. // E_POINTER
  162. // ppvOut was NULL.
  163. //
  164. // Remarks:
  165. // None.
  166. //
  167. //--
  168. //////////////////////////////////////////////////////////////////////////////
  169. STDMETHODIMP
  170. CClusterConfiguration::QueryInterface(
  171. REFIID riidIn
  172. , LPVOID * ppvOut
  173. )
  174. {
  175. TraceQIFunc( riidIn, ppvOut );
  176. HRESULT hr = S_OK;
  177. //
  178. // Validate arguments.
  179. //
  180. Assert( ppvOut != NULL );
  181. if ( ppvOut == NULL )
  182. {
  183. hr = THR( E_POINTER );
  184. goto Cleanup;
  185. }
  186. //
  187. // Handle known interfaces.
  188. //
  189. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  190. {
  191. *ppvOut = static_cast< IClusCfgClusterInfo * >( this );
  192. } // if: IUnknown
  193. else if ( IsEqualIID( riidIn, IID_IClusCfgClusterInfo ) )
  194. {
  195. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgClusterInfo, this, 0 );
  196. } // else if: IClusCfgClusterInfo
  197. else if ( IsEqualIID( riidIn, IID_IGatherData ) )
  198. {
  199. *ppvOut = TraceInterface( __THISCLASS__, IGatherData, this, 0 );
  200. } // else if: IGatherData
  201. else if ( IsEqualIID( riidIn, IID_IExtendObjectManager ) )
  202. {
  203. *ppvOut = TraceInterface( __THISCLASS__, IExtendObjectManager, this, 0 );
  204. } // else if: IObjectManager
  205. else
  206. {
  207. *ppvOut = NULL;
  208. hr = E_NOINTERFACE;
  209. } // else
  210. //
  211. // Add a reference to the interface if successful.
  212. //
  213. if ( SUCCEEDED( hr ) )
  214. {
  215. ((IUnknown*) *ppvOut)->AddRef();
  216. } // if: success
  217. Cleanup:
  218. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  219. } //*** CClusterConfiguration::QueryInterface
  220. //////////////////////////////////////////////////////////////////////////////
  221. //++
  222. //
  223. // STDMETHODIMP_( ULONG )
  224. // CClusterConfiguration::AddRef
  225. //
  226. //--
  227. //////////////////////////////////////////////////////////////////////////////
  228. STDMETHODIMP_( ULONG )
  229. CClusterConfiguration::AddRef( void )
  230. {
  231. TraceFunc( "[IUnknown]" );
  232. InterlockedIncrement( &m_cRef );
  233. CRETURN( m_cRef );
  234. } //*** CClusterConfiguration::AddRef
  235. //////////////////////////////////////////////////////////////////////////////
  236. //++
  237. //
  238. // STDMETHODIMP_( ULONG )
  239. // CClusterConfiguration::Release
  240. //
  241. //--
  242. //////////////////////////////////////////////////////////////////////////////
  243. STDMETHODIMP_( ULONG )
  244. CClusterConfiguration::Release( void )
  245. {
  246. TraceFunc( "[IUnknown]" );
  247. LONG cRef;
  248. cRef = InterlockedDecrement( &m_cRef );
  249. if ( cRef == 0 )
  250. {
  251. TraceDo( delete this );
  252. }
  253. CRETURN( cRef );
  254. } //*** CClusterConfiguration::Release
  255. // ************************************************************************
  256. //
  257. // IClusCfgClusterInfo
  258. //
  259. // ************************************************************************
  260. //////////////////////////////////////////////////////////////////////////////
  261. //++
  262. //
  263. // STDMETHODIMP
  264. // CClusterConfiguration::GetCommitMode( ECommitMode * pecmCurrentModeOut )
  265. //
  266. //--
  267. //////////////////////////////////////////////////////////////////////////////
  268. STDMETHODIMP
  269. CClusterConfiguration::GetCommitMode( ECommitMode * pecmCurrentModeOut )
  270. {
  271. TraceFunc( "[IClusCfgClusterInfo]" );
  272. HRESULT hr = S_OK;
  273. if ( pecmCurrentModeOut == NULL )
  274. {
  275. hr = THR( E_POINTER );
  276. goto Cleanup;
  277. } // if:
  278. *pecmCurrentModeOut = m_ecmCommitChangesMode;
  279. Cleanup:
  280. HRETURN( hr );
  281. } //*** CClusterConfiguration::GetCommitMode
  282. //////////////////////////////////////////////////////////////////////////////
  283. //++
  284. //
  285. // STDMETHODIMP
  286. // CClusterConfiguration::SetCommitMode( ECommitMode ecmCurrentModeIn )
  287. //
  288. //--
  289. //////////////////////////////////////////////////////////////////////////////
  290. STDMETHODIMP
  291. CClusterConfiguration::SetCommitMode( ECommitMode ecmCurrentModeIn )
  292. {
  293. TraceFunc( "[IClusCfgClusterInfo]" );
  294. HRESULT hr = S_OK;
  295. m_ecmCommitChangesMode = ecmCurrentModeIn;
  296. HRETURN( hr );
  297. } //*** CClusterConfiguration::SetCommitMode
  298. ///////////////////////////////////////////////////////////////////////////////
  299. //++
  300. //
  301. // STDMETHODIMP
  302. // CClusterConfiguration::GetName(
  303. // BSTR * pbstrNameOut
  304. // )
  305. //
  306. //--
  307. ///////////////////////////////////////////////////////////////////////////////
  308. STDMETHODIMP
  309. CClusterConfiguration::GetName(
  310. BSTR * pbstrNameOut
  311. )
  312. {
  313. TraceFunc( "[IClusCfgClusterInfo]" );
  314. HRESULT hr = S_OK;
  315. if ( pbstrNameOut == NULL )
  316. {
  317. hr = THR( E_POINTER );
  318. goto Cleanup;
  319. }
  320. if ( m_bstrClusterName == NULL )
  321. {
  322. hr = THR( E_POINTER );
  323. goto Cleanup;
  324. }
  325. *pbstrNameOut = SysAllocString( m_bstrClusterName );
  326. if ( *pbstrNameOut == NULL )
  327. {
  328. hr = THR( E_OUTOFMEMORY );
  329. goto Cleanup;
  330. }
  331. Cleanup:
  332. HRETURN( hr );
  333. } //*** CClusterConfiguration::GetName
  334. ///////////////////////////////////////////////////////////////////////////////
  335. //++
  336. //
  337. // STDMETHODIMP
  338. // CClusterConfiguration::SetName(
  339. // LPCWSTR pcszNameIn
  340. // )
  341. //
  342. //--
  343. ///////////////////////////////////////////////////////////////////////////////
  344. STDMETHODIMP
  345. CClusterConfiguration::SetName(
  346. LPCWSTR pcszNameIn
  347. )
  348. {
  349. TraceFunc1( "[IClusCfgClusterInfo] pcszNameIn = '%ws'", ( pcszNameIn == NULL ? L"<null>" : pcszNameIn ) );
  350. HRESULT hr = S_OK;
  351. BSTR bstrNewName;
  352. if ( pcszNameIn == NULL )
  353. {
  354. hr = THR( E_INVALIDARG );
  355. goto Cleanup;
  356. }
  357. bstrNewName = TraceSysAllocString( pcszNameIn );
  358. if ( bstrNewName == NULL )
  359. {
  360. hr = THR( E_OUTOFMEMORY );
  361. goto Cleanup;
  362. }
  363. TraceSysFreeString( m_bstrClusterName );
  364. m_bstrClusterName = bstrNewName;
  365. m_fHasNameChanged = TRUE;
  366. Cleanup:
  367. HRETURN( hr );
  368. } //*** CClusterConfiguration::SetName
  369. //////////////////////////////////////////////////////////////////////////////
  370. //++
  371. //
  372. // STDMETHODIMP
  373. // CClusterConfiguration::GetIPAddress(
  374. // ULONG * pulDottedQuadOut
  375. // )
  376. //
  377. //--
  378. //////////////////////////////////////////////////////////////////////////////
  379. STDMETHODIMP
  380. CClusterConfiguration::GetIPAddress(
  381. ULONG * pulDottedQuadOut
  382. )
  383. {
  384. TraceFunc( "[IClusCfgClusterInfo]" );
  385. HRESULT hr;
  386. if ( pulDottedQuadOut == NULL )
  387. {
  388. hr = THR( E_POINTER );
  389. goto Cleanup;
  390. }
  391. *pulDottedQuadOut = m_ulIPAddress;
  392. hr = S_OK;
  393. Cleanup:
  394. HRETURN( hr );
  395. } //*** CClusterConfiguration::GetIPAddress
  396. //////////////////////////////////////////////////////////////////////////////
  397. //++
  398. //
  399. // STDMETHODIMP
  400. // CClusterConfiguration::SetIPAddress(
  401. // ULONG ulDottedQuadIn
  402. // )
  403. //
  404. //--
  405. //////////////////////////////////////////////////////////////////////////////
  406. STDMETHODIMP
  407. CClusterConfiguration::SetIPAddress(
  408. ULONG ulDottedQuadIn
  409. )
  410. {
  411. TraceFunc( "[IClusCfgClusterInfo]" );
  412. HRESULT hr = S_OK;
  413. m_ulIPAddress = ulDottedQuadIn;
  414. HRETURN( hr );
  415. } //*** CClusterConfiguration::SetIPAddress
  416. //////////////////////////////////////////////////////////////////////////////
  417. //++
  418. //
  419. // STDMETHODIMP
  420. // CClusterConfiguration::GetSubnetMask(
  421. // ULONG * pulDottedQuadOut
  422. // )
  423. //
  424. //--
  425. //////////////////////////////////////////////////////////////////////////////
  426. STDMETHODIMP
  427. CClusterConfiguration::GetSubnetMask(
  428. ULONG * pulDottedQuadOut
  429. )
  430. {
  431. TraceFunc( "[IClusCfgClusterInfo]" );
  432. HRESULT hr;
  433. if ( pulDottedQuadOut == NULL )
  434. {
  435. hr = THR( E_POINTER );
  436. goto Cleanup;
  437. }
  438. *pulDottedQuadOut = m_ulSubnetMask;
  439. hr = S_OK;
  440. Cleanup:
  441. HRETURN( hr );
  442. } //*** CClusterConfiguration::GetSubnetMask
  443. //////////////////////////////////////////////////////////////////////////////
  444. //++
  445. //
  446. // STDMETHODIMP
  447. // CClusterConfiguration::SetSubnetMask(
  448. // ULONG ulDottedQuadIn
  449. // )
  450. //
  451. //--
  452. //////////////////////////////////////////////////////////////////////////////
  453. STDMETHODIMP
  454. CClusterConfiguration::SetSubnetMask(
  455. ULONG ulDottedQuadIn
  456. )
  457. {
  458. TraceFunc( "[IClusCfgClusterInfo]" );
  459. HRESULT hr = S_OK;
  460. m_ulSubnetMask = ulDottedQuadIn;
  461. HRETURN( hr );
  462. } //*** CClusterConfiguration::SetSubnetMask
  463. //////////////////////////////////////////////////////////////////////////////
  464. //++
  465. //
  466. // STDMETHODIMP
  467. // CClusterConfiguration::GetNetworkInfo(
  468. // IClusCfgNetworkInfo ** ppiccniOut
  469. // )
  470. //
  471. //--
  472. //////////////////////////////////////////////////////////////////////////////
  473. STDMETHODIMP
  474. CClusterConfiguration::GetNetworkInfo(
  475. IClusCfgNetworkInfo ** ppiccniOut
  476. )
  477. {
  478. TraceFunc( "[IClusCfgClusterInfo]" );
  479. HRESULT hr = S_OK;
  480. if ( ppiccniOut == NULL )
  481. {
  482. hr = THR( E_POINTER );
  483. goto Cleanup;
  484. }
  485. if ( m_punkNetwork == NULL )
  486. {
  487. hr = HRESULT_FROM_WIN32( TW32( ERROR_INVALID_DATA ) );
  488. goto Cleanup;
  489. }
  490. *ppiccniOut = TraceInterface( L"CClusterConfiguration!GetNetworkInfo", IClusCfgNetworkInfo, m_punkNetwork, 0 );
  491. (*ppiccniOut)->AddRef();
  492. Cleanup:
  493. HRETURN( hr );
  494. } //*** CClusterConfiguration::GetNetworkInfo
  495. //////////////////////////////////////////////////////////////////////////////
  496. //++
  497. //
  498. // CClusterConfiguration::SetNetworkInfo(
  499. // IClusCfgNetworkInfo * piccniIn
  500. // )
  501. //
  502. //--
  503. //////////////////////////////////////////////////////////////////////////////
  504. STDMETHODIMP
  505. CClusterConfiguration::SetNetworkInfo(
  506. IClusCfgNetworkInfo * piccniIn
  507. )
  508. {
  509. TraceFunc( "[IClusCfgClusterInfo]" );
  510. HRESULT hr = S_OK;
  511. IClusCfgNetworkInfo * punkNew;
  512. if ( piccniIn == NULL )
  513. {
  514. hr = THR( E_INVALIDARG );
  515. goto Cleanup;
  516. }
  517. hr = THR( piccniIn->TypeSafeQI( IClusCfgNetworkInfo, &punkNew ) );
  518. if ( FAILED( hr ) )
  519. {
  520. goto Cleanup;
  521. }
  522. if ( m_punkNetwork != NULL )
  523. {
  524. m_punkNetwork->Release();
  525. }
  526. m_punkNetwork = punkNew; // no addref!
  527. Cleanup:
  528. HRETURN( hr );
  529. } //*** CClusterConfiguration::SetNetworkInfo
  530. //////////////////////////////////////////////////////////////////////////////
  531. //++
  532. //
  533. // STDMETHODIMP
  534. // CClusterConfiguration::GetClusterServiceAccountCredentials(
  535. // IClusCfgCredentials ** ppicccCredentialsOut
  536. // )
  537. //
  538. //--
  539. //////////////////////////////////////////////////////////////////////////////
  540. STDMETHODIMP
  541. CClusterConfiguration::GetClusterServiceAccountCredentials(
  542. IClusCfgCredentials ** ppicccCredentialsOut
  543. )
  544. {
  545. TraceFunc( "[IClusCfgClusterInfo]" );
  546. HRESULT hr = S_OK;
  547. if ( m_picccServiceAccount == NULL )
  548. {
  549. hr = THR( HrCoCreateInternalInstance( CLSID_ClusCfgCredentials,
  550. NULL,
  551. CLSCTX_INPROC_HANDLER,
  552. IID_IClusCfgCredentials,
  553. reinterpret_cast< void ** >( &m_picccServiceAccount )
  554. ) );
  555. if ( FAILED( hr ) )
  556. {
  557. goto Cleanup;
  558. }
  559. }
  560. if ( ppicccCredentialsOut == NULL )
  561. {
  562. hr = THR( E_POINTER );
  563. goto Cleanup;
  564. } // if:
  565. *ppicccCredentialsOut = TraceInterface( L"ClusCfgCredentials!ClusterConfig", IClusCfgCredentials, m_picccServiceAccount, 0 );
  566. (*ppicccCredentialsOut)->AddRef();
  567. Cleanup:
  568. HRETURN( hr );
  569. } //*** CClusterConfiguration::GetClusterServiceAccountCredentials
  570. ///////////////////////////////////////////////////////////////////////////////
  571. //++
  572. //
  573. // STDMETHODIMP
  574. // CClusterConfiguration::GetBindingString(
  575. // BSTR * pbstrBindingStringOut
  576. // )
  577. //
  578. //--
  579. ///////////////////////////////////////////////////////////////////////////////
  580. STDMETHODIMP
  581. CClusterConfiguration::GetBindingString(
  582. BSTR * pbstrBindingStringOut
  583. )
  584. {
  585. TraceFunc( "[IClusCfgClusterInfo]" );
  586. HRESULT hr = S_OK;
  587. if ( pbstrBindingStringOut == NULL )
  588. {
  589. hr = THR( E_POINTER );
  590. goto Cleanup;
  591. }
  592. if ( m_bstrClusterBindingString == NULL )
  593. {
  594. hr = S_FALSE;
  595. goto Cleanup;
  596. }
  597. *pbstrBindingStringOut = SysAllocString( m_bstrClusterBindingString );
  598. if ( *pbstrBindingStringOut == NULL )
  599. {
  600. hr = THR( E_OUTOFMEMORY );
  601. goto Cleanup;
  602. }
  603. Cleanup:
  604. HRETURN( hr );
  605. } //*** CClusterConfiguration::GetBindingString
  606. ///////////////////////////////////////////////////////////////////////////////
  607. //++
  608. //
  609. // STDMETHODIMP
  610. // CClusterConfiguration::SetBindingString(
  611. // LPCWSTR bstrBindingStringIn
  612. // )
  613. //
  614. //--
  615. ///////////////////////////////////////////////////////////////////////////////
  616. STDMETHODIMP
  617. CClusterConfiguration::SetBindingString(
  618. LPCWSTR pcszBindingStringIn
  619. )
  620. {
  621. TraceFunc1( "[IClusCfgClusterInfo] pcszBindingStringIn = '%ws'", ( pcszBindingStringIn == NULL ? L"<null>" : pcszBindingStringIn ) );
  622. HRESULT hr = S_OK;
  623. BSTR bstr = NULL;
  624. if ( pcszBindingStringIn == NULL )
  625. {
  626. hr = THR( E_INVALIDARG );
  627. goto Cleanup;
  628. }
  629. bstr = TraceSysAllocString( pcszBindingStringIn );
  630. if ( bstr == NULL )
  631. {
  632. hr = THR( E_OUTOFMEMORY );
  633. goto Cleanup;
  634. }
  635. TraceSysFreeString( m_bstrClusterBindingString );
  636. m_bstrClusterBindingString = bstr;
  637. Cleanup:
  638. HRETURN( hr );
  639. } //*** CClusterConfiguration::SetBindingString
  640. //////////////////////////////////////////////////////////////////////////////
  641. //++
  642. //
  643. // CClusterConfiguration::GetMaxNodeCount
  644. //
  645. // Description:
  646. // Get the maximum number of nodes supported in this cluster.
  647. //
  648. // Arguments:
  649. // pcMaxNodesOut
  650. //
  651. // Return Value:
  652. // S_OK
  653. // Success;
  654. //
  655. // E_POINTER
  656. // pcMaxNodesOut is NULL.
  657. //
  658. // Other HRESULT errors.
  659. //
  660. //--
  661. //////////////////////////////////////////////////////////////////////////////
  662. STDMETHODIMP
  663. CClusterConfiguration::GetMaxNodeCount(
  664. DWORD * pcMaxNodesOut
  665. )
  666. {
  667. TraceFunc( "[IClusCfgClusterInfo]" );
  668. HRESULT hr = S_OK;
  669. if (pcMaxNodesOut == NULL )
  670. {
  671. hr = THR( E_POINTER );
  672. goto Cleanup;
  673. } // if:
  674. *pcMaxNodesOut = m_cMaxNodes;
  675. Cleanup:
  676. HRETURN( hr );
  677. } //*** CClusterConfiguration::GetMaxNodeCount
  678. //****************************************************************************
  679. //
  680. // IGatherData
  681. //
  682. //****************************************************************************
  683. //////////////////////////////////////////////////////////////////////////////
  684. //++
  685. //
  686. // STDMETHODIMP
  687. // CClusterConfiguration::Gather(
  688. // OBJECTCOOKIE cookieParentIn,
  689. // IUnknown * punkIn
  690. // )
  691. //
  692. //--
  693. //////////////////////////////////////////////////////////////////////////////
  694. STDMETHODIMP
  695. CClusterConfiguration::Gather(
  696. OBJECTCOOKIE cookieParentIn,
  697. IUnknown * punkIn
  698. )
  699. {
  700. TraceFunc( "[IGatherData]" );
  701. HRESULT hr;
  702. OBJECTCOOKIE cookie;
  703. IServiceProvider * psp;
  704. IObjectManager * pom = NULL;
  705. IClusCfgClusterInfo * pcci = NULL;
  706. IClusCfgCredentials * piccc = NULL;
  707. IClusCfgNetworkInfo * pccni = NULL;
  708. IUnknown * punk = NULL;
  709. IGatherData * pgd = NULL;
  710. if ( punkIn == NULL )
  711. {
  712. hr = THR( E_POINTER );
  713. goto Cleanup;
  714. }
  715. //
  716. // Grab the object manager.
  717. //
  718. hr = THR( CoCreateInstance( CLSID_ServiceManager,
  719. NULL,
  720. CLSCTX_SERVER,
  721. TypeSafeParams( IServiceProvider, &psp )
  722. ) );
  723. if ( FAILED( hr ) )
  724. {
  725. goto Cleanup;
  726. }
  727. hr = THR( psp->TypeSafeQS( CLSID_ObjectManager,
  728. IObjectManager,
  729. &pom
  730. ) );
  731. psp->Release(); // release promptly
  732. if ( FAILED( hr ) )
  733. {
  734. goto Cleanup;
  735. }
  736. //
  737. // Make sure this is what we think it is.
  738. //
  739. hr = THR( punkIn->TypeSafeQI( IClusCfgClusterInfo, &pcci ) );
  740. if ( FAILED( hr ) )
  741. {
  742. goto Cleanup;
  743. }
  744. //
  745. // Gather Cluster Name
  746. //
  747. hr = THR( pcci->GetName( &m_bstrClusterName ) );
  748. if ( FAILED( hr ) )
  749. {
  750. goto Error;
  751. }
  752. TraceMemoryAddBSTR( m_bstrClusterName );
  753. //
  754. // Gather Cluster binding string
  755. //
  756. hr = STHR( pcci->GetBindingString( &m_bstrClusterBindingString ) );
  757. if ( FAILED( hr ) )
  758. {
  759. goto Error;
  760. }
  761. TraceMemoryAddBSTR( m_bstrClusterBindingString );
  762. //
  763. // Gather IP Address
  764. //
  765. hr = STHR( pcci->GetIPAddress( &m_ulIPAddress ) );
  766. if ( FAILED( hr ) )
  767. {
  768. goto Error;
  769. }
  770. //
  771. // Gather Subnet Mask
  772. //
  773. hr = STHR( pcci->GetSubnetMask( &m_ulSubnetMask ) );
  774. if ( FAILED( hr ) )
  775. {
  776. goto Error;
  777. }
  778. //
  779. // Find out our cookie.
  780. //
  781. hr = THR( pom->FindObject( CLSID_ClusterConfigurationType,
  782. cookieParentIn,
  783. m_bstrClusterName,
  784. IID_NULL,
  785. &cookie,
  786. NULL
  787. ) );
  788. if ( FAILED( hr ) )
  789. {
  790. goto Error;
  791. }
  792. //
  793. // Gather the network.
  794. //
  795. hr = STHR( pcci->GetNetworkInfo( &pccni ) );
  796. if ( FAILED( hr ) )
  797. {
  798. goto Error;
  799. }
  800. hr = THR( CManagedNetwork::S_HrCreateInstance( &punk ) );
  801. if ( FAILED( hr ) )
  802. {
  803. goto Error;
  804. }
  805. hr = THR( punk->TypeSafeQI( IGatherData, &pgd ) );
  806. if ( FAILED( hr ) )
  807. {
  808. goto Error;
  809. }
  810. //
  811. // Gather the info, but since this object isn't going to be
  812. // reflected in the cookie tree, pass it a parent of ZERO
  813. // so it won't gather the secondary IP addresses.
  814. //
  815. hr = THR( pgd->Gather( 0, pccni ) );
  816. if ( FAILED( hr ) )
  817. {
  818. goto Error;
  819. }
  820. hr = THR( punk->TypeSafeQI( IClusCfgNetworkInfo, &m_punkNetwork ) );
  821. if ( FAILED( hr ) )
  822. {
  823. goto Error;
  824. }
  825. //
  826. // Gather Account Name and Domain.
  827. //
  828. hr = THR( pcci->GetClusterServiceAccountCredentials( &piccc ) );
  829. if ( FAILED( hr ) )
  830. {
  831. goto Error;
  832. }
  833. hr = THR( HrCoCreateInternalInstance( CLSID_ClusCfgCredentials,
  834. NULL,
  835. CLSCTX_INPROC_SERVER,
  836. IID_IClusCfgCredentials,
  837. reinterpret_cast< void ** >( &m_picccServiceAccount )
  838. ) );
  839. if ( FAILED( hr ) )
  840. {
  841. goto Error;
  842. }
  843. hr = THR( m_picccServiceAccount->AssignFrom( piccc ) );
  844. if ( FAILED( hr ) )
  845. {
  846. goto Error;
  847. }
  848. hr = STHR( pcci->GetMaxNodeCount( &m_cMaxNodes ) );
  849. if ( FAILED( hr ) )
  850. {
  851. goto Error;
  852. }
  853. //
  854. // Anything else to gather??
  855. //
  856. hr = S_OK;
  857. Cleanup:
  858. if ( piccc != NULL )
  859. {
  860. piccc->Release();
  861. }
  862. if ( pcci != NULL )
  863. {
  864. pcci->Release();
  865. }
  866. if ( pccni != NULL )
  867. {
  868. pccni->Release();
  869. }
  870. if ( punk != NULL )
  871. {
  872. punk->Release();
  873. }
  874. if ( pgd != NULL )
  875. {
  876. pgd->Release();
  877. }
  878. HRETURN( hr );
  879. Error:
  880. //
  881. // On error, invalidate all data.
  882. //
  883. TraceSysFreeString( m_bstrClusterName );
  884. m_bstrClusterName = NULL;
  885. m_fHasNameChanged = FALSE;
  886. m_ulIPAddress = 0;
  887. m_ulSubnetMask = 0;
  888. if ( m_picccServiceAccount != NULL )
  889. {
  890. m_picccServiceAccount->Release();
  891. m_picccServiceAccount = NULL;
  892. }
  893. if ( m_punkNetwork != NULL )
  894. {
  895. m_punkNetwork->Release();
  896. m_punkNetwork = NULL;
  897. }
  898. goto Cleanup;
  899. } //*** CClusterConfiguration::Gather
  900. // ************************************************************************
  901. //
  902. // IExtendObjectManager
  903. //
  904. // ************************************************************************
  905. //////////////////////////////////////////////////////////////////////////////
  906. //++
  907. //
  908. // STDMETHODIMP
  909. // CClusterConfiguration::FindObject(
  910. // OBJECTCOOKIE cookieIn,
  911. // REFCLSID rclsidTypeIn,
  912. // LPCWSTR pcszNameIn,
  913. // LPUNKNOWN * punkOut
  914. // )
  915. //
  916. //--
  917. //////////////////////////////////////////////////////////////////////////////
  918. STDMETHODIMP
  919. CClusterConfiguration::FindObject(
  920. OBJECTCOOKIE cookieIn,
  921. REFCLSID rclsidTypeIn,
  922. LPCWSTR pcszNameIn,
  923. LPUNKNOWN * ppunkOut
  924. )
  925. {
  926. TraceFunc( "[IExtendObjectManager]" );
  927. HRESULT hr = E_PENDING;
  928. //
  929. // Check parameters.
  930. //
  931. // We need to represent a ClusterType.
  932. if ( !IsEqualIID( rclsidTypeIn, CLSID_ClusterConfigurationType ) )
  933. {
  934. hr = THR( E_INVALIDARG );
  935. goto Cleanup;
  936. }
  937. // Gotta have a cookie
  938. if ( cookieIn == NULL )
  939. {
  940. hr = THR( E_INVALIDARG );
  941. goto Cleanup;
  942. }
  943. // We need to have a name.
  944. if ( pcszNameIn == NULL )
  945. {
  946. hr = THR( E_INVALIDARG );
  947. goto Cleanup;
  948. }
  949. //
  950. // Try to save the name. We don't care if this fails as it will be
  951. // over-ridden when the information is retrieved from the node.
  952. //
  953. m_bstrClusterName = TraceSysAllocString( pcszNameIn );
  954. //
  955. // Get the pointer.
  956. //
  957. if ( ppunkOut != NULL )
  958. {
  959. hr = THR( QueryInterface( DFGUID_ClusterConfigurationInfo,
  960. reinterpret_cast< void ** > ( ppunkOut )
  961. ) );
  962. if ( FAILED( hr ) )
  963. {
  964. goto Cleanup;
  965. }
  966. } // if: ppunkOut
  967. //
  968. // Tell caller that the data is pending.
  969. //
  970. hr = E_PENDING;
  971. Cleanup:
  972. HRETURN( hr );
  973. } //*** CClusterConfiguration::FindObject