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.

1206 lines
28 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ConfigClusApi.cpp
  7. //
  8. // Description:
  9. // CConfigClusApi implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-AUG-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. //////////////////////////////////////////////////////////////////////////////
  16. // Include Files
  17. //////////////////////////////////////////////////////////////////////////////
  18. #include "Pch.h"
  19. #include "CProxyCfgClusterInfo.h"
  20. #include "CProxyCfgNetworkInfo.h"
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Constant Definitions
  23. //////////////////////////////////////////////////////////////////////////////
  24. DEFINE_THISCLASS("CProxyCfgClusterInfo")
  25. //////////////////////////////////////////////////////////////////////////////
  26. //++
  27. //
  28. // CProxyCfgClusterInfo::S_HrCreateInstance
  29. //
  30. // Description:
  31. // Create an instance of the CProxyCfgClusterInfo object.
  32. //
  33. // Arguments:
  34. // ppunkOut -
  35. // punkOuterIn -
  36. // pclsidMajorIn -
  37. // pcszDomainIn -
  38. //
  39. // Return Values:
  40. //
  41. //--
  42. //////////////////////////////////////////////////////////////////////////////
  43. HRESULT
  44. CProxyCfgClusterInfo::S_HrCreateInstance(
  45. IUnknown ** ppunkOut,
  46. IUnknown * punkOuterIn,
  47. HCLUSTER * phClusterIn,
  48. CLSID * pclsidMajorIn,
  49. LPCWSTR pcszDomainIn
  50. )
  51. {
  52. TraceFunc( "" );
  53. HRESULT hr = S_OK;
  54. CProxyCfgClusterInfo * ppcci = NULL;
  55. if ( ppunkOut == NULL )
  56. {
  57. hr = THR( E_POINTER );
  58. goto Cleanup;
  59. } // if:
  60. ppcci = new CProxyCfgClusterInfo;
  61. if ( ppcci == NULL )
  62. {
  63. hr = THR( E_OUTOFMEMORY );
  64. goto Cleanup;
  65. } // if:
  66. hr = THR( ppcci->HrInit( punkOuterIn, phClusterIn, pclsidMajorIn, pcszDomainIn ) );
  67. if ( FAILED( hr ) )
  68. {
  69. goto Cleanup;
  70. }
  71. hr = THR( ppcci->TypeSafeQI( IUnknown, ppunkOut ) );
  72. if ( FAILED( hr ) )
  73. {
  74. goto Cleanup;
  75. }
  76. Cleanup:
  77. if ( ppcci != NULL )
  78. {
  79. ppcci->Release();
  80. } // if:
  81. HRETURN( hr );
  82. } //*** CProxyCfgClusterInfo::S_HrCreateInstance
  83. //////////////////////////////////////////////////////////////////////////////
  84. //++
  85. //
  86. // CProxyCfgClusterInfo::CProxyCfgClusterInfo
  87. //
  88. // Description:
  89. // Default constructor.
  90. //
  91. // Arguments:
  92. // None.
  93. //
  94. // Return Values:
  95. // None.
  96. //
  97. //--
  98. //////////////////////////////////////////////////////////////////////////////
  99. CProxyCfgClusterInfo::CProxyCfgClusterInfo( void )
  100. : m_cRef( 1 )
  101. {
  102. TraceFunc( "" );
  103. InterlockedIncrement( &g_cObjects );
  104. Assert( m_punkOuter == NULL );
  105. Assert( m_pcccb == NULL );
  106. Assert( m_phCluster == NULL );
  107. Assert( m_pclsidMajor == NULL );
  108. Assert( m_bstrClusterName == NULL);
  109. Assert( m_ulIPAddress == 0 );
  110. Assert( m_ulSubnetMask == 0 );
  111. Assert( m_bstrNetworkName == NULL);
  112. Assert( m_pccc == NULL );
  113. Assert( m_bstrBindingString == NULL );
  114. TraceFuncExit();
  115. } //*** CProxyCfgClusterInfo::CProxyCfgClusterInfo
  116. //////////////////////////////////////////////////////////////////////////////
  117. //++
  118. //
  119. // CProxyCfgClusterInfo::~CProxyCfgClusterInfo
  120. //
  121. // Description:
  122. // Destructor.
  123. //
  124. // Arguments:
  125. // None.
  126. //
  127. // Return Values:
  128. // None.
  129. //
  130. //--
  131. //////////////////////////////////////////////////////////////////////////////
  132. CProxyCfgClusterInfo::~CProxyCfgClusterInfo( void )
  133. {
  134. TraceFunc( "" );
  135. // m_cRef - noop
  136. if ( m_punkOuter != NULL )
  137. {
  138. m_punkOuter->Release();
  139. }
  140. if ( m_pcccb != NULL )
  141. {
  142. m_pcccb->Release();
  143. } // if:
  144. // m_phCluster - DO NOT CLOSE!
  145. // m_pclsidMajor - noop
  146. TraceSysFreeString( m_bstrClusterName );
  147. // m_ulIPAddress
  148. // m_ulSubnetMask
  149. TraceSysFreeString( m_bstrNetworkName );
  150. TraceSysFreeString( m_bstrBindingString );
  151. if ( m_pccc != NULL )
  152. {
  153. m_pccc->Release();
  154. }
  155. InterlockedDecrement( &g_cObjects );
  156. TraceFuncExit();
  157. } //*** CProxyCfgClusterInfo::~CProxyCfgClusterInfo
  158. //////////////////////////////////////////////////////////////////////////////
  159. //++
  160. //
  161. // CProxyCfgClusterInfo::HrInit
  162. //
  163. // Description:
  164. // Secondary initializer.
  165. //
  166. // Arguments:
  167. // punkOuterIn -
  168. // phClusterIn -
  169. // pclsidMajorIn -
  170. // pcszDomainIn -
  171. //
  172. // Return Values:
  173. //
  174. //--
  175. //////////////////////////////////////////////////////////////////////////////
  176. HRESULT
  177. CProxyCfgClusterInfo::HrInit(
  178. IUnknown * punkOuterIn,
  179. HCLUSTER * phClusterIn,
  180. CLSID * pclsidMajorIn,
  181. LPCWSTR pcszDomainIn
  182. )
  183. {
  184. TraceFunc( "" );
  185. HRESULT hr;
  186. DWORD sc;
  187. BSTR bstrClusterName = NULL;
  188. CLUSTERVERSIONINFO cvi;
  189. HRESOURCE hIPAddressRes = NULL;
  190. WCHAR * psz = NULL;
  191. size_t cchName = 0;
  192. // IUnknown
  193. Assert( m_cRef == 1 );
  194. if ( punkOuterIn != NULL )
  195. {
  196. m_punkOuter = punkOuterIn;
  197. m_punkOuter->AddRef();
  198. }
  199. if ( phClusterIn == NULL )
  200. {
  201. hr = THR( E_INVALIDARG );
  202. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_ClusterInfo_HrInit_InvalidArg, hr );
  203. goto Cleanup;
  204. }
  205. m_phCluster = phClusterIn;
  206. if ( pclsidMajorIn != NULL )
  207. {
  208. m_pclsidMajor = pclsidMajorIn;
  209. }
  210. else
  211. {
  212. m_pclsidMajor = (CLSID *) &TASKID_Major_Client_And_Server_Log;
  213. }
  214. if ( punkOuterIn != NULL )
  215. {
  216. hr = THR( punkOuterIn->TypeSafeQI( IClusCfgCallback, &m_pcccb ) );
  217. if ( FAILED( hr ) )
  218. {
  219. goto Cleanup;
  220. }
  221. }
  222. //
  223. // Get the cluster's name and version info.
  224. //
  225. cvi.dwVersionInfoSize = sizeof( cvi );
  226. hr = THR( HrGetClusterInformation( *m_phCluster, &bstrClusterName, &cvi ) );
  227. if ( FAILED( hr ) )
  228. {
  229. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_GetClusterInformation_Failed, hr );
  230. goto Cleanup;
  231. }
  232. // Give up ownership
  233. cchName = (size_t) SysStringLen( bstrClusterName ) + 1 + (UINT) wcslen( pcszDomainIn ) + 1; // include space for the . and the '\0'
  234. m_bstrClusterName = TraceSysAllocStringLen( NULL, (UINT) cchName );
  235. if ( m_bstrClusterName == NULL )
  236. {
  237. hr = THR( E_OUTOFMEMORY );
  238. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_ClusterInfo_HrInit_OutOfMemory, hr );
  239. goto Cleanup;
  240. } // if:
  241. hr = THR( StringCchPrintfW( m_bstrClusterName, cchName, L"%ws.%ws", bstrClusterName, pcszDomainIn ) );
  242. if ( FAILED( hr ) )
  243. {
  244. goto Cleanup;
  245. } // if:
  246. sc = TW32( ResUtilGetCoreClusterResources( *m_phCluster, NULL, &hIPAddressRes, NULL ) );
  247. if ( sc != ERROR_SUCCESS )
  248. {
  249. hr = HRESULT_FROM_WIN32( sc );
  250. goto Cleanup;
  251. } // if:
  252. Assert( m_bstrNetworkName == NULL );
  253. hr = THR( HrGetIPAddressInfo( hIPAddressRes, &m_ulIPAddress, &m_ulSubnetMask, &m_bstrNetworkName ) );
  254. if ( FAILED( hr ) )
  255. {
  256. goto Cleanup;
  257. }
  258. sc = TW32( ClRtlTcpipAddressToString( m_ulIPAddress, &psz ) );
  259. if ( sc != ERROR_SUCCESS )
  260. {
  261. hr = HRESULT_FROM_WIN32( sc );
  262. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_ClusterInfo_HrInit_InvalidDottedQuad, hr );
  263. goto Cleanup;
  264. } // if:
  265. Assert( m_bstrBindingString == NULL );
  266. m_bstrBindingString = TraceSysAllocString( psz );
  267. if ( m_bstrBindingString == NULL )
  268. {
  269. hr = THR( E_OUTOFMEMORY );
  270. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_ClusterInfo_HrInit_OutOfMemory, hr );
  271. goto Cleanup;
  272. } // if:
  273. hr = THR( HrLoadCredentials() );
  274. if ( FAILED( hr ) )
  275. {
  276. goto Cleanup;
  277. }
  278. hr = S_OK;
  279. Cleanup:
  280. //
  281. // Do not use TraceFree() because ClRtlTcpipAddressToString()
  282. // uses LocalAlloc() and does not use our memory tracking code.
  283. //
  284. LocalFree( psz );
  285. if ( hIPAddressRes != NULL )
  286. {
  287. CloseClusterResource( hIPAddressRes );
  288. } // if:
  289. TraceSysFreeString( bstrClusterName );
  290. HRETURN( hr );
  291. } //*** CProxyCfgClusterInfo::HrInit
  292. //*************************************************************************//
  293. /////////////////////////////////////////////////////////////////////////////
  294. // CProxyCfgClusterInfo -- IUknkown interface.
  295. /////////////////////////////////////////////////////////////////////////////
  296. /////////////////////////////////////////////////////////////////////////////
  297. //++
  298. //
  299. // CProxyCfgClusterInfo::QueryInterface
  300. //
  301. // Description:
  302. // Query this object for the passed in interface.
  303. //
  304. // Arguments:
  305. // riidIn
  306. // Id of interface requested.
  307. //
  308. // ppvOut
  309. // Pointer to the requested interface.
  310. //
  311. // Return Value:
  312. // S_OK
  313. // If the interface is available on this object.
  314. //
  315. // E_NOINTERFACE
  316. // If the interface is not available.
  317. //
  318. // E_POINTER
  319. // ppvOut was NULL.
  320. //
  321. // Remarks:
  322. // None.
  323. //
  324. //--
  325. /////////////////////////////////////////////////////////////////////////////
  326. STDMETHODIMP
  327. CProxyCfgClusterInfo::QueryInterface(
  328. REFIID riidIn
  329. , void ** ppvOut
  330. )
  331. {
  332. TraceQIFunc( riidIn, ppvOut );
  333. HRESULT hr = S_OK;
  334. //
  335. // Validate arguments.
  336. //
  337. Assert( ppvOut != NULL );
  338. if ( ppvOut == NULL )
  339. {
  340. hr = THR( E_POINTER );
  341. goto Cleanup;
  342. }
  343. //
  344. // Handle known interfaces.
  345. //
  346. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  347. {
  348. *ppvOut = static_cast< IClusCfgClusterInfo * >( this );
  349. } // if: IUnknown
  350. else if ( IsEqualIID( riidIn, IID_IClusCfgClusterInfo ) )
  351. {
  352. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgClusterInfo, this, 0 );
  353. } // else if: IClusCfgClusterInfo
  354. else if ( IsEqualIID( riidIn, IID_IClusCfgClusterInfoEx ) )
  355. {
  356. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgClusterInfoEx, this, 0 );
  357. } // else if: IClusCfgClusterInfoEx
  358. else
  359. {
  360. *ppvOut = NULL;
  361. hr = E_NOINTERFACE;
  362. } // else
  363. //
  364. // Add a reference to the interface if successful.
  365. //
  366. if ( SUCCEEDED( hr ) )
  367. {
  368. ((IUnknown *) *ppvOut)->AddRef();
  369. } // if: success
  370. Cleanup:
  371. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  372. } //*** CConfigClusApi::QueryInterface
  373. //////////////////////////////////////////////////////////////////////////////
  374. //++
  375. //
  376. // CProxyCfgClusterInfo::AddRef
  377. //
  378. // Description:
  379. // Increment the reference count of this object by one.
  380. //
  381. // Arguments:
  382. // None.
  383. //
  384. // Return Value:
  385. // The new reference count.
  386. //
  387. // Remarks:
  388. // None.
  389. //
  390. //--
  391. //////////////////////////////////////////////////////////////////////////////
  392. STDMETHODIMP_( ULONG )
  393. CProxyCfgClusterInfo::AddRef( void )
  394. {
  395. TraceFunc( "[IUnknown]" );
  396. InterlockedIncrement( &m_cRef );
  397. CRETURN( m_cRef );
  398. } //*** CProxyCfgClusterInfo::AddRef
  399. //////////////////////////////////////////////////////////////////////////////
  400. //++
  401. //
  402. // CProxyCfgClusterInfo::Release
  403. //
  404. // Description:
  405. // Decrement the reference count of this object by one.
  406. //
  407. // Arguments:
  408. // None.
  409. //
  410. // Return Value:
  411. // The new reference count.
  412. //
  413. // Remarks:
  414. // None.
  415. //
  416. //--
  417. //////////////////////////////////////////////////////////////////////////////
  418. STDMETHODIMP_( ULONG )
  419. CProxyCfgClusterInfo::Release( void )
  420. {
  421. TraceFunc( "[IUnknown]" );
  422. LONG cRef;
  423. cRef = InterlockedDecrement( &m_cRef );
  424. if ( cRef == 0 )
  425. {
  426. TraceDo( delete this );
  427. }
  428. CRETURN( cRef );
  429. } //*** CProxyCfgClusterInfo::Release
  430. //****************************************************************************
  431. //
  432. // IClusCfgClusterInfo
  433. //
  434. //****************************************************************************
  435. //
  436. //
  437. //
  438. STDMETHODIMP
  439. CProxyCfgClusterInfo::GetName(
  440. BSTR * pbstrNameOut
  441. )
  442. {
  443. TraceFunc( "[IClusCfgClusterInfo]" );
  444. HRESULT hr = S_OK;
  445. if ( pbstrNameOut == NULL )
  446. goto InvalidPointer;
  447. *pbstrNameOut = SysAllocString( m_bstrClusterName );
  448. if ( *pbstrNameOut == NULL )
  449. {
  450. hr = THR( E_OUTOFMEMORY );
  451. }
  452. CharLower( *pbstrNameOut );
  453. Cleanup:
  454. HRETURN( hr );
  455. InvalidPointer:
  456. hr = THR( E_POINTER );
  457. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2kProxy_ClusterInfo_GetName_InvalidPointer, hr );
  458. goto Cleanup;
  459. } //*** CProxyCfgClusterInfo::GetName
  460. //
  461. //
  462. //
  463. STDMETHODIMP
  464. CProxyCfgClusterInfo::GetIPAddress(
  465. DWORD * pdwIPAddress
  466. )
  467. {
  468. TraceFunc( "[IClusCfgClusterInfo]" );
  469. HRESULT hr = S_OK;
  470. if ( pdwIPAddress == NULL )
  471. goto InvalidPointer;
  472. *pdwIPAddress = m_ulIPAddress;
  473. Cleanup:
  474. HRETURN( hr );
  475. InvalidPointer:
  476. hr = THR( E_POINTER );
  477. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_ClusterInfo_GetIPAddress_InvalidPointer, hr );
  478. goto Cleanup;
  479. } //*** CProxyCfgClusterInfo::GetIPAddress
  480. //
  481. //
  482. //
  483. STDMETHODIMP
  484. CProxyCfgClusterInfo::GetSubnetMask(
  485. DWORD * pdwNetMask
  486. )
  487. {
  488. TraceFunc( "[IClusCfgClusterInfo]" );
  489. HRESULT hr = S_OK;
  490. if ( pdwNetMask == NULL )
  491. goto InvalidPointer;
  492. *pdwNetMask = m_ulSubnetMask;
  493. Cleanup:
  494. HRETURN( hr );
  495. InvalidPointer:
  496. hr = THR( E_POINTER );
  497. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_ClusterInfo_GetSubnetMask_InvalidPointer, hr );
  498. goto Cleanup;
  499. } //*** CProxyCfgClusterInfo::GetSubnetMask
  500. //
  501. //
  502. //
  503. STDMETHODIMP
  504. CProxyCfgClusterInfo::GetNetworkInfo(
  505. IClusCfgNetworkInfo ** ppICCNetInfoOut
  506. )
  507. {
  508. TraceFunc( "[IClusCfgClusterInfo]" );
  509. HRESULT hr;
  510. IUnknown * punk = NULL;
  511. if ( ppICCNetInfoOut == NULL )
  512. {
  513. hr = THR( E_POINTER );
  514. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetNetworkInfo_InvalidPointer, hr );
  515. goto Cleanup;
  516. }
  517. //
  518. // Create the network info object.
  519. //
  520. hr = THR( CProxyCfgNetworkInfo::S_HrCreateInstance( &punk,
  521. m_punkOuter,
  522. m_phCluster,
  523. m_pclsidMajor,
  524. m_bstrNetworkName
  525. ) );
  526. if ( FAILED( hr ) )
  527. {
  528. goto Cleanup;
  529. }
  530. hr = THR( punk->TypeSafeQI( IClusCfgNetworkInfo, ppICCNetInfoOut ) );
  531. Cleanup:
  532. if ( punk != NULL )
  533. {
  534. punk->Release();
  535. }
  536. HRETURN( hr );
  537. } //*** CProxyCfgClusterInfo::GetNetworkInfo
  538. //
  539. //
  540. //
  541. STDMETHODIMP
  542. CProxyCfgClusterInfo::GetClusterServiceAccountCredentials(
  543. IClusCfgCredentials ** ppICCCredentialsOut
  544. )
  545. {
  546. TraceFunc( "[IClusCfgClusterInfo]" );
  547. HRESULT hr;
  548. if ( ppICCCredentialsOut == NULL )
  549. goto InvalidPointer;
  550. hr = THR( m_pccc->TypeSafeQI( IClusCfgCredentials, ppICCCredentialsOut ) );
  551. if ( FAILED( hr ) )
  552. goto Cleanup;
  553. Cleanup:
  554. HRETURN( hr );
  555. InvalidPointer:
  556. hr = THR( E_POINTER );
  557. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterServiceAccountCredentials_InvalidPointer, hr );
  558. goto Cleanup;
  559. } //*** CProxyCfgClusterInfo::GetClusterServiceAccountCredentials
  560. //
  561. //
  562. //
  563. STDMETHODIMP
  564. CProxyCfgClusterInfo::GetBindingString(
  565. BSTR * pbstrBindingStringOut
  566. )
  567. {
  568. TraceFunc( "[IClusCfgClusterInfo]" );
  569. HRESULT hr = S_OK;
  570. if ( pbstrBindingStringOut == NULL )
  571. {
  572. hr = THR( E_POINTER );
  573. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2kProxy_ClusterInfo_GetBindingString_InvalidPointer, hr );
  574. goto Cleanup;
  575. }
  576. if ( m_bstrBindingString == NULL )
  577. {
  578. hr = S_FALSE;
  579. goto Cleanup;
  580. } // if:
  581. *pbstrBindingStringOut = SysAllocString( m_bstrBindingString );
  582. if ( *pbstrBindingStringOut == NULL )
  583. {
  584. hr = THR( E_OUTOFMEMORY );
  585. goto Cleanup;
  586. }
  587. Cleanup:
  588. HRETURN( hr );
  589. } //*** CProxyCfgClusterInfo::GetBindingString
  590. //
  591. //
  592. //
  593. STDMETHODIMP
  594. CProxyCfgClusterInfo::SetCommitMode( ECommitMode ecmNewModeIn )
  595. {
  596. TraceFunc( "[IClusCfgClusterInfo]" );
  597. Assert( ecmNewModeIn != cmUNKNOWN );
  598. HRESULT hr = THR( E_NOTIMPL );
  599. HRETURN( hr );
  600. } //*** CProxyCfgClusterInfo::SetCommitMode
  601. //
  602. //
  603. //
  604. STDMETHODIMP
  605. CProxyCfgClusterInfo::GetCommitMode( ECommitMode * pecmCurrentModeOut )
  606. {
  607. TraceFunc( "[IClusCfgClusterInfo]" );
  608. Assert( pecmCurrentModeOut != NULL );
  609. HRESULT hr = S_FALSE;
  610. HRETURN( hr );
  611. } //*** CProxyCfgClusterInfo::GetCommitMode
  612. //
  613. //
  614. //
  615. STDMETHODIMP
  616. CProxyCfgClusterInfo::SetName( LPCWSTR pcszNameIn )
  617. {
  618. TraceFunc1( "[IClusCfgClusterInfo] pcszNameIn = '%ls'", pcszNameIn );
  619. HRESULT hr = THR( E_NOTIMPL );
  620. HRETURN( hr );
  621. } //*** CProxyCfgClusterInfo::SetName
  622. //
  623. //
  624. //
  625. STDMETHODIMP
  626. CProxyCfgClusterInfo::SetIPAddress( DWORD dwIPAddressIn )
  627. {
  628. TraceFunc( "[IClusCfgClusterInfo]" );
  629. HRESULT hr = S_OK;
  630. if ( dwIPAddressIn != m_ulIPAddress )
  631. {
  632. hr = THR( E_INVALIDARG );
  633. }
  634. HRETURN( hr );
  635. } //*** CProxyCfgClusterInfo::SetIPAddress
  636. //
  637. //
  638. //
  639. STDMETHODIMP
  640. CProxyCfgClusterInfo::SetSubnetMask( DWORD dwNetMaskIn )
  641. {
  642. TraceFunc( "[IClusCfgClusterInfo]" );
  643. HRESULT hr = S_OK;
  644. if ( dwNetMaskIn != m_ulSubnetMask )
  645. {
  646. hr = THR( E_INVALIDARG );
  647. }
  648. HRETURN( hr );
  649. } //*** CProxyCfgClusterInfo::SetSubnetMask
  650. //
  651. //
  652. //
  653. STDMETHODIMP
  654. CProxyCfgClusterInfo::SetNetworkInfo( IClusCfgNetworkInfo * pICCNetInfoIn )
  655. {
  656. TraceFunc( "[IClusCfgClusterInfo]" );
  657. HRESULT hr = THR( E_NOTIMPL );
  658. HRETURN( hr );
  659. } //*** CProxyCfgClusterInfo::SetNetworkInfo
  660. //
  661. //
  662. //
  663. STDMETHODIMP
  664. CProxyCfgClusterInfo::SetBindingString( LPCWSTR pcszBindingStringIn )
  665. {
  666. TraceFunc1( "[IClusCfgClusterInfo] pcszBindingStringIn = '%ls'", pcszBindingStringIn );
  667. HRESULT hr = S_OK;
  668. BSTR bstr = NULL;
  669. if ( pcszBindingStringIn == NULL )
  670. {
  671. hr = THR( E_INVALIDARG );
  672. goto Cleanup;
  673. } // if:
  674. bstr = TraceSysAllocString( pcszBindingStringIn );
  675. if ( bstr == NULL )
  676. {
  677. hr = THR( E_OUTOFMEMORY );
  678. goto Cleanup;
  679. } // if:
  680. TraceSysFreeString( m_bstrBindingString );
  681. m_bstrBindingString = bstr;
  682. Cleanup:
  683. HRETURN( hr );
  684. } //*** CProxyCfgClusterInfo::SetBindingString
  685. //
  686. //
  687. //
  688. STDMETHODIMP
  689. CProxyCfgClusterInfo::GetMaxNodeCount(
  690. DWORD * pcMaxNodesOut
  691. )
  692. {
  693. TraceFunc( "[IClusCfgClusterInfo]" );
  694. HRESULT hr = S_OK;
  695. if ( pcMaxNodesOut == NULL )
  696. {
  697. hr = THR( E_POINTER );
  698. goto Cleanup;
  699. } // if:
  700. //
  701. // TODO: 11-OCT-2001 GalenB
  702. //
  703. // Need to figure out the correct max nodes for the Win2K cluster
  704. // that we are proxying for. May be able to use HrGetMaxNodeCount(),
  705. // once it is implemented.
  706. //
  707. hr = S_FALSE;
  708. Cleanup:
  709. HRETURN( hr );
  710. } //*** CProxyCfgClusterInfo::GetMaxNodeCount
  711. //////////////////////////////////////////////////////////////////////////////
  712. //++
  713. //
  714. // CProxyCfgClusterInfo::CheckJoiningNodeVersion
  715. //
  716. // Description:
  717. // Check a joining node's version information against that of the cluster.
  718. //
  719. // Arguments:
  720. // dwNodeHighestVersionIn
  721. // dwNodeLowestVersionIn
  722. //
  723. // Return Value:
  724. // S_OK
  725. // The joining node is compatible.
  726. //
  727. // HRESULT_FROM_WIN32( ERROR_CLUSTER_INCOMPATIBLE_VERSIONS )
  728. // The joining node is NOT compatible.
  729. //
  730. // Other HRESULT errors.
  731. //
  732. // Remarks:
  733. //
  734. // Get and verify the sponsor version
  735. //
  736. //
  737. // From Whistler onwards, CsRpcGetJoinVersionData() will return a failure code in its last parameter
  738. // if the version of this node is not compatible with the sponsor version. Prior to this, the last
  739. // parameter always contained a success value and the cluster versions had to be compared subsequent to this
  740. // call. This will, however, still have to be done as long as interoperability with Win2K
  741. // is a requirement, since Win2K sponsors do not return an error in the last parameter.
  742. //
  743. //--
  744. //////////////////////////////////////////////////////////////////////////////
  745. STDMETHODIMP
  746. CProxyCfgClusterInfo::CheckJoiningNodeVersion(
  747. DWORD dwNodeHighestVersionIn
  748. , DWORD dwNodeLowestVersionIn
  749. )
  750. {
  751. TraceFunc( "[IClusCfgClusterInfoEx]" );
  752. HRESULT hr = S_OK;
  753. hr = THR( HrCheckJoiningNodeVersion(
  754. m_bstrClusterName
  755. , dwNodeHighestVersionIn
  756. , dwNodeLowestVersionIn
  757. , m_pcccb
  758. ) );
  759. HRETURN( hr );
  760. } //*** CProxyCfgClusterInfo::CheckJoiningNodeVersion
  761. //////////////////////////////////////////////////////////////////////////////
  762. //++
  763. //
  764. // CProxyCfgClusterInfo::GetNodeNames
  765. //
  766. // Description:
  767. // Retrieve the names of the nodes currently in the cluster.
  768. //
  769. // Parameters:
  770. // pnCountOut
  771. // On success, *pnCountOut returns the number of nodes in the cluster.
  772. //
  773. // prgbstrNodeNamesOut
  774. // On success, an array of BSTRs containing the node names.
  775. // The caller must free each BSTR with SysFreeString, and free
  776. // the array with CoTaskMemFree.
  777. //
  778. // Return Values:
  779. // S_OK
  780. // The out parameters contain valid information and the caller
  781. // must free the array and the BSTRs it contains.
  782. //
  783. // E_OUTOFMEMORY, and other failures are possible.
  784. //
  785. //--
  786. //////////////////////////////////////////////////////////////////////////////
  787. STDMETHODIMP
  788. CProxyCfgClusterInfo::GetNodeNames(
  789. long * pnCountOut
  790. , BSTR ** prgbstrNodeNamesOut
  791. )
  792. {
  793. TraceFunc( "[IClusCfgClusterInfoEx]" );
  794. HRESULT hr = S_OK;
  795. hr = THR( HrGetNodeNames(
  796. *m_phCluster
  797. , pnCountOut
  798. , prgbstrNodeNamesOut
  799. ) );
  800. if ( FAILED( hr ) )
  801. {
  802. goto Cleanup;
  803. } // if:
  804. Cleanup:
  805. HRETURN( hr );
  806. } //*** CProxyCfgClusterInfo::GetNodeNames
  807. //****************************************************************************
  808. //
  809. // IClusCfgCallback
  810. //
  811. //****************************************************************************
  812. //////////////////////////////////////////////////////////////////////////////
  813. //++
  814. //
  815. // CProxyCfgClusterInfo::SendStatusReport
  816. //
  817. // Description:
  818. //
  819. // Arguments:
  820. //
  821. // Return Value:
  822. //
  823. // Remarks:
  824. // None.
  825. //
  826. //--
  827. //////////////////////////////////////////////////////////////////////////////
  828. STDMETHODIMP
  829. CProxyCfgClusterInfo::SendStatusReport(
  830. LPCWSTR pcszNodeNameIn
  831. , CLSID clsidTaskMajorIn
  832. , CLSID clsidTaskMinorIn
  833. , ULONG ulMinIn
  834. , ULONG ulMaxIn
  835. , ULONG ulCurrentIn
  836. , HRESULT hrStatusIn
  837. , LPCWSTR pcszDescriptionIn
  838. , FILETIME * pftTimeIn
  839. , LPCWSTR pcszReferenceIn
  840. )
  841. {
  842. TraceFunc( "[IClusCfgCallback]" );
  843. HRESULT hr = S_OK;
  844. if ( m_pcccb != NULL )
  845. {
  846. hr = THR( m_pcccb->SendStatusReport( pcszNodeNameIn,
  847. clsidTaskMajorIn,
  848. clsidTaskMinorIn,
  849. ulMinIn,
  850. ulMaxIn,
  851. ulCurrentIn,
  852. hrStatusIn,
  853. pcszDescriptionIn,
  854. pftTimeIn,
  855. pcszReferenceIn
  856. ) );
  857. } // if:
  858. HRETURN( hr );
  859. } //*** CProxyCfgClusterInfo::SendStatusReport
  860. //****************************************************************************
  861. //
  862. // IClusCfgCallback
  863. //
  864. //****************************************************************************
  865. //////////////////////////////////////////////////////////////////////////////
  866. //++
  867. //
  868. // CProxyCfgClusterInfo::HrLoadCredentials
  869. //
  870. // Description:
  871. //
  872. //
  873. // Arguments:
  874. //
  875. //
  876. // Return Value:
  877. //
  878. //
  879. //--
  880. //////////////////////////////////////////////////////////////////////////////
  881. HRESULT
  882. CProxyCfgClusterInfo::HrLoadCredentials( void )
  883. {
  884. TraceFunc( "" );
  885. HRESULT hr = S_OK;
  886. SC_HANDLE schSCM = NULL;
  887. SC_HANDLE schClusSvc = NULL;
  888. DWORD sc;
  889. DWORD cbpqsc = 128;
  890. DWORD cbRequired;
  891. QUERY_SERVICE_CONFIG * pqsc = NULL;
  892. IUnknown * punk = NULL;
  893. IClusCfgSetCredentials * piccsc = NULL;
  894. schSCM = OpenSCManager( m_bstrClusterName, NULL, GENERIC_READ );
  895. if ( schSCM == NULL )
  896. {
  897. hr = HRESULT_FROM_WIN32( TW32( GetLastError() ) );
  898. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrLoadCredentials_OpenSCManager_Failed, hr );
  899. goto Cleanup;
  900. } // if:
  901. schClusSvc = OpenService( schSCM, L"ClusSvc", GENERIC_READ );
  902. if ( schClusSvc == NULL )
  903. {
  904. hr = HRESULT_FROM_WIN32( TW32( GetLastError() ) );
  905. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrLoadCredentials_OpenService_Failed, hr );
  906. goto Cleanup;
  907. } // if:
  908. for ( ; ; )
  909. {
  910. BOOL fRet;
  911. pqsc = (QUERY_SERVICE_CONFIG *) TraceAlloc( 0, cbpqsc );
  912. if ( pqsc == NULL )
  913. {
  914. hr = THR( E_OUTOFMEMORY );
  915. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrLoadCredentials_OutOfMemory, hr );
  916. goto Cleanup;
  917. }
  918. fRet = QueryServiceConfig( schClusSvc, pqsc, cbpqsc, &cbRequired );
  919. if ( !fRet )
  920. {
  921. sc = GetLastError();
  922. if ( sc == ERROR_INSUFFICIENT_BUFFER )
  923. {
  924. TraceFree( pqsc );
  925. pqsc = NULL;
  926. cbpqsc = cbRequired;
  927. continue;
  928. } // if:
  929. else
  930. {
  931. hr = HRESULT_FROM_WIN32( TW32( sc ) );
  932. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrLoadCredentials_QueryServiceConfig_Failed, hr );
  933. goto Cleanup;
  934. } // else:
  935. } // if:
  936. else
  937. {
  938. break;
  939. } // else:
  940. } // for:
  941. Assert( m_pccc == NULL );
  942. hr = THR( HrCoCreateInternalInstance(
  943. CLSID_ClusCfgCredentials
  944. , NULL
  945. , CLSCTX_INPROC_SERVER
  946. , IID_IClusCfgCredentials
  947. , reinterpret_cast< void ** >( &m_pccc )
  948. ) );
  949. if ( FAILED( hr ) )
  950. {
  951. goto Cleanup;
  952. }
  953. hr = THR( m_pccc->TypeSafeQI( IClusCfgSetCredentials, &piccsc ) );
  954. if ( FAILED( hr ) )
  955. {
  956. goto Cleanup;
  957. } // if:
  958. hr = THR( piccsc->SetDomainCredentials( pqsc->lpServiceStartName ) );
  959. Cleanup:
  960. if ( punk != NULL )
  961. {
  962. punk->Release();
  963. }
  964. if ( schClusSvc != NULL )
  965. {
  966. CloseServiceHandle( schClusSvc );
  967. } // if:
  968. if ( schSCM != NULL )
  969. {
  970. CloseServiceHandle( schSCM );
  971. } // if:
  972. if ( pqsc != NULL )
  973. {
  974. TraceFree( pqsc );
  975. } // if:
  976. if ( piccsc != NULL )
  977. {
  978. piccsc->Release();
  979. } // if:
  980. HRETURN( hr );
  981. } //*** CProxyCfgClusterInfo::HrLoadCredentials