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.

1451 lines
35 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 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 "ConfigClusApi.h"
  20. #include "CProxyCfgNodeInfo.h"
  21. #include "CEnumCfgResources.h"
  22. #include "CEnumCfgNetworks.h"
  23. #include "StatusReports.h"
  24. #include "nameutil.h"
  25. //////////////////////////////////////////////////////////////////////////////
  26. // Constant Definitions
  27. //////////////////////////////////////////////////////////////////////////////
  28. DEFINE_THISCLASS("CConfigClusApi");
  29. //////////////////////////////////////////////////////////////////////////////
  30. //++
  31. //
  32. // HrMakeClusterFQDN
  33. //
  34. // Description:
  35. // Construct a cluster's FQDN given a cluster handle and an FQIP (an IP
  36. // address with a domain appended after a pipe |).
  37. //
  38. // Arguments:
  39. // hClusterIn
  40. // pcwszClusterFQIPIn
  41. // pbstrFQDNOut
  42. //
  43. // Return Values:
  44. // S_OK
  45. // Other HRESULT error.
  46. //
  47. //--
  48. //////////////////////////////////////////////////////////////////////////////
  49. static
  50. HRESULT
  51. HrMakeClusterFQDN(
  52. HCLUSTER hClusterIn
  53. , PCWSTR pcwszClusterFQIPIn
  54. , BSTR * pbstrFQDNOut
  55. )
  56. {
  57. TraceFunc( "" );
  58. HRESULT hr = S_OK;
  59. BSTR bstrClusterName = NULL;
  60. size_t idxClusterDomain = 0;
  61. //
  62. // Get cluster hostname from handle.
  63. //
  64. hr = THR( HrGetClusterInformation( hClusterIn, &bstrClusterName, NULL ) );
  65. if ( FAILED( hr ) )
  66. {
  67. goto Cleanup;
  68. }
  69. //
  70. // Get domain from pcwszClusterFQIPIn.
  71. //
  72. hr = THR( HrFindDomainInFQN( pcwszClusterFQIPIn, &idxClusterDomain ) );
  73. if ( FAILED( hr ) )
  74. {
  75. goto Cleanup;
  76. }
  77. //
  78. // Make FQDN from cluster hostname and domain part of pcwszClusterFQIPIn.
  79. //
  80. hr = THR( HrMakeFQN( bstrClusterName, pcwszClusterFQIPIn + idxClusterDomain, true, pbstrFQDNOut ) );
  81. if ( FAILED( hr ) )
  82. {
  83. goto Cleanup;
  84. }
  85. Cleanup:
  86. TraceSysFreeString( bstrClusterName );
  87. HRETURN( hr );
  88. } //*** HrMakeClusterFQDN
  89. //////////////////////////////////////////////////////////////////////////////
  90. //++
  91. //
  92. // CConfigClusApi::S_HrCreateInstance
  93. //
  94. // Description:
  95. // Create a CConfigClusApi instance.
  96. //
  97. // Arguments:
  98. // None.
  99. //
  100. // Return Values:
  101. // S_OK
  102. // Success.
  103. //
  104. // E_POINTER
  105. // A passed in argument is NULL.
  106. //
  107. // E_OUTOFMEMORY
  108. // Out of memory.
  109. //
  110. // Other HRESULT error.
  111. //
  112. //--
  113. //////////////////////////////////////////////////////////////////////////////
  114. HRESULT
  115. CConfigClusApi::S_HrCreateInstance(
  116. IUnknown ** ppunkOut
  117. )
  118. {
  119. TraceFunc( "" );
  120. HRESULT hr = S_OK;
  121. CConfigClusApi * pcca = NULL;
  122. if ( ppunkOut == NULL )
  123. {
  124. hr = THR( E_POINTER );
  125. goto Cleanup;
  126. } // if:
  127. pcca = new CConfigClusApi;
  128. if ( pcca == NULL )
  129. {
  130. hr = THR( E_OUTOFMEMORY );
  131. goto Cleanup;
  132. } // if:
  133. hr = THR( pcca->TypeSafeQI( IUnknown, ppunkOut ) );
  134. if ( FAILED( hr ) )
  135. {
  136. goto Cleanup;
  137. }
  138. Cleanup:
  139. if ( pcca != NULL )
  140. {
  141. pcca->Release();
  142. } // if:
  143. HRETURN( hr );
  144. } //*** CConfigClusApi::S_HrCreateInstance
  145. //////////////////////////////////////////////////////////////////////////////
  146. //++
  147. //
  148. // CConfigClusApi::CConfigClusApi
  149. //
  150. // Description:
  151. // Constructor of the CConfigClusApi class. This initializes
  152. // the m_cRef variable to 1 instead of 0 to account of possible
  153. // QueryInterface failure in DllGetClassObject.
  154. //
  155. // Arguments:
  156. // None.
  157. //
  158. // Return Value:
  159. // None.
  160. //
  161. // Remarks:
  162. // None.
  163. //
  164. //--
  165. //////////////////////////////////////////////////////////////////////////////
  166. CConfigClusApi::CConfigClusApi( void )
  167. : m_cRef( 1 )
  168. {
  169. TraceFunc( "" );
  170. InterlockedIncrement( &g_cObjects );
  171. Assert( m_cRef == 1 );
  172. Assert( m_pcccb == NULL );
  173. Assert( IsEqualIID( m_clsidMajor, IID_NULL ) );
  174. Assert( m_bstrName == NULL );
  175. Assert( m_bstrBindingString == NULL );
  176. TraceFuncExit();
  177. } //*** CConfigClusApi::CConfigClusApi
  178. //////////////////////////////////////////////////////////////////////////////
  179. //++
  180. //
  181. // CConfigClusApi::~CConfigClusApi
  182. //
  183. // Description:
  184. // Destructor of the CConfigClusApi class.
  185. //
  186. // Arguments:
  187. // None.
  188. //
  189. // Return Value:
  190. // None.
  191. //
  192. // Remarks:
  193. // None.
  194. //
  195. //--
  196. //////////////////////////////////////////////////////////////////////////////
  197. CConfigClusApi::~CConfigClusApi( void )
  198. {
  199. TraceFunc( "" );
  200. if ( m_pcccb != NULL )
  201. {
  202. m_pcccb->Release();
  203. } // if:
  204. TraceSysFreeString( m_bstrName );
  205. TraceSysFreeString( m_bstrBindingString );
  206. InterlockedDecrement( &g_cObjects );
  207. TraceFuncExit();
  208. } //*** CConfigClusApi::~CConfigClusApi
  209. //*************************************************************************//
  210. /////////////////////////////////////////////////////////////////////////////
  211. // CConfigClusApi -- IUnknown interface.
  212. /////////////////////////////////////////////////////////////////////////////
  213. //////////////////////////////////////////////////////////////////////////////
  214. //++
  215. //
  216. // CConfigClusApi::QueryInterface
  217. //
  218. // Description:
  219. // Query this object for the passed in interface.
  220. //
  221. // Arguments:
  222. // riidIn
  223. // Id of interface requested.
  224. //
  225. // ppvOut
  226. // Pointer to the requested interface.
  227. //
  228. // Return Value:
  229. // S_OK
  230. // If the interface is available on this object.
  231. //
  232. // E_NOINTERFACE
  233. // If the interface is not available.
  234. //
  235. // E_POINTER
  236. // ppvOut was NULL.
  237. //
  238. // Remarks:
  239. // None.
  240. //
  241. //--
  242. //////////////////////////////////////////////////////////////////////////////
  243. STDMETHODIMP
  244. CConfigClusApi::QueryInterface(
  245. REFIID riidIn
  246. , void ** ppvOut
  247. )
  248. {
  249. TraceQIFunc( riidIn, ppvOut );
  250. HRESULT hr = S_OK;
  251. //
  252. // Validate arguments.
  253. //
  254. Assert( ppvOut != NULL );
  255. if ( ppvOut == NULL )
  256. {
  257. hr = THR( E_POINTER );
  258. goto Cleanup;
  259. }
  260. //
  261. // Handle known interfaces.
  262. //
  263. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  264. {
  265. *ppvOut = static_cast< IConfigurationConnection * >( this );
  266. } // if: IUnknown
  267. else if ( IsEqualIID( riidIn, IID_IConfigurationConnection ) )
  268. {
  269. *ppvOut = TraceInterface( __THISCLASS__, IConfigurationConnection, this, 0 );
  270. } // else if: IConfigClusApi
  271. else if ( IsEqualIID( riidIn, IID_IClusCfgServer ) )
  272. {
  273. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgServer, this, 0 );
  274. } // else if: IClusCfgServer
  275. else if ( IsEqualIID( riidIn, IID_IClusCfgCallback ) )
  276. {
  277. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgCallback, this, 0 );
  278. } // else if: IClusCfgCallback
  279. else if ( IsEqualIID( riidIn, IID_IClusCfgCapabilities ) )
  280. {
  281. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgCapabilities, this, 0 );
  282. } // else if: IClusCfgCapabilities
  283. else if ( IsEqualIID( riidIn, IID_IClusCfgVerify ) )
  284. {
  285. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgVerify, this, 0 );
  286. } // else if: IClusCfgVerify
  287. else
  288. {
  289. *ppvOut = NULL;
  290. hr = E_NOINTERFACE;
  291. } // else
  292. //
  293. // Add a reference to the interface if successful.
  294. //
  295. if ( SUCCEEDED( hr ) )
  296. {
  297. ((IUnknown *) *ppvOut)->AddRef();
  298. } // if: success
  299. Cleanup:
  300. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  301. } //*** CConfigClusApi::QueryInterface
  302. //////////////////////////////////////////////////////////////////////////////
  303. //++
  304. //
  305. // CConfigClusApi::AddRef
  306. //
  307. // Description:
  308. // Increment the reference count of this object by one.
  309. //
  310. // Arguments:
  311. // None.
  312. //
  313. // Return Value:
  314. // The new reference count.
  315. //
  316. // Remarks:
  317. // None.
  318. //
  319. //--
  320. //////////////////////////////////////////////////////////////////////////////
  321. STDMETHODIMP_( ULONG )
  322. CConfigClusApi::AddRef( void )
  323. {
  324. TraceFunc( "[IUnknown]" );
  325. InterlockedIncrement( &m_cRef );
  326. CRETURN( m_cRef );
  327. } //*** CConfigClusApi::AddRef
  328. //////////////////////////////////////////////////////////////////////////////
  329. //++
  330. //
  331. // CConfigClusApi::Release
  332. //
  333. // Description:
  334. // Decrement the reference count of this object by one.
  335. //
  336. // Arguments:
  337. // None.
  338. //
  339. // Return Value:
  340. // The new reference count.
  341. //
  342. // Remarks:
  343. // None.
  344. //
  345. //--
  346. //////////////////////////////////////////////////////////////////////////////
  347. STDMETHODIMP_( ULONG )
  348. CConfigClusApi::Release( void )
  349. {
  350. TraceFunc( "[IUnknown]" );
  351. LONG cRef;
  352. cRef = InterlockedDecrement( &m_cRef );
  353. if ( cRef == 0 )
  354. {
  355. TraceDo( delete this );
  356. }
  357. CRETURN( cRef );
  358. } //*** CConfigClusApi::Release
  359. //****************************************************************************
  360. //
  361. // IConfigClusApi
  362. //
  363. //****************************************************************************
  364. //////////////////////////////////////////////////////////////////////////////
  365. //++
  366. //
  367. // CConfigClusApi::ConnectTo
  368. //
  369. // Description:
  370. //
  371. //
  372. // Arguments
  373. // OBJECTCOOKIE cookieIn, The Object Cookie.
  374. // REFIID riidIn, The IID. of the interface
  375. // LPUNKNOWN * ppunkOut The return pointer
  376. //
  377. // Description:
  378. // Connects to the given object.
  379. //
  380. // Return Values:
  381. // HRESULT
  382. //
  383. //--
  384. //////////////////////////////////////////////////////////////////////////////
  385. STDMETHODIMP
  386. CConfigClusApi::ConnectTo(
  387. OBJECTCOOKIE cookieIn
  388. )
  389. {
  390. TraceFunc( "[IConfigClusApi]" );
  391. HRESULT hr = S_OK;
  392. IServiceProvider * psp = NULL;
  393. IObjectManager * pom = NULL;
  394. IStandardInfo * psi = NULL;
  395. IConnectionPoint * pcp = NULL;
  396. IConnectionPointContainer * pcpc = NULL;
  397. BSTR bstrClusterFQDN = NULL;
  398. //
  399. // Retrieve the managers needs for the task ahead.
  400. //
  401. hr = THR( CoCreateInstance( CLSID_ServiceManager,
  402. NULL,
  403. CLSCTX_INPROC_SERVER,
  404. IID_IServiceProvider,
  405. reinterpret_cast< void ** >( &psp )
  406. ) );
  407. if ( FAILED( hr ) )
  408. goto Cleanup;
  409. hr = THR( psp->QueryService( CLSID_ObjectManager,
  410. TypeSafeParams( IObjectManager, &pom )
  411. ) );
  412. if ( FAILED( hr ) )
  413. goto Cleanup;
  414. hr = THR( psp->QueryService( CLSID_NotificationManager,
  415. TypeSafeParams( IConnectionPointContainer, &pcpc )
  416. ) );
  417. if ( FAILED( hr ) )
  418. goto Cleanup;
  419. psp->Release(); // release promptly
  420. psp = NULL;
  421. //
  422. // Find the callback interface connection point.
  423. //
  424. hr = THR( pcpc->FindConnectionPoint( IID_IClusCfgCallback, &pcp ) );
  425. if ( FAILED( hr ) )
  426. goto Cleanup;
  427. hr = THR( pcp->TypeSafeQI( IClusCfgCallback, &m_pcccb ) );
  428. if ( FAILED( hr ) )
  429. goto Cleanup;
  430. //
  431. // Get the name of the node to contact.
  432. //
  433. hr = THR( pom->GetObject( DFGUID_StandardInfo,
  434. cookieIn,
  435. reinterpret_cast< IUnknown ** >( &psi )
  436. ) );
  437. if ( FAILED( hr ) )
  438. {
  439. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectTo_GetObject_Failed, hr );
  440. goto Cleanup;
  441. }
  442. TraceSysFreeString( m_bstrName );
  443. m_bstrName = NULL;
  444. hr = THR( psi->GetName( &m_bstrName ) );
  445. if ( FAILED( hr ) )
  446. {
  447. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectTo_GetName_Failed, hr );
  448. goto Cleanup;
  449. }
  450. //
  451. // Find out the type of object we are going to connect to (cluster or node).
  452. //
  453. hr = THR( psi->GetType( &m_clsidType ) );
  454. if ( FAILED( hr ) )
  455. {
  456. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectTo_GetType_Failed, hr );
  457. goto Cleanup;
  458. }
  459. //
  460. // Figure out where to logging information in the UI.
  461. //
  462. if ( IsEqualIID( m_clsidType, CLSID_NodeType ) )
  463. {
  464. CopyMemory( &m_clsidMajor, &TASKID_Major_Establish_Connection, sizeof(m_clsidMajor) );
  465. }
  466. else if ( IsEqualIID( m_clsidType, CLSID_ClusterConfigurationType ) )
  467. {
  468. CopyMemory( &m_clsidMajor, &TASKID_Major_Checking_For_Existing_Cluster, sizeof(m_clsidMajor) );
  469. }
  470. else
  471. {
  472. hr = THR( E_INVALIDARG );
  473. goto Cleanup;
  474. }
  475. //
  476. // Create a binding string.
  477. //
  478. TraceSysFreeString( m_bstrBindingString );
  479. m_bstrBindingString = NULL;
  480. hr = THR( HrFQNToBindingString( m_pcccb, &m_clsidMajor, m_bstrName, &m_bstrBindingString ) );
  481. if ( FAILED( hr ) )
  482. {
  483. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectTo_CreateBinding_Failed, hr );
  484. goto Cleanup;
  485. }
  486. //
  487. // Connect to cluster/node.
  488. //
  489. m_hCluster = OpenCluster( m_bstrBindingString );
  490. if ( m_hCluster == NULL )
  491. {
  492. hr = HRESULT_FROM_WIN32( TW32( GetLastError() ) );
  493. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectTo_OpenCluster_Failed, hr );
  494. goto Cleanup;
  495. }
  496. //
  497. // Ensure standard info object's name is one that subsequent lookups in the object manager will find.
  498. //
  499. hr = STHR( HrFQNIsFQIP( m_bstrName ) );
  500. if ( FAILED( hr ) )
  501. {
  502. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectTo_HrFQNIsFQIP_Failed, hr );
  503. goto Cleanup;
  504. }
  505. else if ( hr == S_OK )
  506. {
  507. hr = THR( HrMakeClusterFQDN( m_hCluster, m_bstrName, &bstrClusterFQDN ) );
  508. if ( FAILED( hr ) )
  509. {
  510. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectTo_HrMakeClusterFQDN_Failed, hr );
  511. goto Cleanup;
  512. }
  513. TraceSysFreeString( m_bstrName );
  514. m_bstrName = bstrClusterFQDN;
  515. bstrClusterFQDN = NULL;
  516. hr = THR( psi->SetName( m_bstrName ) );
  517. if ( FAILED( hr ) )
  518. {
  519. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectTo_SetName_Failed, hr );
  520. goto Cleanup;
  521. }
  522. }
  523. else
  524. {
  525. //
  526. // HrFQNIsFQIP returned S_FALSE, but this function should return S_OK.
  527. //
  528. hr = S_OK;
  529. }
  530. Cleanup:
  531. // This should be released first... always!
  532. if ( psp != NULL )
  533. {
  534. psp->Release();
  535. } // if: psp
  536. if ( pom != NULL )
  537. {
  538. pom->Release();
  539. } // if: pom
  540. if ( psi != NULL )
  541. {
  542. psi->Release();
  543. } // if: psi
  544. if ( pcpc != NULL )
  545. {
  546. pcpc->Release();
  547. } // if: pcpc
  548. if ( pcp != NULL )
  549. {
  550. pcp->Release();
  551. } // if: pcp
  552. TraceSysFreeString( bstrClusterFQDN );
  553. HRETURN( hr );
  554. } //*** CConfigClusApi::ConnectTo
  555. //////////////////////////////////////////////////////////////////////////////
  556. //++
  557. //
  558. // CConfigClusApi::ConnectToObject
  559. //
  560. // Description:
  561. //
  562. // Arguments
  563. // OBJECTCOOKIE cookieIn, The Object Cookie.
  564. // REFIID riidIn, The IID. of the interface
  565. // LPUNKNOWN * ppunkOut The return pointer
  566. //
  567. // Description:
  568. // Connects to the given object.
  569. //
  570. // Return Values:
  571. // HRESULT
  572. //
  573. //--
  574. //////////////////////////////////////////////////////////////////////////////
  575. STDMETHODIMP
  576. CConfigClusApi::ConnectToObject(
  577. OBJECTCOOKIE cookieIn,
  578. REFIID riidIn,
  579. LPUNKNOWN * ppunkOut
  580. )
  581. {
  582. TraceFunc( "[IConfigClusApi]" );
  583. HRESULT hr;
  584. CLSID clsid;
  585. IServiceProvider * psp;
  586. IObjectManager * pom = NULL;
  587. IStandardInfo * psi = NULL;
  588. //
  589. // Check the parameters.
  590. //
  591. if ( ppunkOut == NULL )
  592. {
  593. hr = THR( E_POINTER );
  594. goto Cleanup;
  595. }
  596. //
  597. // Check my state.
  598. //
  599. if ( m_hCluster == NULL )
  600. goto NotInitialized;
  601. //
  602. // Retrieve the managers needs for the task ahead.
  603. //
  604. hr = THR( CoCreateInstance( CLSID_ServiceManager,
  605. NULL,
  606. CLSCTX_INPROC_SERVER,
  607. IID_IServiceProvider,
  608. reinterpret_cast< void ** >( &psp )
  609. ) );
  610. if ( FAILED( hr ) )
  611. goto Cleanup;
  612. hr = THR( psp->QueryService( CLSID_ObjectManager,
  613. TypeSafeParams( IObjectManager, &pom )
  614. ) );
  615. psp->Release(); // release promptly
  616. if ( FAILED( hr ) )
  617. goto Cleanup;
  618. //
  619. // Retrieve the type of the object.
  620. //
  621. hr = THR( pom->GetObject( DFGUID_StandardInfo,
  622. cookieIn,
  623. reinterpret_cast< IUnknown ** >( &psi )
  624. ) );
  625. if ( FAILED( hr ) )
  626. {
  627. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectToObject_GetObject_Failed, hr );
  628. goto Cleanup;
  629. }
  630. hr = THR( psi->GetType( &clsid ) );
  631. if ( FAILED( hr ) )
  632. {
  633. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectToObject_GetType_Failed, hr );
  634. goto Cleanup;
  635. }
  636. if ( !IsEqualIID( clsid, CLSID_NodeType )
  637. && !IsEqualIID( clsid, CLSID_ClusterType )
  638. )
  639. {
  640. hr = THR( E_INVALIDARG );
  641. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectToObject_InvalidCookie, hr );
  642. goto Cleanup;
  643. }
  644. //
  645. // Return the requested interface.
  646. //
  647. hr = THR( QueryInterface( riidIn, reinterpret_cast<void**>( ppunkOut ) ) );
  648. if ( FAILED( hr ) )
  649. {
  650. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectToObject_QI_Failed, hr );
  651. goto Cleanup;
  652. }
  653. Cleanup:
  654. if ( pom != NULL )
  655. {
  656. pom->Release();
  657. } // if: pom
  658. if ( psi != NULL )
  659. {
  660. psi->Release();
  661. } // if: psi
  662. HRETURN( hr );
  663. NotInitialized:
  664. hr = THR( OLE_E_BLANK ); // the error text is better than the message id.
  665. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_ConnectToObject_NotInitialized, hr );
  666. goto Cleanup;
  667. } //*** CConfigClusApi::ConnectToObject
  668. //****************************************************************************
  669. //
  670. // IClusCfgServer
  671. //
  672. //****************************************************************************
  673. //////////////////////////////////////////////////////////////////////////////
  674. //++
  675. //
  676. // CConfigClusApi::GetClusterNodeInfo
  677. //
  678. // Description:
  679. //
  680. // Arguments
  681. // IClusCfgNodeInfo ** ppClusterNodeInfoOut The Node Info object.
  682. //
  683. // Description:
  684. // Returns the Node Info of the Cluster.
  685. //
  686. // Return Values:
  687. // HRESULT
  688. //
  689. //--
  690. //////////////////////////////////////////////////////////////////////////////
  691. STDMETHODIMP
  692. CConfigClusApi::GetClusterNodeInfo(
  693. IClusCfgNodeInfo ** ppClusterNodeInfoOut
  694. )
  695. {
  696. TraceFunc( "[IClusCfgServer]" );
  697. HRESULT hr = S_OK;
  698. size_t idxDomain = 0;
  699. BSTR bstrNodeHostname = NULL;
  700. IUnknown * punk = NULL;
  701. //
  702. // Check for valid parameters.
  703. //
  704. if ( ppClusterNodeInfoOut == NULL )
  705. {
  706. hr = THR( E_POINTER );
  707. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterNodeInfo_InvalidPointer, hr );
  708. goto Cleanup;
  709. }
  710. //
  711. // Check my state
  712. //
  713. if ( m_hCluster == NULL )
  714. {
  715. hr = THR( OLE_E_BLANK ); // the error text is better than the message id.
  716. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterNodeInfo_NotInitialized, hr );
  717. goto Cleanup;
  718. }
  719. //
  720. // Figure out the domain name.
  721. //
  722. hr = THR( HrFindDomainInFQN( m_bstrName, &idxDomain ) );
  723. if ( FAILED( hr ) )
  724. {
  725. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterNodeInfo_HrFindDomainInFQN, hr );
  726. goto Cleanup;
  727. }
  728. //
  729. // Use node hostname only if connecting to node; otherwise, leave hostname null.
  730. //
  731. if ( IsEqualIID( m_clsidType, CLSID_NodeType ) )
  732. {
  733. hr = THR( HrExtractPrefixFromFQN( m_bstrName, &bstrNodeHostname ) );
  734. if ( FAILED( hr ) )
  735. {
  736. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterNodeInfo_HrExtractPrefixFromFQN, hr );
  737. goto Cleanup;
  738. }
  739. }
  740. //
  741. // Now create the object.
  742. //
  743. hr = THR( CProxyCfgNodeInfo::S_HrCreateInstance( &punk,
  744. static_cast< IConfigurationConnection * >( this ),
  745. &m_hCluster,
  746. &m_clsidMajor,
  747. bstrNodeHostname,
  748. m_bstrName + idxDomain
  749. ) );
  750. if ( FAILED( hr ) )
  751. {
  752. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterNodeInfo_Create_CProxyCfgNodeInfo, hr );
  753. goto Cleanup;
  754. }
  755. //
  756. // Done. Return the interface.
  757. //
  758. hr = THR( punk->TypeSafeQI( IClusCfgNodeInfo, ppClusterNodeInfoOut ) );
  759. if ( FAILED( hr ) )
  760. {
  761. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterNodeInfo_QI_Failed, hr );
  762. goto Cleanup;
  763. }
  764. Cleanup:
  765. TraceSysFreeString( bstrNodeHostname );
  766. if ( punk != NULL )
  767. {
  768. punk->Release();
  769. } // if:
  770. HRETURN( hr );
  771. } //*** CConfigClusApi::GetClusterNodeInfo
  772. //////////////////////////////////////////////////////////////////////////////
  773. //++
  774. //
  775. // CConfigClusApi::GetManagedResourcesEnum
  776. //
  777. // Description:
  778. //
  779. // Arguments
  780. // IEnumClusCfgManagedResources ** ppEnumManagedResourcesOut
  781. // The Resources enumerator for the clusters.
  782. //
  783. // Description:
  784. // Returns the resources enumerator for the cluster.
  785. //
  786. // Return Values:
  787. // HRESULT
  788. //
  789. //--
  790. //////////////////////////////////////////////////////////////////////////////
  791. STDMETHODIMP
  792. CConfigClusApi::GetManagedResourcesEnum(
  793. IEnumClusCfgManagedResources ** ppEnumManagedResourcesOut
  794. )
  795. {
  796. TraceFunc( "[IClusCfgServer]" );
  797. HRESULT hr;
  798. IUnknown * punk = NULL;
  799. //
  800. // Check for valid parameters.
  801. //
  802. if ( ppEnumManagedResourcesOut == NULL )
  803. goto InvalidPointer;
  804. //
  805. // Check my state
  806. //
  807. if ( m_hCluster == NULL )
  808. goto NotInitialized;
  809. //
  810. // Create the resource enumer.
  811. //
  812. hr = THR( CEnumCfgResources::S_HrCreateInstance( &punk, static_cast< IConfigurationConnection * >( this ), &m_hCluster, &m_clsidMajor ) );
  813. if ( FAILED( hr ) )
  814. {
  815. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetManagedResourcesEnum_Create_CEnumCfgResources_Failed, hr );
  816. goto Cleanup;
  817. }
  818. //
  819. // QI for the interface.
  820. //
  821. hr = THR( punk->TypeSafeQI( IEnumClusCfgManagedResources, ppEnumManagedResourcesOut ) );
  822. {
  823. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetManagedResourcesEnum_QI_Failed, hr );
  824. goto Cleanup;
  825. }
  826. Cleanup:
  827. if ( punk != NULL )
  828. {
  829. punk->Release();
  830. }
  831. HRETURN( hr );
  832. NotInitialized:
  833. hr = THR( OLE_E_BLANK ); // the error text is better than the message id.
  834. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetManagedResourcesEnum_NotInitialized, hr );
  835. goto Cleanup;
  836. InvalidPointer:
  837. hr = THR( E_POINTER );
  838. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetManagedResourcesEnum_InvalidPointer, hr );
  839. goto Cleanup;
  840. } //*** CConfigClusApi::GetManagedResourcesEnum
  841. //////////////////////////////////////////////////////////////////////////////
  842. //++
  843. //
  844. // CConfigClusApi::GetNetworksEnum
  845. //
  846. // Description:
  847. // Returns the network enumerator for the cluster.
  848. //
  849. // Arguments:
  850. // IEnumClusCfgNetworks ** ppEnumNetworksOut The Network Enumerator
  851. //
  852. // Return Values:
  853. // HRESULT
  854. //
  855. //--
  856. //////////////////////////////////////////////////////////////////////////////
  857. STDMETHODIMP
  858. CConfigClusApi::GetNetworksEnum(
  859. IEnumClusCfgNetworks ** ppEnumNetworksOut
  860. )
  861. {
  862. TraceFunc( "[IClusCfgServer]" );
  863. HRESULT hr;
  864. IUnknown * punk = NULL;
  865. //
  866. // Check for valid parameters.
  867. //
  868. if ( ppEnumNetworksOut == NULL )
  869. goto InvalidPointer;
  870. //
  871. // Check my state
  872. //
  873. if ( m_hCluster == NULL )
  874. goto NotInitialized;
  875. //
  876. // Create an instance of the enumeratore and initialize it.
  877. //
  878. hr = THR( CEnumCfgNetworks::S_HrCreateInstance( &punk, static_cast< IConfigurationConnection * >( this ), &m_hCluster, &m_clsidMajor ) );
  879. if ( FAILED( hr ) )
  880. {
  881. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetNetworksEnum_Create_CEnumCfgNetworks_Failed, hr );
  882. goto Cleanup;
  883. }
  884. //
  885. // Return the Enum interface.
  886. //
  887. hr = THR( punk->TypeSafeQI( IEnumClusCfgNetworks , ppEnumNetworksOut) );
  888. if ( FAILED( hr ) )
  889. {
  890. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetNetworksEnum_QI_Failed, hr );
  891. goto Cleanup;
  892. }
  893. Cleanup:
  894. if ( punk != NULL )
  895. {
  896. punk->Release();
  897. } // if:
  898. HRETURN( hr );
  899. NotInitialized:
  900. hr = THR( OLE_E_BLANK ); // the error text is better than the message id.
  901. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetNetworksEnum_NotInitialized, hr );
  902. goto Cleanup;
  903. InvalidPointer:
  904. hr = THR( E_POINTER );
  905. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetNetworksEnum_InvalidPointer, hr );
  906. goto Cleanup;
  907. } //*** CConfigClusApi::GetNetworksEnum
  908. //////////////////////////////////////////////////////////////////////////////
  909. //++
  910. //
  911. // CConfigClusApi::CommitChanges
  912. //
  913. // Description:
  914. // NOT IMPLEMENTED.
  915. //
  916. // Arguments:
  917. //
  918. // Return Values:
  919. // S_FALSE
  920. //
  921. //--
  922. //////////////////////////////////////////////////////////////////////////////
  923. STDMETHODIMP
  924. CConfigClusApi::CommitChanges( void )
  925. {
  926. TraceFunc( "[IClusCfgServer]" );
  927. HRESULT hr = THR( E_NOTIMPL );
  928. HRETURN( hr );
  929. } //*** CConfigClusApi::CommitChanges()
  930. //////////////////////////////////////////////////////////////////////////////
  931. //++
  932. //
  933. // CConfigClusApi::GetBindingString
  934. //
  935. // Description:
  936. // Get the binding string.
  937. //
  938. // Arguments:
  939. //
  940. // Return Values:
  941. // S_FALSE
  942. //
  943. //--
  944. //////////////////////////////////////////////////////////////////////////////
  945. STDMETHODIMP
  946. CConfigClusApi::GetBindingString( BSTR * pbstrBindingStringOut )
  947. {
  948. TraceFunc1( "[IClusCfgServer] pbstrBindingStringOut = %p", pbstrBindingStringOut );
  949. HRESULT hr = S_FALSE;
  950. if ( pbstrBindingStringOut == NULL )
  951. {
  952. hr = THR( E_POINTER );
  953. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetBindingString_InvalidPointer, hr );
  954. goto Cleanup;
  955. }
  956. // If local server, then there isn't a binding context.
  957. if ( m_bstrBindingString == NULL )
  958. {
  959. Assert( hr == S_FALSE );
  960. goto Cleanup;
  961. }
  962. *pbstrBindingStringOut = SysAllocString( m_bstrBindingString );
  963. if ( *pbstrBindingStringOut == NULL )
  964. {
  965. hr = THR( E_OUTOFMEMORY );
  966. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetBindingString_OutOfMemory, hr );
  967. goto Cleanup;
  968. }
  969. hr = S_OK;
  970. Cleanup:
  971. HRETURN( hr );
  972. } //*** CConfigClusApi::GetBindingString
  973. //////////////////////////////////////////////////////////////////////////////
  974. //++
  975. //
  976. // CConfigClusApi::SetBindingString
  977. //
  978. // Description:
  979. // Set the binding string.
  980. //
  981. // Arguments:
  982. //
  983. // Return Values:
  984. // S_FALSE
  985. //
  986. //--
  987. //////////////////////////////////////////////////////////////////////////////
  988. STDMETHODIMP
  989. CConfigClusApi::SetBindingString( LPCWSTR pcszBindingStringIn )
  990. {
  991. TraceFunc( "[IClusCfgServer]" );
  992. HRESULT hr = S_OK;
  993. BSTR bstr = NULL;
  994. if ( pcszBindingStringIn == NULL )
  995. {
  996. hr = THR( E_INVALIDARG );
  997. goto Cleanup;
  998. } // if:
  999. bstr = TraceSysAllocString( pcszBindingStringIn );
  1000. if ( bstr == NULL )
  1001. {
  1002. hr = THR( E_OUTOFMEMORY );
  1003. goto Cleanup;
  1004. } // if:
  1005. TraceSysFreeString( m_bstrBindingString );
  1006. m_bstrBindingString = bstr;
  1007. Cleanup:
  1008. HRETURN( hr );
  1009. } //*** CConfigClusApi::SetBindingString
  1010. //****************************************************************************
  1011. //
  1012. // IClusCfgCapabilities
  1013. //
  1014. //****************************************************************************
  1015. //////////////////////////////////////////////////////////////////////////////
  1016. //++
  1017. //
  1018. // CConfigClusApi::CanNodeBeClustered
  1019. //
  1020. // Description:
  1021. // Returns whether the node can be clustered.
  1022. //
  1023. // Arguments:
  1024. //
  1025. // Return Values:
  1026. // S_OK True
  1027. // S_FALSE False
  1028. //
  1029. //--
  1030. //////////////////////////////////////////////////////////////////////////////
  1031. STDMETHODIMP
  1032. CConfigClusApi::CanNodeBeClustered( void )
  1033. {
  1034. TraceFunc( "[IClusCfgCapabilities]" );
  1035. HRESULT hr = S_OK;
  1036. HRETURN( hr );
  1037. } //*** CConfigClusApi::CanNodeBeClustered
  1038. //****************************************************************************
  1039. //
  1040. // IClusCfgVerify
  1041. //
  1042. //****************************************************************************
  1043. //////////////////////////////////////////////////////////////////////////////
  1044. //++
  1045. //
  1046. // CConfigClusApi::VerifyCredentials
  1047. //
  1048. // Description:
  1049. // Validate the passed in credentials.
  1050. //
  1051. // Arguments:
  1052. //
  1053. // Return Value:
  1054. // S_OK
  1055. // The credentials are valid.
  1056. //
  1057. // S_FALSE
  1058. // The credentials are not valid.
  1059. //
  1060. // Remarks:
  1061. // None.
  1062. //
  1063. //--
  1064. //////////////////////////////////////////////////////////////////////////////
  1065. STDMETHODIMP
  1066. CConfigClusApi::VerifyCredentials(
  1067. LPCWSTR pcszNameIn,
  1068. LPCWSTR pcszDomainIn,
  1069. LPCWSTR pcszPasswordIn
  1070. )
  1071. {
  1072. TraceFunc( "[IClusCfgVerify]" );
  1073. //
  1074. // Trying to use the credentials on the client machine adds no value, and
  1075. // can lead to false errors when the client's domain does not trust the
  1076. // the cluster service account's domain. The Windows Server 2003 nodes being
  1077. // added to the cluster will perform the proper credential validation.
  1078. //
  1079. UNREFERENCED_PARAMETER( pcszNameIn );
  1080. UNREFERENCED_PARAMETER( pcszDomainIn );
  1081. UNREFERENCED_PARAMETER( pcszPasswordIn );
  1082. HRETURN( S_OK );
  1083. } //*** CConfigClusApi::VerifyCredentials
  1084. //////////////////////////////////////////////////////////////////////////////
  1085. //++
  1086. //
  1087. // CConfigClusApi::VerifyConnectionToCluster
  1088. //
  1089. // Description:
  1090. // Verify that that this server is the same as the passed in server.
  1091. //
  1092. // Arguments:
  1093. // bstrServerNameIn
  1094. //
  1095. // Return Value:
  1096. // S_OK
  1097. // This is the server.
  1098. //
  1099. // S_FALSE
  1100. // This is not the server.
  1101. //
  1102. // other HRESULTs
  1103. // The call failed.
  1104. //
  1105. // Remarks:
  1106. // None.
  1107. //
  1108. //--
  1109. //////////////////////////////////////////////////////////////////////////////
  1110. STDMETHODIMP
  1111. CConfigClusApi::VerifyConnectionToCluster( LPCWSTR pcszClusterNameIn )
  1112. {
  1113. TraceFunc1( "pcszClusterNameIn = '%ls'", pcszClusterNameIn );
  1114. HRESULT hr = THR( E_NOTIMPL );
  1115. HRETURN( hr );
  1116. } // CConfigClusApi::VerifyConnection
  1117. //////////////////////////////////////////////////////////////////////////////
  1118. //++
  1119. //
  1120. // CConfigClusApi::VerifyConnectionToNode
  1121. //
  1122. // Description:
  1123. // Verify that that this server is the same as the passed in server.
  1124. //
  1125. // Arguments:
  1126. // bstrServerNameIn
  1127. //
  1128. // Return Value:
  1129. // S_OK
  1130. // This is the server.
  1131. //
  1132. // S_FALSE
  1133. // This is not the server.
  1134. //
  1135. // other HRESULTs
  1136. // The call failed.
  1137. //
  1138. // Remarks:
  1139. // None.
  1140. //
  1141. //--
  1142. //////////////////////////////////////////////////////////////////////////////
  1143. STDMETHODIMP
  1144. CConfigClusApi::VerifyConnectionToNode( LPCWSTR pcszNodeNameIn )
  1145. {
  1146. TraceFunc1( "pcszNodeNameIn = '%ls'", pcszNodeNameIn );
  1147. HRESULT hr = THR( E_NOTIMPL );
  1148. HRETURN( hr );
  1149. } // CConfigClusApi::VerifyConnection
  1150. //****************************************************************************
  1151. //
  1152. // IClusCfgCallback
  1153. //
  1154. //****************************************************************************
  1155. //////////////////////////////////////////////////////////////////////////////
  1156. //++
  1157. //
  1158. // CConfigClusApi::SendStatusReport
  1159. //
  1160. // Description:
  1161. //
  1162. // Arguments:
  1163. //
  1164. // Return Value:
  1165. //
  1166. // Remarks:
  1167. // None.
  1168. //
  1169. //--
  1170. //////////////////////////////////////////////////////////////////////////////
  1171. STDMETHODIMP
  1172. CConfigClusApi::SendStatusReport(
  1173. LPCWSTR pcszNodeNameIn
  1174. , CLSID clsidTaskMajorIn
  1175. , CLSID clsidTaskMinorIn
  1176. , ULONG ulMinIn
  1177. , ULONG ulMaxIn
  1178. , ULONG ulCurrentIn
  1179. , HRESULT hrStatusIn
  1180. , LPCWSTR pcszDescriptionIn
  1181. , FILETIME * pftTimeIn
  1182. , LPCWSTR pcszReferenceIn
  1183. )
  1184. {
  1185. TraceFunc( "[IClusCfgCallback]" );
  1186. HRESULT hr = S_OK;
  1187. FILETIME ft;
  1188. if ( pcszNodeNameIn == NULL )
  1189. {
  1190. pcszNodeNameIn = m_bstrName;
  1191. }
  1192. if ( pftTimeIn == NULL )
  1193. {
  1194. GetSystemTimeAsFileTime( &ft );
  1195. pftTimeIn = &ft;
  1196. } // if:
  1197. if ( m_pcccb != NULL )
  1198. {
  1199. hr = THR( m_pcccb->SendStatusReport( pcszNodeNameIn,
  1200. clsidTaskMajorIn,
  1201. clsidTaskMinorIn,
  1202. ulMinIn,
  1203. ulMaxIn,
  1204. ulCurrentIn,
  1205. hrStatusIn,
  1206. pcszDescriptionIn,
  1207. pftTimeIn,
  1208. pcszReferenceIn
  1209. ) );
  1210. } // if:
  1211. HRETURN( hr );
  1212. } //*** CConfigClusApi::SendStatusReport