Source code of Windows XP (NT5)
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.

1055 lines
24 KiB

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