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.

740 lines
24 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // NetName.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CNetworkNameParamsPage class.
  10. //
  11. // Author:
  12. // David Potter (davidp) June 28, 1996
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "CluAdmX.h"
  21. #include "ExtObj.h"
  22. #include "NetName.h"
  23. #include "DDxDDv.h"
  24. #include "ExcOper.h"
  25. #include "ClusName.h"
  26. #include "HelpData.h" // for g_rghelpmap*
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CNetworkNameParamsPage property page
  34. /////////////////////////////////////////////////////////////////////////////
  35. IMPLEMENT_DYNCREATE(CNetworkNameParamsPage, CBasePropertyPage)
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Message Maps
  38. BEGIN_MESSAGE_MAP(CNetworkNameParamsPage, CBasePropertyPage)
  39. //{{AFX_MSG_MAP(CNetworkNameParamsPage)
  40. ON_EN_CHANGE(IDC_PP_NETNAME_PARAMS_NAME, OnChangeName)
  41. ON_BN_CLICKED(IDC_PP_NETNAME_PARAMS_RENAME, OnRename)
  42. ON_BN_CLICKED(IDC_PP_NETNAME_PARAMS_CHECKBOX_DNS, OnRequireDNS)
  43. ON_BN_CLICKED(IDC_PP_NETNAME_PARAMS_CHECKBOX_KERBEROS, CBasePropertyPage::OnChangeCtrl)
  44. //}}AFX_MSG_MAP
  45. // TODO: Modify the following lines to represent the data displayed on this page.
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. //++
  49. //
  50. // CNetworkNameParamsPage::CNetworkNameParamsPage
  51. //
  52. // Routine Description:
  53. // Default constructor.
  54. //
  55. // Arguments:
  56. // None.
  57. //
  58. // Return Value:
  59. // None.
  60. //
  61. //--
  62. /////////////////////////////////////////////////////////////////////////////
  63. CNetworkNameParamsPage::CNetworkNameParamsPage(void)
  64. : CBasePropertyPage(g_aHelpIDs_IDD_PP_NETNAME_PARAMETERS, g_aHelpIDs_IDD_WIZ_NETNAME_PARAMETERS)
  65. {
  66. // TODO: Modify the following lines to represent the data displayed on this page.
  67. //{{AFX_DATA_INIT(CNetworkNameParamsPage)
  68. m_strName = _T("");
  69. m_strPrevName = _T("");
  70. m_nRequireDNS = BST_UNCHECKED;
  71. m_nRequireKerberos = BST_UNCHECKED;
  72. m_dwNetBIOSStatus = 0;
  73. m_dwDNSStatus = 0;
  74. m_dwKerberosStatus = 0;
  75. //}}AFX_DATA_INIT
  76. // Setup the property array.
  77. {
  78. m_rgProps[epropName].Set(REGPARAM_NETNAME_NAME, m_strName, m_strPrevName);
  79. m_rgProps[epropRequireDNS].Set(REGPARAM_NETNAME_REQUIRE_DNS, m_nRequireDNS, m_nPrevRequireDNS);
  80. m_rgProps[epropRequireKerberos].Set(REGPARAM_NETNAME_REQUIRE_KERBEROS, m_nRequireKerberos, m_nPrevRequireKerberos);
  81. m_rgProps[epropStatusNetBIOS].Set(REGPARAM_NETNAME_STATUS_NETBIOS, m_dwNetBIOSStatus, m_dwPrevNetBIOSStatus);
  82. m_rgProps[epropStatusDNS].Set(REGPARAM_NETNAME_STATUS_DNS, m_dwDNSStatus, m_dwPrevDNSStatus);
  83. m_rgProps[epropStatusKerberos].Set(REGPARAM_NETNAME_STATUS_KERBEROS, m_dwKerberosStatus, m_dwPrevKerberosStatus);
  84. } // Setup the property array
  85. m_dwFlags = 0;
  86. m_iddPropertyPage = IDD_PP_NETNAME_PARAMETERS;
  87. m_iddWizardPage = IDD_WIZ_NETNAME_PARAMETERS;
  88. } //*** CNetworkNameParamsPage::CNetworkNameParamsPage()
  89. /////////////////////////////////////////////////////////////////////////////
  90. //++
  91. //
  92. // CNetworkNameParamsPage::HrInit
  93. //
  94. // Routine Description:
  95. // Initialize the page.
  96. //
  97. // Arguments:
  98. // peo [IN OUT] Pointer to the extension object.
  99. //
  100. // Return Value:
  101. // S_OK Page initialized successfully.
  102. // hr Page failed to initialize.
  103. //
  104. //--
  105. /////////////////////////////////////////////////////////////////////////////
  106. HRESULT CNetworkNameParamsPage::HrInit(IN OUT CExtObject * peo)
  107. {
  108. HRESULT hr;
  109. CWaitCursor wc;
  110. DWORD sc;
  111. DWORD cbReturned;
  112. // Call the base class method.
  113. // This populates the m_rgProps struct.
  114. hr = CBasePropertyPage::HrInit(peo);
  115. if (!FAILED(hr))
  116. {
  117. m_strPrevName = m_strName;
  118. // Read the flags for this resource.
  119. sc = ClusterResourceControl(
  120. Peo()->PrdResData()->m_hresource,
  121. NULL,
  122. CLUSCTL_RESOURCE_GET_FLAGS,
  123. NULL,
  124. NULL,
  125. &m_dwFlags,
  126. sizeof(m_dwFlags),
  127. &cbReturned
  128. );
  129. if (sc != ERROR_SUCCESS)
  130. {
  131. CNTException nte(sc, NULL, NULL, FALSE /*bAutoDelete*/);
  132. nte.ReportError();
  133. nte.Delete();
  134. } // if: error retrieving data
  135. else
  136. {
  137. ASSERT(cbReturned == sizeof(m_dwFlags));
  138. } // else: data retrieved successfully
  139. } // if: base class init was successful
  140. return hr;
  141. } //*** CNetworkNameParamsPage::HrInit()
  142. /////////////////////////////////////////////////////////////////////////////
  143. //++
  144. //
  145. // CNetworkNameParamsPage::DoDataExchange
  146. //
  147. // Routine Description:
  148. // Do data exchange between the dialog and the class.
  149. //
  150. // Arguments:
  151. // pDX [IN OUT] Data exchange object
  152. //
  153. // Return Value:
  154. // None.
  155. //
  156. //--
  157. /////////////////////////////////////////////////////////////////////////////
  158. void CNetworkNameParamsPage::DoDataExchange(CDataExchange * pDX)
  159. {
  160. DWORD scError;
  161. BOOL bError;
  162. if (!pDX->m_bSaveAndValidate || !BSaved())
  163. {
  164. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  165. CWaitCursor wc;
  166. CString strNetName;
  167. // TODO: Modify the following lines to represent the data displayed on this page.
  168. //{{AFX_DATA_MAP(CNetworkNameParamsPage)
  169. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_NAME_LABEL, m_staticName);
  170. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_RENAME, m_pbRename);
  171. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_CORE_TEXT, m_staticCore);
  172. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_NAME, m_editName);
  173. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_CHECKBOX_DNS, m_cbRequireDNS);
  174. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_CHECKBOX_KERBEROS, m_cbRequireKerberos);
  175. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_STATUS_NETBIOS, m_editNetBIOSStatus);
  176. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_STATUS_DNS, m_editDNSStatus);
  177. DDX_Control(pDX, IDC_PP_NETNAME_PARAMS_STATUS_KERBEROS, m_editKerberosStatus);
  178. //
  179. // Get the status of the checkboxes.
  180. //
  181. DDX_Check(pDX, IDC_PP_NETNAME_PARAMS_CHECKBOX_DNS, m_nRequireDNS);
  182. DDX_Check(pDX, IDC_PP_NETNAME_PARAMS_CHECKBOX_KERBEROS, m_nRequireKerberos);
  183. //}}AFX_DATA_MAP
  184. bError = FALSE;
  185. if (pDX->m_bSaveAndValidate && !BBackPressed())
  186. {
  187. CLRTL_NAME_STATUS cnStatus;
  188. CString strMsg;
  189. UINT idsError;
  190. //
  191. // Get the name from the control into a temp variable
  192. //
  193. DDX_Text(pDX, IDC_PP_NETNAME_PARAMS_NAME, strNetName);
  194. DDV_RequiredText(pDX, IDC_PP_NETNAME_PARAMS_NAME, IDC_PP_NETNAME_PARAMS_NAME_LABEL, strNetName);
  195. DDV_MaxChars(pDX, strNetName, MAX_CLUSTERNAME_LENGTH);
  196. if( m_nRequireDNS == BST_UNCHECKED )
  197. {
  198. m_nRequireKerberos = BST_UNCHECKED;
  199. }
  200. if ( (m_strName != strNetName ) &&
  201. (! ClRtlIsNetNameValid(strNetName, &cnStatus, FALSE /*CheckIfExists*/)) )
  202. {
  203. switch (cnStatus)
  204. {
  205. case NetNameTooLong:
  206. idsError = IDS_INVALID_NETWORK_NAME_TOO_LONG;
  207. break;
  208. case NetNameInvalidChars:
  209. idsError = IDS_INVALID_NETWORK_NAME_INVALID_CHARS;
  210. break;
  211. case NetNameInUse:
  212. idsError = IDS_INVALID_NETWORK_NAME_IN_USE;
  213. break;
  214. case NetNameDNSNonRFCChars:
  215. idsError = IDS_INVALID_NETWORK_NAME_INVALID_DNS_CHARS;
  216. break;
  217. case NetNameSystemError:
  218. {
  219. scError = GetLastError();
  220. CNTException nte(scError, IDS_ERROR_VALIDATING_NETWORK_NAME, (LPCWSTR) strNetName);
  221. nte.ReportError();
  222. pDX->Fail();
  223. }
  224. default:
  225. idsError = IDS_INVALID_NETWORK_NAME;
  226. break;
  227. } // switch: cnStatus
  228. strMsg.LoadString(idsError);
  229. if ( idsError == IDS_INVALID_NETWORK_NAME_INVALID_DNS_CHARS )
  230. {
  231. int id = AfxMessageBox(strMsg, MB_YESNO | MB_DEFBUTTON2 | MB_ICONEXCLAMATION );
  232. if ( id == IDNO )
  233. {
  234. strMsg.Empty();
  235. pDX->Fail();
  236. bError = TRUE;
  237. }
  238. }
  239. else
  240. {
  241. AfxMessageBox(strMsg, MB_ICONEXCLAMATION);
  242. strMsg.Empty(); // exception prep
  243. pDX->Fail();
  244. bError = TRUE;
  245. }
  246. } // if: ((m_strName != strNetName) && (! ClRtlIsNetNameValid(strNetName, &cnStatus, FALSE)) )
  247. //
  248. // Everything was validated - apply all of the changes.
  249. //
  250. if( FALSE == bError )
  251. {
  252. m_strName = strNetName;
  253. }
  254. }// if: (pDX->m_bSaveAndValidate && !BBackPressed())
  255. else // if: populating controls
  256. {
  257. CString m_strStatus;
  258. //
  259. // Populate the controls with data from the member variables.
  260. //
  261. DDX_Text(pDX, IDC_PP_NETNAME_PARAMS_NAME, m_strName);
  262. m_strStatus.Format( _T("%d (0x%08x)"), m_dwNetBIOSStatus, m_dwNetBIOSStatus );
  263. DDX_Text( pDX, IDC_PP_NETNAME_PARAMS_STATUS_NETBIOS, m_strStatus );
  264. m_strStatus.Format( _T("%d (0x%08x)"), m_dwDNSStatus, m_dwDNSStatus );
  265. DDX_Text( pDX, IDC_PP_NETNAME_PARAMS_STATUS_DNS, m_strStatus );
  266. m_strStatus.Format( _T("%d (0x%08x)"), m_dwKerberosStatus, m_dwKerberosStatus );
  267. DDX_Text( pDX, IDC_PP_NETNAME_PARAMS_STATUS_KERBEROS, m_strStatus );
  268. }
  269. } // if: not saving or haven't saved yet
  270. CBasePropertyPage::DoDataExchange(pDX);
  271. } //*** CNetworkNameParamsPage::DoDataExchange()
  272. /////////////////////////////////////////////////////////////////////////////
  273. //++
  274. //
  275. // CNetworkNameParamsPage::OnInitDialog
  276. //
  277. // Routine Description:
  278. // Handler for the WM_INITDIALOG message.
  279. //
  280. // Arguments:
  281. // None.
  282. //
  283. // Return Value:
  284. // TRUE We need the focus to be set for us.
  285. // FALSE We already set the focus to the proper control.
  286. //
  287. //--
  288. /////////////////////////////////////////////////////////////////////////////
  289. BOOL CNetworkNameParamsPage::OnInitDialog(void)
  290. {
  291. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  292. CBasePropertyPage::OnInitDialog();
  293. // Set limits on the edit controls.
  294. m_editName.SetLimitText(MAX_CLUSTERNAME_LENGTH);
  295. // Set up the checkboxes.
  296. m_cbRequireDNS.EnableWindow( TRUE );
  297. m_cbRequireKerberos.EnableWindow( m_nRequireDNS != 0 );
  298. //
  299. // Make sure we're not dealing with a non-Whistler Cluster. If we are then
  300. // disable both checkboxes (the props didn't exist back then - don't set them).
  301. //
  302. CheckForDownlevelCluster();
  303. // If this is a core resource, set the name control to be read-only
  304. // and enable the Core Resource static control.
  305. if (BCore())
  306. {
  307. WINDOWPLACEMENT wpLabel;
  308. WINDOWPLACEMENT wpName;
  309. WINDOWPLACEMENT wpButton;
  310. WINDOWPLACEMENT wpText;
  311. WINDOWPLACEMENT wpCheckDNS;
  312. WINDOWPLACEMENT wpCheckKerberos;
  313. CRect rectName;
  314. CRect rectText;
  315. RECT * prect;
  316. LONG nHeight;
  317. // Get the placement of the controls.
  318. m_editName.GetWindowPlacement(&wpName);
  319. m_staticCore.GetWindowPlacement(&wpText);
  320. m_staticName.GetWindowPlacement(&wpLabel);
  321. m_pbRename.GetWindowPlacement(&wpButton);
  322. m_cbRequireDNS.GetWindowPlacement(&wpCheckDNS);
  323. m_cbRequireKerberos.GetWindowPlacement(&wpCheckKerberos);
  324. // Get the positions of the edit control and text control.
  325. rectName = wpName.rcNormalPosition;
  326. rectText = wpText.rcNormalPosition;
  327. // Move the name control to where the text control is.
  328. prect = &wpName.rcNormalPosition;
  329. *prect = rectText;
  330. nHeight = rectName.bottom - rectName.top;
  331. prect->left = rectName.left;
  332. prect->right = rectName.right;
  333. prect->bottom = prect->top + nHeight;
  334. m_editName.SetWindowPlacement(&wpName);
  335. // Move the text control to where the name control was.
  336. prect = &wpText.rcNormalPosition;
  337. *prect = rectName;
  338. nHeight = rectText.bottom - rectText.top;
  339. prect->left = rectText.left;
  340. prect->right = rectText.right;
  341. prect->bottom = prect->top + nHeight;
  342. m_staticCore.SetWindowPlacement(&wpText);
  343. // Move the name label control to be next to the name edit control.
  344. prect = &wpLabel.rcNormalPosition;
  345. nHeight = prect->bottom - prect->top;
  346. prect->top = wpName.rcNormalPosition.top + 2;
  347. prect->bottom = prect->top + nHeight;
  348. m_staticName.SetWindowPlacement(&wpLabel);
  349. // Move the button control to be next to the name edit control.
  350. prect = &wpButton.rcNormalPosition;
  351. nHeight = prect->bottom - prect->top;
  352. prect->top = wpName.rcNormalPosition.top;
  353. prect->bottom = prect->top + nHeight;
  354. m_pbRename.SetWindowPlacement(&wpButton);
  355. // Move the Require DNS checkbox down.
  356. prect = &wpCheckDNS.rcNormalPosition;
  357. nHeight = prect->bottom - prect->top;
  358. // Move us down by the height of the now displayed static text.
  359. prect->top = prect->top + (wpText.rcNormalPosition.bottom - wpText.rcNormalPosition.top);
  360. prect->top = prect->top + rectText.top - rectName.bottom;
  361. prect->bottom = prect->top + nHeight;
  362. m_cbRequireDNS.SetWindowPlacement(&wpCheckDNS);
  363. // Move the Require Kerberos checkbox down.
  364. prect = &wpCheckKerberos.rcNormalPosition;
  365. nHeight = prect->bottom - prect->top;
  366. // Move us down by the height of the now displayed static text.
  367. prect->top = prect->top + (wpText.rcNormalPosition.bottom - wpText.rcNormalPosition.top);
  368. prect->top = prect->top + rectText.top - rectName.bottom;
  369. prect->bottom = prect->top + nHeight;
  370. m_cbRequireKerberos.SetWindowPlacement(&wpCheckKerberos);
  371. // Prevent the name edit control from being editable and
  372. // Show the text and the button.
  373. m_editName.SetReadOnly(TRUE);
  374. m_staticCore.ShowWindow(SW_SHOW);
  375. m_pbRename.ShowWindow(SW_SHOW);
  376. m_pbRename.EnableWindow( TRUE );
  377. }
  378. else // if: core resource (show static text & move other controls down)
  379. {
  380. m_editName.SetReadOnly(FALSE);
  381. m_staticCore.ShowWindow(SW_HIDE);
  382. m_pbRename.ShowWindow(SW_HIDE);
  383. m_pbRename.EnableWindow( FALSE );
  384. } // else: not core resource
  385. return TRUE; // return TRUE unless you set the focus to a control
  386. // EXCEPTION: OCX Property Pages should return FALSE
  387. } //*** CNetworkNameParamsPage::OnInitDialog()
  388. /////////////////////////////////////////////////////////////////////////////
  389. //++
  390. //
  391. // CNetworkNameParamsPage::OnSetActive
  392. //
  393. // Routine Description:
  394. // Handler for the PSN_SETACTIVE message.
  395. //
  396. // Arguments:
  397. // None.
  398. //
  399. // Return Value:
  400. // TRUE Page successfully initialized.
  401. // FALSE Page not initialized.
  402. //
  403. //--
  404. /////////////////////////////////////////////////////////////////////////////
  405. BOOL CNetworkNameParamsPage::OnSetActive(void)
  406. {
  407. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  408. // Enable/disable the Next/Finish button.
  409. if (BWizard())
  410. {
  411. if (m_strName.GetLength() == 0)
  412. EnableNext(FALSE);
  413. else
  414. EnableNext(TRUE);
  415. } // if: enable/disable the Next button
  416. return CBasePropertyPage::OnSetActive();
  417. } //*** CNetworkNameParamsPage::OnSetActive()
  418. /////////////////////////////////////////////////////////////////////////////
  419. //++
  420. //
  421. // CNetworkNameParamsPage::BApplyChanges
  422. //
  423. // Routine Description:
  424. // Apply changes made on the page.
  425. //
  426. // Arguments:
  427. // None.
  428. //
  429. // Return Value:
  430. // TRUE Page successfully applied.
  431. // FALSE Error applying page.
  432. //
  433. //--
  434. /////////////////////////////////////////////////////////////////////////////
  435. BOOL CNetworkNameParamsPage::BApplyChanges(void)
  436. {
  437. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  438. CWaitCursor wc;
  439. BOOL bSuccess = TRUE;
  440. // Save data.
  441. if (BCore())
  442. {
  443. DWORD scStatus;
  444. //
  445. // If this is the core Network Name (Cluster Name) we should set the name via
  446. // the SetClusterName API. If that succeeds then we'll set the other properties.
  447. //
  448. if ( m_strName != m_strPrevName )
  449. {
  450. scStatus = SetClusterName(Hcluster(), m_strName);
  451. if (scStatus != ERROR_SUCCESS)
  452. {
  453. if (scStatus == ERROR_RESOURCE_PROPERTIES_STORED)
  454. {
  455. TCHAR szError[1024];
  456. CNTException nte(scStatus, NULL, m_strName, NULL, FALSE /*bAutoDelete*/);
  457. nte.FormatErrorMessage(szError, sizeof(szError) / sizeof(TCHAR), NULL, FALSE /*bIncludeID*/);
  458. nte.Delete();
  459. AfxMessageBox(szError);
  460. } // if: properties stored
  461. else
  462. {
  463. CNTException nte(scStatus, IDS_ERROR_SETTING_CLUSTER_NAME, m_strName, NULL, FALSE /*bAutoDelete*/);
  464. nte.ReportError();
  465. nte.Delete();
  466. bSuccess = FALSE;
  467. } // else: other error occurred
  468. } // if: error setting the cluster name
  469. else
  470. {
  471. //
  472. // By setting the prev value equal to the current value the BSetPrivateProps
  473. // function will skip this prop when constructing it's list of props to set.
  474. //
  475. m_strPrevName = m_strName;
  476. }
  477. } // if: name has changed
  478. //
  479. // Now set the other private properties.
  480. //
  481. if ( bSuccess == TRUE )
  482. {
  483. bSuccess = BSetPrivateProps();
  484. }
  485. } // if: core resource
  486. else
  487. {
  488. bSuccess = BSetPrivateProps();
  489. }
  490. //
  491. // If we applied the changes then clear the require kerberos check if
  492. // the checkbox was disabled. Don't make this dependent upon the require
  493. // DNS checkbox state as the dependency may change in the future.
  494. //
  495. if( ( bSuccess == TRUE ) &&
  496. ( m_cbRequireKerberos.IsWindowEnabled() == FALSE ) )
  497. {
  498. m_cbRequireKerberos.SetCheck( BST_UNCHECKED );
  499. }
  500. return bSuccess;
  501. } //*** CNetworkNameParamsPage::BApplyChanges()
  502. /////////////////////////////////////////////////////////////////////////////
  503. //++
  504. //
  505. // CNetworkNameParamsPage::OnChangeName
  506. //
  507. // Routine Description:
  508. // Handler for the EN_CHANGE message on the Name edit control.
  509. //
  510. // Arguments:
  511. // None.
  512. //
  513. // Return Value:
  514. // None.
  515. //
  516. //--
  517. /////////////////////////////////////////////////////////////////////////////
  518. void CNetworkNameParamsPage::OnChangeName(void)
  519. {
  520. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  521. OnChangeCtrl();
  522. if (BWizard())
  523. {
  524. if (m_editName.GetWindowTextLength() == 0)
  525. {
  526. EnableNext(FALSE);
  527. }
  528. else
  529. {
  530. EnableNext(TRUE);
  531. }
  532. } // if: in a wizard
  533. } //*** CNetworkNameParamsPage::OnChangeName()
  534. /////////////////////////////////////////////////////////////////////////////
  535. //++
  536. //
  537. // CNetworkNameParamsPage::OnRename
  538. //
  539. // Routine Description:
  540. // Handler for the BN_CLICKED message on the Rename push button.
  541. //
  542. // Arguments:
  543. // None.
  544. //
  545. // Return Value:
  546. // None.
  547. //
  548. //--
  549. /////////////////////////////////////////////////////////////////////////////
  550. void CNetworkNameParamsPage::OnRename(void)
  551. {
  552. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  553. CChangeClusterNameDlg dlg(this);
  554. ASSERT(BCore());
  555. dlg.m_strClusName = m_strName;
  556. if (dlg.DoModal() == IDOK)
  557. {
  558. if (m_strName != dlg.m_strClusName)
  559. {
  560. OnChangeCtrl();
  561. m_strName = dlg.m_strClusName;
  562. UpdateData(FALSE /*bSaveAndValidate*/);
  563. } // if: the name changed
  564. } // if: user accepted change
  565. } //*** CNetworkNameParamsPage::OnRename()
  566. /////////////////////////////////////////////////////////////////////////////
  567. //++
  568. //
  569. // CNetworkNameParamsPage::OnRequireDNS
  570. //
  571. // Routine Description:
  572. // Handler for the BN_CLICKED message on the RequireDNS checkbox.
  573. //
  574. // Arguments:
  575. // None.
  576. //
  577. // Return Value:
  578. // None.
  579. //
  580. //--
  581. /////////////////////////////////////////////////////////////////////////////
  582. void CNetworkNameParamsPage::OnRequireDNS(void)
  583. {
  584. int nChecked;
  585. nChecked = m_cbRequireDNS.GetCheck();
  586. m_cbRequireKerberos.EnableWindow( nChecked == BST_CHECKED );
  587. SetModified( TRUE );
  588. } //*** CNetworkNameParamsPage::OnRequireDNS()
  589. /////////////////////////////////////////////////////////////////////////////
  590. //++
  591. //
  592. // CNetworkNameParamsPage::CheckForDownlevelCluster
  593. //
  594. // Routine Description:
  595. // If determine whether the cluster we're connected to is pre-Whistler.
  596. // If it is then disable the buttons. If an error occurs display a
  597. // message box.
  598. //
  599. // Arguments:
  600. // None.
  601. //
  602. // Return Value:
  603. // None.
  604. //
  605. //--
  606. /////////////////////////////////////////////////////////////////////////////
  607. void CNetworkNameParamsPage::CheckForDownlevelCluster(void)
  608. {
  609. CLUSTERVERSIONINFO cvi;
  610. DWORD sc;
  611. DWORD scErr;
  612. DWORD cchName;
  613. //
  614. // Determine whether we're talking to a pre-Whistler cluster.
  615. // If so, disable the Require DNS & Kerberos checkboxes.
  616. //
  617. memset( &cvi, 0, sizeof( cvi ) );
  618. cvi.dwVersionInfoSize = sizeof( cvi );
  619. cchName = 0;
  620. sc = GetClusterInformation( Hcluster(), NULL, &cchName, &cvi );
  621. scErr = GetLastError();
  622. if( ERROR_SUCCESS != sc )
  623. {
  624. //
  625. // API failed. Pop up a message box.
  626. //
  627. TCHAR szError[1024];
  628. CNTException nte(scErr, IDS_ERROR_GETTING_CLUSTER_INFORMATION, m_strName, NULL, FALSE /*bAutoDelete*/);
  629. nte.FormatErrorMessage(szError, sizeof(szError) / sizeof(TCHAR), NULL, FALSE /*bIncludeID*/);
  630. nte.ReportError();
  631. nte.Delete();
  632. //
  633. // We can't be sure that we're on a down-level cluster (chances are that we're not),
  634. // so leave the checkboxes enabled - the worst that will happen is that some extra props
  635. // will be added that are ignored by the resource.
  636. //
  637. }
  638. else
  639. {
  640. if( CLUSTER_GET_MAJOR_VERSION( cvi.dwClusterHighestVersion ) < NT51_MAJOR_VERSION )
  641. {
  642. //
  643. // We're on a pre-Whistler Cluster where the DNS & Kerberos setting make no
  644. // sense. So, disable the checkboxes to indicate that the settings
  645. // are unavailable.
  646. //
  647. m_cbRequireKerberos.EnableWindow( FALSE );
  648. m_cbRequireDNS.EnableWindow( FALSE );
  649. }
  650. }
  651. } //*** CNetworkNameParamsPage::CheckForDownlevelCluster()