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.

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