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.

3301 lines
97 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: zoneui.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "preDNSsn.h"
  11. #include <SnapBase.h>
  12. #include "resource.h"
  13. #include "dnsutil.h"
  14. #include "DNSSnap.h"
  15. #include "snapdata.h"
  16. #include "server.h"
  17. #include "domain.h"
  18. #include "record.h"
  19. #include "zone.h"
  20. #include "ZoneUI.h"
  21. #include "browser.h"
  22. #ifdef DEBUG_ALLOCATOR
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. #endif
  29. #ifdef USE_NDNC
  30. ///////////////////////////////////////////////////////////////////////////////
  31. // CDNSZoneChangeReplicationScopeDialog
  32. class CDNSZoneChangeReplicationScopeDialog : public CHelpDialog
  33. {
  34. public:
  35. CDNSZoneChangeReplicationScopeDialog(CPropertyPageHolderBase* pHolder,
  36. ReplicationType replType,
  37. PCWSTR pszCustomScope,
  38. DWORD dwServerVersion);
  39. ReplicationType m_newReplType; // IN/OUT
  40. CString m_szCustomScope; // IN/OUT
  41. protected:
  42. virtual BOOL OnInitDialog();
  43. virtual void OnOK();
  44. virtual void OnCancel();
  45. afx_msg void OnRadioChange();
  46. afx_msg void OnCustomComboSelChange();
  47. DECLARE_MESSAGE_MAP()
  48. private:
  49. void SyncRadioButtons();
  50. ReplicationType m_replType;
  51. BOOL m_dwServerVersion;
  52. CPropertyPageHolderBase* m_pHolder;
  53. };
  54. CDNSZoneChangeReplicationScopeDialog::CDNSZoneChangeReplicationScopeDialog(CPropertyPageHolderBase* pHolder,
  55. ReplicationType replType,
  56. PCWSTR pszCustomScope,
  57. DWORD dwServerVersion)
  58. : m_pHolder(pHolder),
  59. m_replType(replType),
  60. m_newReplType(replType),
  61. m_szCustomScope(pszCustomScope),
  62. m_dwServerVersion(dwServerVersion),
  63. CHelpDialog(IDD_ZONE_GENERAL_CHANGE_REPLICATION, pHolder->GetComponentData())
  64. {
  65. ASSERT(pHolder != NULL);
  66. }
  67. BEGIN_MESSAGE_MAP(CDNSZoneChangeReplicationScopeDialog, CHelpDialog)
  68. ON_BN_CLICKED(IDC_FOREST_RADIO, OnRadioChange)
  69. ON_BN_CLICKED(IDC_DOMAIN_RADIO, OnRadioChange)
  70. ON_BN_CLICKED(IDC_DOMAIN_DC_RADIO, OnRadioChange)
  71. ON_BN_CLICKED(IDC_CUSTOM_RADIO, OnRadioChange)
  72. ON_CBN_EDITCHANGE(IDC_CUSTOM_COMBO, OnRadioChange)
  73. ON_CBN_SELCHANGE(IDC_CUSTOM_COMBO, OnCustomComboSelChange)
  74. END_MESSAGE_MAP()
  75. void CDNSZoneChangeReplicationScopeDialog::OnRadioChange()
  76. {
  77. if (SendDlgItemMessage(IDC_FOREST_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  78. {
  79. m_newReplType = forest;
  80. }
  81. else if (SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  82. {
  83. m_newReplType = domain;
  84. }
  85. else if (SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  86. {
  87. m_newReplType = w2k;
  88. }
  89. else if (SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  90. {
  91. m_newReplType = custom;
  92. LRESULT iSel = SendDlgItemMessage(IDC_CUSTOM_COMBO, CB_GETCURSEL, 0, 0);
  93. if (CB_ERR != iSel)
  94. {
  95. CString szTemp;
  96. CComboBox* pComboBox = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_CUSTOM_COMBO));
  97. ASSERT(pComboBox);
  98. pComboBox->GetLBText(static_cast<int>(iSel), m_szCustomScope);
  99. }
  100. }
  101. else
  102. {
  103. // one of the radio buttons must be selected
  104. ASSERT(FALSE);
  105. }
  106. SyncRadioButtons();
  107. }
  108. void CDNSZoneChangeReplicationScopeDialog::SyncRadioButtons()
  109. {
  110. switch (m_newReplType)
  111. {
  112. case forest:
  113. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  114. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  115. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  116. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  117. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  118. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  119. break;
  120. case domain:
  121. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  122. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  123. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  124. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  125. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  126. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  127. break;
  128. case w2k:
  129. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  130. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  131. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  132. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  133. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  134. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  135. break;
  136. case custom:
  137. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  138. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  139. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  140. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  141. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(TRUE);
  142. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(TRUE);
  143. break;
  144. default:
  145. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  146. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  147. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  148. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  149. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  150. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  151. break;
  152. }
  153. if (BST_CHECKED == SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_GETCHECK, 0, 0))
  154. {
  155. CString szTemp;
  156. GetDlgItemText(IDC_CUSTOM_COMBO, szTemp);
  157. GetDlgItem(IDOK)->EnableWindow(!szTemp.IsEmpty());
  158. }
  159. else
  160. {
  161. GetDlgItem(IDOK)->EnableWindow(TRUE);
  162. }
  163. }
  164. void CDNSZoneChangeReplicationScopeDialog::OnCustomComboSelChange()
  165. {
  166. LRESULT iSel = SendDlgItemMessage(IDC_CUSTOM_COMBO, CB_GETCURSEL, 0, 0);
  167. if (CB_ERR != iSel)
  168. {
  169. CComboBox* pComboBox = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_CUSTOM_COMBO));
  170. ASSERT(pComboBox);
  171. pComboBox->GetLBText(static_cast<int>(iSel), m_szCustomScope);
  172. GetDlgItem(IDOK)->EnableWindow(!m_szCustomScope.IsEmpty());
  173. }
  174. else
  175. {
  176. GetDlgItem(IDOK)->EnableWindow(FALSE);
  177. }
  178. }
  179. BOOL CDNSZoneChangeReplicationScopeDialog::OnInitDialog()
  180. {
  181. CHelpDialog::OnInitDialog();
  182. m_pHolder->PushDialogHWnd(GetSafeHwnd());
  183. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)m_pHolder;
  184. CDNSServerNode* pServerNode = pHolder->GetZoneNode()->GetServerNode();
  185. //
  186. // We should only reach this dialog if we are on a Whistler or greater server
  187. //
  188. ASSERT(DNS_SRV_BUILD_NUMBER(m_dwServerVersion) >= DNS_SRV_BUILD_NUMBER_WHISTLER &&
  189. (DNS_SRV_MAJOR_VERSION(m_dwServerVersion) > DNS_SRV_MAJOR_VERSION_NT_5 ||
  190. DNS_SRV_MINOR_VERSION(m_dwServerVersion) >= DNS_SRV_MINOR_VERSION_WHISTLER));
  191. USES_CONVERSION;
  192. //
  193. // Get the forest and domain names and format them into the UI
  194. //
  195. PCWSTR pszDomainName = UTF8_TO_W(pServerNode->GetDomainName());
  196. PCWSTR pszForestName = UTF8_TO_W(pServerNode->GetForestName());
  197. ASSERT(pszDomainName);
  198. ASSERT(pszForestName);
  199. CString szWin2KReplText;
  200. szWin2KReplText.Format(IDS_ZWIZ_AD_REPL_FORMAT, pszDomainName);
  201. SetDlgItemText(IDC_DOMAIN_DC_RADIO, szWin2KReplText);
  202. CString szDNSDomainText;
  203. szDNSDomainText.Format(IDS_ZWIZ_AD_DOMAIN_FORMAT, pszDomainName);
  204. SetDlgItemText(IDC_DOMAIN_RADIO, szDNSDomainText);
  205. CString szDNSForestText;
  206. szDNSForestText.Format(IDS_ZWIZ_AD_FOREST_FORMAT, pszForestName);
  207. SetDlgItemText(IDC_FOREST_RADIO, szDNSForestText);
  208. //
  209. // Enumerate the available directory partitions
  210. //
  211. PDNS_RPC_DP_LIST pDirectoryPartitions = NULL;
  212. DWORD dwErr = ::DnssrvEnumDirectoryPartitions(pServerNode->GetRPCName(),
  213. DNS_DP_ENLISTED,
  214. &pDirectoryPartitions);
  215. //
  216. // Don't show an error if we are not able to get the available directory partitions
  217. // We can still continue on and the user can type in the directory partition they need
  218. //
  219. bool bCustomPartitionAdded = false;
  220. if (dwErr == 0 && pDirectoryPartitions)
  221. {
  222. for (DWORD dwIdx = 0; dwIdx < pDirectoryPartitions->dwDpCount; dwIdx++)
  223. {
  224. PDNS_RPC_DP_INFO pDirectoryPartition = 0;
  225. dwErr = ::DnssrvDirectoryPartitionInfo(pServerNode->GetRPCName(),
  226. pDirectoryPartitions->DpArray[dwIdx]->pszDpFqdn,
  227. &pDirectoryPartition);
  228. if (dwErr == 0 &&
  229. pDirectoryPartition)
  230. {
  231. //
  232. // Only add the partition if it is not one of the autocreated ones
  233. // and the DNS server is enlisted in the partition
  234. //
  235. if (!(pDirectoryPartition->dwFlags & DNS_DP_AUTOCREATED) &&
  236. (pDirectoryPartition->dwFlags & DNS_DP_ENLISTED))
  237. {
  238. SendDlgItemMessage(IDC_CUSTOM_COMBO,
  239. CB_ADDSTRING,
  240. 0,
  241. (LPARAM)UTF8_TO_W(pDirectoryPartition->pszDpFqdn));
  242. bCustomPartitionAdded = true;
  243. }
  244. ::DnssrvFreeDirectoryPartitionInfo(pDirectoryPartition);
  245. }
  246. }
  247. ::DnssrvFreeDirectoryPartitionList(pDirectoryPartitions);
  248. }
  249. if (!bCustomPartitionAdded)
  250. {
  251. GetDlgItem(IDC_CUSTOM_RADIO)->EnableWindow(FALSE);
  252. }
  253. //
  254. // Select the correct partition if we are using a custom partition
  255. //
  256. if (m_replType == custom)
  257. {
  258. LRESULT lIdx = SendDlgItemMessage(IDC_CUSTOM_COMBO,
  259. CB_FINDSTRINGEXACT,
  260. (WPARAM)-1,
  261. (LPARAM)(PCWSTR)m_szCustomScope);
  262. if (lIdx != CB_ERR)
  263. {
  264. SendDlgItemMessage(IDC_CUSTOM_COMBO,
  265. CB_SETCURSEL,
  266. (WPARAM)lIdx,
  267. 0);
  268. }
  269. else
  270. {
  271. //
  272. // Add the partition
  273. //
  274. SendDlgItemMessage(IDC_CUSTOM_COMBO,
  275. CB_ADDSTRING,
  276. 0,
  277. (LPARAM)(PCWSTR)m_szCustomScope);
  278. }
  279. }
  280. SyncRadioButtons();
  281. return TRUE;
  282. }
  283. void CDNSZoneChangeReplicationScopeDialog::OnCancel()
  284. {
  285. if (m_pHolder != NULL)
  286. {
  287. m_pHolder->PopDialogHWnd();
  288. }
  289. CHelpDialog::OnCancel();
  290. }
  291. void CDNSZoneChangeReplicationScopeDialog::OnOK()
  292. {
  293. if (m_pHolder != NULL)
  294. {
  295. m_pHolder->PopDialogHWnd();
  296. }
  297. CHelpDialog::OnOK();
  298. }
  299. #endif // USE_NDNC
  300. ///////////////////////////////////////////////////////////////////////////////
  301. // CDNSZoneChangeTypeDialog
  302. class CDNSZoneChangeTypeDialog : public CHelpDialog
  303. {
  304. public:
  305. CDNSZoneChangeTypeDialog(CPropertyPageHolderBase* pHolder,
  306. BOOL bServerADSEnabled,
  307. DWORD dwServerVersion);
  308. BOOL m_bIsPrimary; // IN/OUT
  309. BOOL m_bDSIntegrated; // IN/OUT
  310. BOOL m_bIsStub; // IN/OUT
  311. protected:
  312. virtual BOOL OnInitDialog();
  313. virtual void OnOK();
  314. virtual void OnCancel();
  315. afx_msg void OnRadioChange();
  316. DECLARE_MESSAGE_MAP()
  317. private:
  318. BOOL m_bServerADSEnabled;
  319. BOOL m_dwServerVersion;
  320. CPropertyPageHolderBase* m_pHolder;
  321. };
  322. CDNSZoneChangeTypeDialog::CDNSZoneChangeTypeDialog(CPropertyPageHolderBase* pHolder,
  323. BOOL bServerADSEnabled,
  324. DWORD dwServerVersion)
  325. : CHelpDialog(IDD_ZONE_GENERAL_CHANGE_TYPE, pHolder->GetComponentData())
  326. {
  327. ASSERT(pHolder != NULL);
  328. m_pHolder = pHolder;
  329. m_bServerADSEnabled = bServerADSEnabled;
  330. m_dwServerVersion = dwServerVersion;
  331. }
  332. BEGIN_MESSAGE_MAP(CDNSZoneChangeTypeDialog, CHelpDialog)
  333. ON_BN_CLICKED(IDC_RADIO_ZONE_PRIMARY, OnRadioChange)
  334. ON_BN_CLICKED(IDC_RADIO_ZONE_SECONDARY, OnRadioChange)
  335. ON_BN_CLICKED(IDC_RADIO_ZONE_STUB, OnRadioChange)
  336. END_MESSAGE_MAP()
  337. void CDNSZoneChangeTypeDialog::OnRadioChange()
  338. {
  339. if (SendDlgItemMessage(IDC_RADIO_ZONE_SECONDARY, BM_GETCHECK, 0, 0) == BST_CHECKED)
  340. {
  341. SendDlgItemMessage(IDC_ADINT_CHECK, BM_SETCHECK, BST_UNCHECKED, 0);
  342. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(FALSE);
  343. }
  344. else
  345. {
  346. if (m_bServerADSEnabled)
  347. {
  348. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(TRUE);
  349. }
  350. else
  351. {
  352. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(FALSE);
  353. }
  354. }
  355. }
  356. BOOL CDNSZoneChangeTypeDialog::OnInitDialog()
  357. {
  358. CHelpDialog::OnInitDialog();
  359. m_pHolder->PushDialogHWnd(GetSafeHwnd());
  360. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(m_bServerADSEnabled);
  361. int nIDCheckButton;
  362. if (m_bIsPrimary)
  363. {
  364. nIDCheckButton = IDC_RADIO_ZONE_PRIMARY;
  365. }
  366. else
  367. {
  368. if (m_bIsStub)
  369. {
  370. nIDCheckButton = IDC_RADIO_ZONE_STUB;
  371. }
  372. else
  373. {
  374. nIDCheckButton = IDC_RADIO_ZONE_SECONDARY;
  375. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(FALSE);
  376. }
  377. }
  378. CheckRadioButton(IDC_RADIO_ZONE_PRIMARY, IDC_RADIO_ZONE_STUB, nIDCheckButton);
  379. SendDlgItemMessage(IDC_ADINT_CHECK, BM_SETCHECK, m_bDSIntegrated, 0);
  380. if (DNS_SRV_BUILD_NUMBER(m_dwServerVersion) < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  381. (DNS_SRV_MAJOR_VERSION(m_dwServerVersion) <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  382. DNS_SRV_MINOR_VERSION(m_dwServerVersion) < DNS_SRV_MINOR_VERSION_WHISTLER))
  383. {
  384. //
  385. // Stub zones not available on pre-Whistler servers
  386. //
  387. GetDlgItem(IDC_RADIO_ZONE_STUB)->EnableWindow(FALSE);
  388. GetDlgItem(IDC_STUB_STATIC)->EnableWindow(FALSE);
  389. }
  390. return TRUE;
  391. }
  392. void CDNSZoneChangeTypeDialog::OnCancel()
  393. {
  394. if (m_pHolder != NULL)
  395. {
  396. m_pHolder->PopDialogHWnd();
  397. }
  398. CHelpDialog::OnCancel();
  399. }
  400. void CDNSZoneChangeTypeDialog::OnOK()
  401. {
  402. BOOL bIsPrimary = TRUE;
  403. BOOL bDSIntegrated = TRUE;
  404. BOOL bIsStub = FALSE;
  405. int nIDCheckButton = GetCheckedRadioButton(IDC_RADIO_ZONE_PRIMARY, IDC_RADIO_ZONE_STUB);
  406. switch (nIDCheckButton)
  407. {
  408. case IDC_RADIO_ZONE_PRIMARY:
  409. bIsPrimary = TRUE;
  410. bIsStub = FALSE;
  411. break;
  412. case IDC_RADIO_ZONE_SECONDARY:
  413. bIsPrimary = FALSE;
  414. bIsStub = FALSE;
  415. break;
  416. case IDC_RADIO_ZONE_STUB:
  417. bIsPrimary = FALSE;
  418. bIsStub = TRUE;
  419. break;
  420. default:
  421. ASSERT(FALSE);
  422. break;
  423. }
  424. bDSIntegrated = static_cast<BOOL>(SendDlgItemMessage(IDC_ADINT_CHECK, BM_GETCHECK, 0, 0));
  425. //
  426. // warnings on special transitions
  427. //
  428. if (m_bDSIntegrated && !bDSIntegrated)
  429. {
  430. //
  431. // warning changing from DS integrated to something else
  432. //
  433. if (IDYES != DNSMessageBox(IDS_MSG_ZONE_WARNING_CHANGE_TYPE_FROM_DS,MB_YESNO))
  434. {
  435. return;
  436. }
  437. }
  438. else if (!m_bDSIntegrated && bDSIntegrated)
  439. {
  440. //
  441. // warning changing from primary to DS integrated primary
  442. //
  443. if (IDYES != DNSMessageBox(IDS_MSG_ZONE_WARNING_CHANGE_TYPE_TO_DS,MB_YESNO))
  444. {
  445. return;
  446. }
  447. }
  448. m_bIsPrimary = bIsPrimary;
  449. m_bDSIntegrated = bDSIntegrated;
  450. m_bIsStub = bIsStub;
  451. if (m_pHolder != NULL)
  452. {
  453. m_pHolder->PopDialogHWnd();
  454. }
  455. CHelpDialog::OnOK();
  456. }
  457. ///////////////////////////////////////////////////////////////////////////////
  458. // CDNSZoneChangeTypeDataConflict
  459. class CDNSZoneChangeTypeDataConflict : public CHelpDialog
  460. {
  461. public:
  462. CDNSZoneChangeTypeDataConflict(CPropertyPageHolderBase* pHolder);
  463. BOOL m_bUseDsData; // IN/OUT
  464. protected:
  465. virtual BOOL OnInitDialog();
  466. virtual void OnOK();
  467. virtual void OnCancel();
  468. private:
  469. CPropertyPageHolderBase* m_pHolder;
  470. };
  471. CDNSZoneChangeTypeDataConflict::CDNSZoneChangeTypeDataConflict(
  472. CPropertyPageHolderBase* pHolder)
  473. : CHelpDialog(IDD_ZONE_GENERAL_CHANGE_TYPE_DATA_CONFLICT, pHolder->GetComponentData())
  474. {
  475. m_pHolder = pHolder;
  476. m_bUseDsData = FALSE;
  477. }
  478. BOOL CDNSZoneChangeTypeDataConflict::OnInitDialog()
  479. {
  480. CHelpDialog::OnInitDialog();
  481. m_pHolder->PushDialogHWnd(GetSafeHwnd());
  482. CheckRadioButton(IDC_RADIO_USE_DS_DATA, IDC_RADIO_USE_MEM_DATA,
  483. m_bUseDsData ? IDC_RADIO_USE_DS_DATA : IDC_RADIO_USE_MEM_DATA);
  484. return TRUE;
  485. }
  486. void CDNSZoneChangeTypeDataConflict::OnCancel()
  487. {
  488. if (m_pHolder != NULL)
  489. m_pHolder->PopDialogHWnd();
  490. CHelpDialog::OnCancel();
  491. }
  492. void CDNSZoneChangeTypeDataConflict::OnOK()
  493. {
  494. int nIDCheckButton = GetCheckedRadioButton(
  495. IDC_RADIO_USE_DS_DATA, IDC_RADIO_USE_MEM_DATA);
  496. m_bUseDsData = (nIDCheckButton == IDC_RADIO_USE_DS_DATA);
  497. if (m_pHolder != NULL)
  498. m_pHolder->PopDialogHWnd();
  499. CHelpDialog::OnOK();
  500. }
  501. ///////////////////////////////////////////////////////////////////////////////
  502. // CDNSZoneNotifyDialog
  503. class CDNSZoneNotifyDialog : public CHelpDialog
  504. {
  505. public:
  506. CDNSZoneNotifyDialog(CDNSZone_ZoneTransferPropertyPage* pPage, BOOL bSecondaryZone,
  507. CComponentDataObject* pComponentData);
  508. protected:
  509. virtual BOOL OnInitDialog();
  510. virtual void OnOK();
  511. virtual void OnCancel();
  512. afx_msg void OnRadioNotifyOff() { SyncUIRadioHelper(IDC_CHECK_AUTO_NOTIFY);}
  513. afx_msg void OnRadioNotifyAll() { SyncUIRadioHelper(IDC_RADIO_NOTIFY_ALL);}
  514. afx_msg void OnRadioNotifyList() { SyncUIRadioHelper(IDC_RADIO_NOTIFY_LIST);}
  515. DECLARE_MESSAGE_MAP()
  516. private:
  517. void SyncUIRadioHelper(UINT nRadio);
  518. int SetRadioState(DWORD fNotifyFlag);
  519. DWORD GetRadioState();
  520. CDNSZone_ZoneTransferPropertyPage* m_pPage;
  521. BOOL m_bSecondaryZone;
  522. class CDNSNotifyIPEditor : public CIPEditor
  523. {
  524. public:
  525. CDNSNotifyIPEditor() : CIPEditor(TRUE) {} // no up/down buttons
  526. virtual void OnChangeData();
  527. };
  528. CDNSNotifyIPEditor m_notifyListEditor;
  529. friend class CDNSNotifyIPEditor;
  530. CComponentDataObject* m_pComponentData;
  531. };
  532. BEGIN_MESSAGE_MAP(CDNSZoneNotifyDialog, CHelpDialog)
  533. ON_BN_CLICKED(IDC_CHECK_AUTO_NOTIFY, OnRadioNotifyOff)
  534. ON_BN_CLICKED(IDC_RADIO_NOTIFY_ALL, OnRadioNotifyAll)
  535. ON_BN_CLICKED(IDC_RADIO_NOTIFY_LIST, OnRadioNotifyList)
  536. END_MESSAGE_MAP()
  537. void CDNSZoneNotifyDialog::CDNSNotifyIPEditor::OnChangeData()
  538. {
  539. CWnd* pWnd = GetParentWnd();
  540. pWnd->GetDlgItem(IDOK)->EnableWindow(TRUE); // it is dirty now
  541. }
  542. CDNSZoneNotifyDialog::CDNSZoneNotifyDialog(CDNSZone_ZoneTransferPropertyPage* pPage,
  543. BOOL bSecondaryZone,
  544. CComponentDataObject* pComponentData)
  545. : CHelpDialog(IDD_ZONE_NOTIFY_SUBDIALOG, pComponentData)
  546. {
  547. m_pPage = pPage;
  548. m_bSecondaryZone = bSecondaryZone;
  549. m_pComponentData = pComponentData;
  550. }
  551. BOOL CDNSZoneNotifyDialog::OnInitDialog()
  552. {
  553. CHelpDialog::OnInitDialog();
  554. m_pPage->GetHolder()->PushDialogHWnd(GetSafeHwnd());
  555. VERIFY(m_notifyListEditor.Initialize(this,
  556. this,
  557. IDC_BUTTON_UP,
  558. IDC_BUTTON_DOWN,
  559. IDC_BUTTON_ADD,
  560. IDC_BUTTON_REMOVE,
  561. IDC_IPEDIT,
  562. IDC_LIST));
  563. if (m_bSecondaryZone)
  564. {
  565. ASSERT(m_pPage->m_fNotifyLevel != ZONE_NOTIFY_ALL);
  566. GetDlgItem(IDC_RADIO_NOTIFY_ALL)->EnableWindow(FALSE);
  567. }
  568. // read the state and set the UI
  569. if ( (ZONE_NOTIFY_LIST == m_pPage->m_fNotifyLevel) && (m_pPage->m_cNotify > 0) )
  570. {
  571. m_notifyListEditor.AddAddresses(m_pPage->m_aipNotify, m_pPage->m_cNotify);
  572. }
  573. SyncUIRadioHelper(SetRadioState(m_pPage->m_fNotifyLevel));
  574. GetDlgItem(IDOK)->EnableWindow(FALSE); // not dirty
  575. BOOL bListState = ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->GetCheck();
  576. BOOL bAllState = ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_ALL))->GetCheck();
  577. if (!bAllState && !bListState)
  578. {
  579. ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->SetCheck(TRUE);
  580. }
  581. return TRUE;
  582. }
  583. void CDNSZoneNotifyDialog::OnCancel()
  584. {
  585. if (m_pPage->GetHolder() != NULL)
  586. m_pPage->GetHolder()->PopDialogHWnd();
  587. CHelpDialog::OnCancel();
  588. }
  589. void CDNSZoneNotifyDialog::OnOK()
  590. {
  591. // read the data back to the main page storage
  592. m_pPage->m_fNotifyLevel = GetRadioState();
  593. m_pPage->m_cNotify = 0;
  594. if (m_pPage->m_aipNotify != NULL)
  595. {
  596. free(m_pPage->m_aipNotify);
  597. m_pPage->m_aipNotify = NULL;
  598. }
  599. if (m_pPage->m_fNotifyLevel == ZONE_NOTIFY_LIST)
  600. {
  601. m_pPage->m_cNotify = m_notifyListEditor.GetCount();
  602. if (m_pPage->m_cNotify > 0)
  603. {
  604. m_pPage->m_aipNotify = (DWORD*) malloc(sizeof(DWORD)*m_pPage->m_cNotify);
  605. int nFilled = 0;
  606. if (m_pPage->m_aipNotify != NULL)
  607. {
  608. m_notifyListEditor.GetAddresses(m_pPage->m_aipNotify, m_pPage->m_cNotify, &nFilled);
  609. }
  610. ASSERT(nFilled == (int)m_pPage->m_cNotify);
  611. }
  612. }
  613. // dismiss dialog, all cool
  614. if (m_pPage->GetHolder())
  615. m_pPage->GetHolder()->PopDialogHWnd();
  616. CHelpDialog::OnOK();
  617. }
  618. void CDNSZoneNotifyDialog::SyncUIRadioHelper(UINT nRadio)
  619. {
  620. m_notifyListEditor.EnableUI(IDC_RADIO_NOTIFY_LIST == nRadio, TRUE);
  621. // if (IDC_RADIO_NOTIFY_LIST != nRadio)
  622. // m_notifyListEditor.Clear();
  623. GetDlgItem(IDOK)->EnableWindow(TRUE); // dirty
  624. if (IDC_CHECK_AUTO_NOTIFY == nRadio)
  625. {
  626. BOOL bState = ((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->GetCheck();
  627. ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->EnableWindow(bState);
  628. ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_ALL))->EnableWindow(bState);
  629. BOOL bRadioState = ((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->GetCheck();
  630. m_notifyListEditor.EnableUI(bRadioState && bState, TRUE);
  631. }
  632. }
  633. int CDNSZoneNotifyDialog::SetRadioState(DWORD fNotifyLevel)
  634. {
  635. int nRadio = 0;
  636. switch (fNotifyLevel)
  637. {
  638. case ZONE_NOTIFY_OFF:
  639. nRadio = IDC_CHECK_AUTO_NOTIFY;
  640. ((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->SetCheck(FALSE);
  641. break;
  642. case ZONE_NOTIFY_LIST:
  643. nRadio = IDC_RADIO_NOTIFY_LIST;
  644. ((CButton*)GetDlgItem(nRadio))->SetCheck(TRUE);
  645. ((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->SetCheck(TRUE);
  646. break;
  647. case ZONE_NOTIFY_ALL:
  648. nRadio = IDC_RADIO_NOTIFY_ALL;
  649. ((CButton*)GetDlgItem(nRadio))->SetCheck(TRUE);
  650. ((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->SetCheck(TRUE);
  651. break;
  652. }
  653. ASSERT(nRadio != 0);
  654. return nRadio;
  655. }
  656. DWORD CDNSZoneNotifyDialog::GetRadioState()
  657. {
  658. static int nRadioArr[] =
  659. {
  660. IDC_RADIO_NOTIFY_OFF,
  661. IDC_RADIO_NOTIFY_LIST,
  662. IDC_RADIO_NOTIFY_ALL
  663. };
  664. int nRadio = 0;
  665. if (!((CButton*)GetDlgItem(IDC_CHECK_AUTO_NOTIFY))->GetCheck())
  666. {
  667. nRadio = IDC_CHECK_AUTO_NOTIFY;
  668. }
  669. else
  670. {
  671. if (((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_LIST))->GetCheck())
  672. {
  673. nRadio = IDC_RADIO_NOTIFY_LIST;
  674. }
  675. else if (((CButton*)GetDlgItem(IDC_RADIO_NOTIFY_ALL))->GetCheck())
  676. {
  677. nRadio = IDC_RADIO_NOTIFY_ALL;
  678. }
  679. }
  680. // int nRadio = ::GetCheckedRadioButtonHelper(m_hWnd, 3, nRadioArr, IDC_RADIO_NOTIFY_OFF);
  681. ASSERT(nRadio != 0);
  682. DWORD fNotifyLevel = (DWORD)-1;
  683. switch (nRadio)
  684. {
  685. case IDC_CHECK_AUTO_NOTIFY:
  686. fNotifyLevel = ZONE_NOTIFY_OFF;
  687. break;
  688. case IDC_RADIO_NOTIFY_LIST:
  689. fNotifyLevel = ZONE_NOTIFY_LIST;
  690. break;
  691. case IDC_RADIO_NOTIFY_ALL:
  692. fNotifyLevel = ZONE_NOTIFY_ALL;
  693. break;
  694. }
  695. ASSERT(fNotifyLevel != (DWORD)-1);
  696. return fNotifyLevel;
  697. }
  698. ///////////////////////////////////////////////////////////////////////////////
  699. // CDNSZone_GeneralPropertyPage
  700. //
  701. // defines for the status text string positions (matching the RC file)
  702. //
  703. #define N_ZONE_STATES 3
  704. #define N_ZONE_STATUS_RUNNING 0
  705. #define N_ZONE_STATUS_PAUSED 1
  706. #define N_ZONE_STATUS_EXPIRED 2
  707. #define N_ZONE_TYPES 4
  708. #define N_ZONE_TYPES_PRIMARY 0
  709. #define N_ZONE_TYPES_DS_PRIMARY 1
  710. #define N_ZONE_TYPES_SECONDARY 2
  711. #define N_ZONE_TYPES_STUB 3
  712. void CDNSZone_GeneralIPEditor::OnChangeData()
  713. {
  714. if (m_bNoUpdateNow)
  715. {
  716. return;
  717. }
  718. ((CDNSZone_GeneralPropertyPage*)GetParentWnd())->OnChangeIPEditorData();
  719. }
  720. void CDNSZone_GeneralIPEditor::FindMastersNames()
  721. {
  722. m_bNoUpdateNow = TRUE;
  723. FindNames();
  724. m_bNoUpdateNow = FALSE;
  725. }
  726. BEGIN_MESSAGE_MAP(CDNSZone_GeneralPropertyPage, CPropertyPageBase)
  727. ON_BN_CLICKED(IDC_CHANGE_TYPE_BUTTON, OnChangeTypeButton)
  728. #ifdef USE_NDNC
  729. ON_BN_CLICKED(IDC_CHANGE_REPL_BUTTON, OnChangeReplButton)
  730. #endif // USE_NDNC
  731. ON_BN_CLICKED(IDC_PAUSE_START_BUTTON, OnPauseStartButton)
  732. ON_EN_CHANGE(IDC_FILE_NAME_EDIT, OnChangePrimaryFileNameEdit)
  733. ON_CBN_SELCHANGE(IDC_PRIMARY_DYN_UPD_COMBO, OnChangePrimaryDynamicUpdateCombo)
  734. ON_BN_CLICKED(IDC_BROWSE_MASTERS_BUTTON, OnBrowseMasters)
  735. ON_BN_CLICKED(IDC_FIND_MASTERS_NAMES_BUTTON, OnFindMastersNames)
  736. ON_BN_CLICKED(IDC_AGING_BUTTON, OnAging)
  737. ON_BN_CLICKED(IDC_LOCAL_LIST_CHECK, OnLocalCheck)
  738. END_MESSAGE_MAP()
  739. CDNSZone_GeneralPropertyPage::CDNSZone_GeneralPropertyPage()
  740. : CPropertyPageBase(CDNSZone_GeneralPropertyPage::IDD),
  741. m_statusHelper(N_ZONE_STATES), m_typeStaticHelper(N_ZONE_TYPES)
  742. {
  743. // actual values will be set when loading UI data
  744. m_bIsPrimary = TRUE;
  745. m_bIsPaused = FALSE;
  746. m_bIsExpired = FALSE;
  747. m_bDSIntegrated = FALSE;
  748. m_bIsStub = FALSE;
  749. m_bServerADSEnabled = FALSE;
  750. m_bScavengingEnabled = FALSE;
  751. m_dwRefreshInterval = 0;
  752. m_dwNoRefreshInterval = 0;
  753. m_nAllowsDynamicUpdate = ZONE_UPDATE_OFF;
  754. m_bDiscardUIState = FALSE;
  755. m_bDiscardUIStateShowMessage = FALSE;
  756. #ifdef USE_NDNC
  757. m_replType = none;
  758. #endif // USE_NDNC
  759. }
  760. void CDNSZone_GeneralPropertyPage::OnChangeIPEditorData()
  761. {
  762. ASSERT(!m_bIsPrimary);
  763. SetDirty(TRUE);
  764. GetFindMastersNamesButton()->EnableWindow(m_mastersEditor.GetCount()>0);
  765. }
  766. BOOL CDNSZone_GeneralPropertyPage::OnPropertyChange(BOOL, long*)
  767. {
  768. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  769. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  770. // need to apply the pause/start zone command ?
  771. BOOL bWasPaused = pZoneNode->IsPaused();
  772. if (bWasPaused != m_bIsPaused)
  773. {
  774. DNS_STATUS err = pZoneNode->TogglePauseHelper(pHolder->GetComponentData());
  775. if (err != 0)
  776. pHolder->SetError(err);
  777. }
  778. if (pZoneNode->GetZoneType() == DNS_ZONE_TYPE_SECONDARY ||
  779. pZoneNode->GetZoneType() == DNS_ZONE_TYPE_STUB)
  780. {
  781. // NTRAID#NTBUG9-762897-2003/01/16-JeffJon
  782. // Need to update the result pane view because changing stub
  783. // and secondary zones can easily put the zone in an expired
  784. // state which requires us to show the message view instead
  785. // of the normal result pane.
  786. pZoneNode->ToggleView(pHolder->GetComponentData());
  787. }
  788. return TRUE;
  789. }
  790. void CDNSZone_GeneralPropertyPage::SetUIData()
  791. {
  792. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  793. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  794. CDNSServerNode* pServerNode = pZoneNode->GetServerNode();
  795. //
  796. // get zone type
  797. //
  798. DWORD dwZoneType = pZoneNode->GetZoneType();
  799. ASSERT((dwZoneType == DNS_ZONE_TYPE_PRIMARY) ||
  800. (dwZoneType == DNS_ZONE_TYPE_SECONDARY)||
  801. (dwZoneType == DNS_ZONE_TYPE_STUB));
  802. m_bIsPrimary = (dwZoneType == DNS_ZONE_TYPE_PRIMARY);
  803. m_bIsStub = (dwZoneType == DNS_ZONE_TYPE_STUB);
  804. m_bDSIntegrated = pZoneNode->IsDSIntegrated();
  805. m_bIsPaused = pZoneNode->IsPaused();
  806. m_bIsExpired = pZoneNode->IsExpired();
  807. m_bScavengingEnabled = pZoneNode->IsScavengingEnabled();
  808. m_dwRefreshInterval = pZoneNode->GetAgingRefreshInterval();
  809. m_dwNoRefreshInterval = pZoneNode->GetAgingNoRefreshInterval();
  810. m_dwScavengingStart = pZoneNode->GetScavengingStart();
  811. #ifdef USE_NDNC
  812. m_replType = pZoneNode->GetDirectoryPartitionFlagsAsReplType();
  813. m_szCustomScope = pZoneNode->GetCustomPartitionName();
  814. //
  815. // Enable the replication scope button only for AD integrated zones
  816. //
  817. if (m_bDSIntegrated &&
  818. (DNS_SRV_BUILD_NUMBER(pServerNode->GetVersion()) >= DNS_SRV_BUILD_NUMBER_WHISTLER &&
  819. (DNS_SRV_MAJOR_VERSION(pServerNode->GetVersion()) > DNS_SRV_MAJOR_VERSION_NT_5 ||
  820. DNS_SRV_MINOR_VERSION(pServerNode->GetVersion()) >= DNS_SRV_MINOR_VERSION_WHISTLER)))
  821. {
  822. GetDlgItem(IDC_CHANGE_REPL_BUTTON)->EnableWindow(TRUE);
  823. GetDlgItem(IDC_REPL_LABEL_STATIC)->EnableWindow(TRUE);
  824. GetDlgItem(IDC_REPLICATION_STATIC)->EnableWindow(TRUE);
  825. }
  826. else
  827. {
  828. GetDlgItem(IDC_CHANGE_REPL_BUTTON)->EnableWindow(FALSE);
  829. GetDlgItem(IDC_REPL_LABEL_STATIC)->EnableWindow(FALSE);
  830. GetDlgItem(IDC_REPLICATION_STATIC)->EnableWindow(FALSE);
  831. }
  832. #endif // USE_NDNC
  833. //
  834. // change the controls to the zone type
  835. //
  836. ChangeUIControls();
  837. USES_CONVERSION;
  838. //
  839. // set the file name control
  840. //
  841. CString szZoneStorage;
  842. szZoneStorage = UTF8_TO_W(pZoneNode->GetDataFile());
  843. if (m_bIsPrimary)
  844. {
  845. m_nAllowsDynamicUpdate = pZoneNode->GetDynamicUpdate();
  846. }
  847. else // secondary
  848. {
  849. DWORD cAddrCount;
  850. PIP_ADDRESS pipMasters;
  851. if (m_bIsStub)
  852. {
  853. pZoneNode->GetLocalListOfMasters(&cAddrCount, &pipMasters);
  854. if (cAddrCount > 0 && pipMasters != NULL)
  855. {
  856. m_mastersEditor.AddAddresses(pipMasters, cAddrCount);
  857. SendDlgItemMessage(IDC_LOCAL_LIST_CHECK, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  858. }
  859. else
  860. {
  861. pZoneNode->GetMastersInfo(&cAddrCount, &pipMasters);
  862. if (cAddrCount > 0)
  863. {
  864. m_mastersEditor.AddAddresses(pipMasters, cAddrCount);
  865. }
  866. SendDlgItemMessage(IDC_LOCAL_LIST_CHECK, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  867. }
  868. }
  869. else
  870. {
  871. pZoneNode->GetMastersInfo(&cAddrCount, &pipMasters);
  872. if (cAddrCount > 0)
  873. {
  874. m_mastersEditor.AddAddresses(pipMasters, cAddrCount);
  875. }
  876. }
  877. }
  878. if (m_bDSIntegrated && !m_bIsStub)
  879. {
  880. GetDlgItem(IDC_AGING_STATIC)->EnableWindow(TRUE);
  881. GetDlgItem(IDC_AGING_STATIC)->ShowWindow(TRUE);
  882. GetDlgItem(IDC_AGING_BUTTON)->EnableWindow(TRUE);
  883. GetDlgItem(IDC_AGING_BUTTON)->ShowWindow(TRUE);
  884. }
  885. //
  886. // we set also the database name of the "other" zone type, just
  887. // in case the user promotes or demotes
  888. //
  889. GetFileNameEdit()->SetWindowText(szZoneStorage);
  890. SetPrimaryDynamicUpdateComboVal(m_nAllowsDynamicUpdate);
  891. if (m_bIsExpired)
  892. {
  893. //
  894. // hide the start/stop button
  895. //
  896. CButton* pBtn = GetPauseStartButton();
  897. pBtn->ShowWindow(FALSE);
  898. pBtn->EnableWindow(FALSE);
  899. //
  900. // change the text to "expired"
  901. //
  902. m_statusHelper.SetStateX(N_ZONE_STATUS_EXPIRED);
  903. }
  904. else
  905. {
  906. m_statusHelper.SetStateX(m_bIsPaused ? N_ZONE_STATUS_PAUSED : N_ZONE_STATUS_RUNNING);
  907. m_pauseStartHelper.SetToggleState(!m_bIsPaused);
  908. }
  909. }
  910. #define PRIMARY_DYN_UPD_COMBO_ITEM_COUNT 3
  911. void _MoveChildWindowY(CWnd* pChild, CWnd* pParent, int nY)
  912. {
  913. CRect r;
  914. pChild->GetWindowRect(r);
  915. pParent->ScreenToClient(r);
  916. int nDy = r.bottom - r.top;
  917. r.top = nY;
  918. r.bottom = nY + nDy;
  919. pChild->MoveWindow(r, TRUE);
  920. }
  921. BOOL CDNSZone_GeneralPropertyPage::OnInitDialog()
  922. {
  923. CPropertyPageBase::OnInitDialog();
  924. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  925. m_bServerADSEnabled = pHolder->GetZoneNode()->GetServerNode()->CanUseADS();
  926. VERIFY(m_mastersEditor.Initialize(this,
  927. GetParent(),
  928. IDC_MASTERS_BUTTON_UP,
  929. IDC_MASTERS_BUTTON_DOWN,
  930. IDC_MASTERS_BUTTON_ADD,
  931. IDC_MASTERS_BUTTON_REMOVE,
  932. IDC_MASTERS_IPEDIT,
  933. IDC_MASTERS_IP_LIST));
  934. UINT pnButtonStringIDs[2] = { IDS_BUTTON_TEXT_PAUSE_BUTTON, IDS_BUTTON_TEXT_START_BUTTON };
  935. VERIFY(m_pauseStartHelper.Init(this, IDC_PAUSE_START_BUTTON, pnButtonStringIDs));
  936. VERIFY(m_typeStaticHelper.Init(this, IDC_TYPE_STATIC));
  937. VERIFY(m_statusHelper.Init(this, IDC_STATUS_STATIC));
  938. VERIFY(m_zoneStorageStaticHelper.Init(this, IDC_STORAGE_STATIC));
  939. SendDlgItemMessage(IDC_FILE_NAME_EDIT, EM_SETLIMITTEXT, (WPARAM)_MAX_FNAME, 0);
  940. // initial positioning (in the resource these controls are at the bottom of the screen)
  941. // move relative the file name exit box
  942. CRect fileNameEditRect;
  943. GetDlgItem(IDC_FILE_NAME_EDIT)->GetWindowRect(fileNameEditRect);
  944. ScreenToClient(fileNameEditRect);
  945. // move below the edit box, with with separation equal of 6 (DBU)
  946. // height of the edit box.
  947. int nYPos = fileNameEditRect.bottom + 6;
  948. CComboBox* pDynamicUpdateCombo = GetPrimaryDynamicUpdateCombo();
  949. // The static control needs to be 2 lower
  950. _MoveChildWindowY(GetPrimaryDynamicUpdateStatic(), this, nYPos + 2);
  951. _MoveChildWindowY(pDynamicUpdateCombo, this, nYPos);
  952. // initialize the state of the page
  953. SetUIData();
  954. #ifdef USE_NDNC
  955. SetTextForReplicationScope();
  956. #endif
  957. SetDirty(FALSE);
  958. return TRUE; // return TRUE unless you set the focus to a control
  959. // EXCEPTION: OCX Property Pages should return FALSE
  960. }
  961. BOOL CDNSZone_GeneralPropertyPage::OnApply()
  962. {
  963. if (m_bDiscardUIState)
  964. {
  965. // if we get called from other pages, we have to make them fail
  966. if (m_bDiscardUIStateShowMessage)
  967. {
  968. DNSMessageBox(IDS_ZONE_LOADED_FROM_DS_WARNING);
  969. m_bDiscardUIStateShowMessage = FALSE;
  970. }
  971. return FALSE;
  972. }
  973. if (!IsDirty())
  974. return TRUE;
  975. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  976. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  977. CDNSServerNode* pServerNode = pZoneNode->GetServerNode();
  978. //
  979. // changed from primary to secondary or vice versa?
  980. //
  981. DWORD dwZoneType = pZoneNode->GetZoneType();
  982. ASSERT((dwZoneType == DNS_ZONE_TYPE_PRIMARY) ||
  983. (dwZoneType == DNS_ZONE_TYPE_SECONDARY)||
  984. (dwZoneType == DNS_ZONE_TYPE_STUB));
  985. BOOL bWasPrimary = (dwZoneType == DNS_ZONE_TYPE_PRIMARY);
  986. DNS_STATUS dwErr = 0;
  987. USES_CONVERSION;
  988. CString szDataStorageName;
  989. GetStorageName(szDataStorageName);
  990. DWORD dwLoadOptions;
  991. if (m_bIsPrimary)
  992. {
  993. dwLoadOptions = 0x0;
  994. PWSTR pszZoneFile = UTF8_TO_W(pZoneNode->GetDataFile());
  995. //
  996. // Check to see if this was primary before if so only submit changes if the storage changed
  997. //
  998. if (!bWasPrimary ||
  999. (bWasPrimary &&
  1000. ((pZoneNode->IsDSIntegrated() && !m_bDSIntegrated) ||
  1001. (!pZoneNode->IsDSIntegrated() && m_bDSIntegrated))) ||
  1002. (pszZoneFile && szDataStorageName.CompareNoCase(pszZoneFile)))
  1003. {
  1004. dwErr = pZoneNode->SetPrimary(dwLoadOptions, m_bDSIntegrated, szDataStorageName);
  1005. if (m_bDSIntegrated && (dwErr == DNS_ERROR_DS_ZONE_ALREADY_EXISTS))
  1006. {
  1007. FIX_THREAD_STATE_MFC_BUG();
  1008. CThemeContextActivator activator;
  1009. CDNSZoneChangeTypeDataConflict dlg(pHolder);
  1010. //
  1011. // if the zone was a primary, use in memory data
  1012. // otherwise, use DS data
  1013. //
  1014. dlg.m_bUseDsData = bWasPrimary ? FALSE : TRUE;
  1015. if (IDOK == dlg.DoModal())
  1016. {
  1017. //
  1018. // try again, getting options from dialog
  1019. //
  1020. dwLoadOptions = dlg.m_bUseDsData ? DNS_ZONE_LOAD_OVERWRITE_MEMORY : DNS_ZONE_LOAD_OVERWRITE_DS;
  1021. dwErr = pZoneNode->SetPrimary(dwLoadOptions, m_bDSIntegrated, szDataStorageName);
  1022. if ((dwErr == 0) && dlg.m_bUseDsData)
  1023. {
  1024. //
  1025. // we loaded from the DS, we will have to discard all the other
  1026. // changes the user has made.
  1027. //
  1028. m_bDiscardUIState = TRUE;
  1029. //
  1030. // tell the user to bail out
  1031. //
  1032. m_bDiscardUIStateShowMessage = FALSE;
  1033. DNSMessageBox(IDS_ZONE_LOADED_FROM_DS_WARNING);
  1034. SetDirty(FALSE);
  1035. return TRUE;
  1036. }
  1037. }
  1038. else
  1039. {
  1040. //
  1041. // user canceled the operation, just stop here
  1042. //
  1043. return FALSE;
  1044. }
  1045. }
  1046. }
  1047. if (dwErr == 0)
  1048. {
  1049. // update dynamic update flag, if changed
  1050. m_nAllowsDynamicUpdate = GetPrimaryDynamicUpdateComboVal();
  1051. UINT nWasDynamicUpdate = pZoneNode->GetDynamicUpdate();
  1052. if ( (dwErr == 0) && (m_nAllowsDynamicUpdate != nWasDynamicUpdate) )
  1053. {
  1054. dwErr = pZoneNode->SetDynamicUpdate(m_nAllowsDynamicUpdate);
  1055. if (dwErr != 0)
  1056. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_DYN_UPD);
  1057. }
  1058. }
  1059. else
  1060. {
  1061. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_PRIMARY);
  1062. }
  1063. if (dwErr == 0 && m_bIsPrimary)
  1064. {
  1065. dwErr = pZoneNode->SetAgingNoRefreshInterval(m_dwNoRefreshInterval);
  1066. if (dwErr != 0)
  1067. {
  1068. DNSErrorDialog(dwErr, IDS_MSG_ERROR_NO_REFRESH_INTERVAL);
  1069. return FALSE;
  1070. }
  1071. dwErr = pZoneNode->SetAgingRefreshInterval(m_dwRefreshInterval);
  1072. if (dwErr != 0)
  1073. {
  1074. DNSErrorDialog(dwErr, IDS_MSG_ERROR_REFRESH_INTERVAL);
  1075. return FALSE;
  1076. }
  1077. dwErr = pZoneNode->SetScavengingEnabled(m_bScavengingEnabled);
  1078. if (dwErr != 0)
  1079. {
  1080. DNSErrorDialog(dwErr, IDS_MSG_ERROR_SCAVENGING_ENABLED);
  1081. return FALSE;
  1082. }
  1083. }
  1084. }
  1085. else // it is a secondary or stub
  1086. {
  1087. //
  1088. // get data from the IP editor
  1089. //
  1090. DWORD cAddrCount = m_mastersEditor.GetCount();
  1091. // NTRAID#NTBUG9-655784-2002/07/05-artm
  1092. // Initialize the array.
  1093. DWORD* pArr = (cAddrCount > 0) ? (DWORD*) calloc(cAddrCount, sizeof(DWORD)) : NULL;
  1094. if (cAddrCount > 0)
  1095. {
  1096. int nFilled = 0;
  1097. // NTRAID#NTBUG9-653630-2002/07/05-artm
  1098. if (pArr)
  1099. {
  1100. m_mastersEditor.GetAddresses(pArr, cAddrCount, &nFilled);
  1101. ASSERT(nFilled == (int)cAddrCount);
  1102. }
  1103. else
  1104. {
  1105. // Out of memory! Try to tell the user, and abort the operation.
  1106. dwErr = ERROR_OUTOFMEMORY;
  1107. DNSDisplaySystemError(dwErr);
  1108. return FALSE;
  1109. }
  1110. }
  1111. dwLoadOptions = 0x0;
  1112. if (m_bIsStub)
  1113. {
  1114. LRESULT lLocalListOfMasters = SendDlgItemMessage(IDC_LOCAL_LIST_CHECK, BM_GETCHECK, 0, 0);
  1115. BOOL bLocalListOfMasters = (lLocalListOfMasters == BST_CHECKED);
  1116. dwErr = pZoneNode->SetStub(cAddrCount,
  1117. pArr,
  1118. dwLoadOptions,
  1119. m_bDSIntegrated,
  1120. szDataStorageName,
  1121. bLocalListOfMasters);
  1122. if (dwErr != 0)
  1123. {
  1124. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_STUB);
  1125. }
  1126. }
  1127. else
  1128. {
  1129. dwErr = pZoneNode->SetSecondary(cAddrCount, pArr, dwLoadOptions, szDataStorageName);
  1130. if (dwErr != 0)
  1131. {
  1132. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_SECONDARY);
  1133. }
  1134. }
  1135. if (pArr)
  1136. {
  1137. free(pArr);
  1138. pArr = 0;
  1139. }
  1140. }
  1141. #ifdef USE_NDNC
  1142. if ((DNS_SRV_BUILD_NUMBER(pServerNode->GetVersion()) >= DNS_SRV_BUILD_NUMBER_WHISTLER &&
  1143. (DNS_SRV_MAJOR_VERSION(pServerNode->GetVersion()) > DNS_SRV_MAJOR_VERSION_NT_5 ||
  1144. DNS_SRV_MINOR_VERSION(pServerNode->GetVersion()) >= DNS_SRV_MINOR_VERSION_WHISTLER)) &&
  1145. (m_replType != pZoneNode->GetDirectoryPartitionFlagsAsReplType() ||
  1146. _wcsicmp(m_szCustomScope, pZoneNode->GetCustomPartitionName()) != 0) &&
  1147. m_bDSIntegrated)
  1148. {
  1149. dwErr = pZoneNode->ChangeDirectoryPartitionType(m_replType, m_szCustomScope);
  1150. if (dwErr != 0)
  1151. {
  1152. DNSErrorDialog(dwErr, IDS_ERROR_ZONE_REPLTYPE);
  1153. }
  1154. }
  1155. #endif
  1156. // if promoted or demoted, have to change icon
  1157. // if paused/started, have to apply the command
  1158. BOOL bWasPaused = pZoneNode->IsPaused();
  1159. DNS_STATUS dwPauseStopErr = 0;
  1160. if ((bWasPrimary != m_bIsPrimary) || (bWasPaused != m_bIsPaused))
  1161. {
  1162. dwPauseStopErr = pHolder->NotifyConsole(this);
  1163. if (dwPauseStopErr != 0)
  1164. {
  1165. if (m_bIsPaused)
  1166. DNSErrorDialog(dwPauseStopErr, IDS_ERROR_ZONE_PAUSE);
  1167. else
  1168. DNSErrorDialog(dwPauseStopErr, IDS_ERROR_ZONE_START);
  1169. }
  1170. }
  1171. if ( (dwErr != 0) || (dwPauseStopErr != 0) )
  1172. return FALSE; // something went wrong, already got error messages
  1173. // NTRAID#NTBUG9-762897-2003/01/16-JeffJon
  1174. // Need to update the result pane view because changing stub
  1175. // and secondary zones can easily put the zone in an expired
  1176. // state which requires us to show the message view instead
  1177. // of the normal result pane.
  1178. pHolder->NotifyConsole(this);
  1179. SetDirty(FALSE);
  1180. return TRUE;
  1181. }
  1182. void CDNSZone_GeneralPropertyPage::OnAging()
  1183. {
  1184. CThemeContextActivator activator;
  1185. CDNSZonePropertyPageHolder* pHolder =
  1186. (CDNSZonePropertyPageHolder*)GetHolder();
  1187. CDNSZone_AgingDialog dlg(pHolder, IDD_ZONE_AGING_DIALOG, pHolder->GetComponentData());
  1188. dlg.m_dwRefreshInterval = m_dwRefreshInterval;
  1189. dlg.m_dwNoRefreshInterval = m_dwNoRefreshInterval;
  1190. dlg.m_dwScavengingStart = m_dwScavengingStart;
  1191. dlg.m_fScavengingEnabled = m_bScavengingEnabled;
  1192. dlg.m_bAdvancedView = pHolder->IsAdvancedView();
  1193. if (IDCANCEL == dlg.DoModal())
  1194. {
  1195. return;
  1196. }
  1197. m_dwRefreshInterval = dlg.m_dwRefreshInterval;
  1198. m_dwNoRefreshInterval = dlg.m_dwNoRefreshInterval;
  1199. m_bScavengingEnabled = dlg.m_fScavengingEnabled;
  1200. SetDirty(TRUE);
  1201. }
  1202. void CDNSZone_GeneralPropertyPage::OnLocalCheck()
  1203. {
  1204. SetDirty(TRUE);
  1205. }
  1206. #ifdef USE_NDNC
  1207. void CDNSZone_GeneralPropertyPage::OnChangeReplButton()
  1208. {
  1209. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1210. FIX_THREAD_STATE_MFC_BUG();
  1211. CThemeContextActivator activator;
  1212. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1213. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1214. CDNSZoneChangeReplicationScopeDialog dlg(GetHolder(),
  1215. m_replType,
  1216. m_szCustomScope,
  1217. pZoneNode->GetServerNode()->GetVersion());
  1218. if (IDCANCEL == dlg.DoModal())
  1219. {
  1220. return;
  1221. }
  1222. BOOL bDirty = (m_replType != dlg.m_newReplType) ||
  1223. (m_szCustomScope != dlg.m_szCustomScope);
  1224. if (!bDirty)
  1225. {
  1226. return;
  1227. }
  1228. m_replType = dlg.m_newReplType;
  1229. m_szCustomScope = dlg.m_szCustomScope;
  1230. SetTextForReplicationScope();
  1231. SetDirty(TRUE);
  1232. }
  1233. void CDNSZone_GeneralPropertyPage::SetTextForReplicationScope()
  1234. {
  1235. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1236. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1237. CDNSServerNode* pServerNode = pZoneNode->GetServerNode();
  1238. UINT nStringID = 0;
  1239. CString szReplText;
  1240. if (m_bDSIntegrated)
  1241. {
  1242. switch(m_replType)
  1243. {
  1244. case domain :
  1245. nStringID = IDS_ZONE_REPLICATION_DOMAIN_TEXT;
  1246. break;
  1247. case forest :
  1248. nStringID = IDS_ZONE_REPLICATION_FOREST_TEXT;
  1249. break;
  1250. case custom :
  1251. nStringID = IDS_ZONE_REPLICATION_CUSTOM_TEXT;
  1252. break;
  1253. default :
  1254. nStringID = IDS_ZONE_REPLICATION_W2K_TEXT;
  1255. break;
  1256. }
  1257. if (m_bDSIntegrated &&
  1258. (DNS_SRV_BUILD_NUMBER(pServerNode->GetVersion()) >= DNS_SRV_BUILD_NUMBER_WHISTLER &&
  1259. (DNS_SRV_MAJOR_VERSION(pServerNode->GetVersion()) > DNS_SRV_MAJOR_VERSION_NT_5 ||
  1260. DNS_SRV_MINOR_VERSION(pServerNode->GetVersion()) >= DNS_SRV_MINOR_VERSION_WHISTLER)))
  1261. {
  1262. GetDlgItem(IDC_CHANGE_REPL_BUTTON)->EnableWindow(TRUE);
  1263. GetDlgItem(IDC_REPL_LABEL_STATIC)->EnableWindow(TRUE);
  1264. GetDlgItem(IDC_REPLICATION_STATIC)->EnableWindow(TRUE);
  1265. }
  1266. }
  1267. else
  1268. {
  1269. nStringID = IDS_ZONE_REPLICATION_NONDS_TEXT;
  1270. GetDlgItem(IDC_CHANGE_REPL_BUTTON)->EnableWindow(FALSE);
  1271. GetDlgItem(IDC_REPL_LABEL_STATIC)->EnableWindow(FALSE);
  1272. GetDlgItem(IDC_REPLICATION_STATIC)->EnableWindow(FALSE);
  1273. }
  1274. szReplText.LoadString(nStringID);
  1275. SetDlgItemText(IDC_REPLICATION_STATIC, szReplText);
  1276. }
  1277. #endif // USE_NDNC
  1278. void CDNSZone_GeneralPropertyPage::OnChangeTypeButton()
  1279. {
  1280. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1281. FIX_THREAD_STATE_MFC_BUG();
  1282. CThemeContextActivator activator;
  1283. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1284. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1285. CDNSZoneChangeTypeDialog dlg(GetHolder(),
  1286. m_bServerADSEnabled,
  1287. pZoneNode->GetServerNode()->GetVersion());
  1288. dlg.m_bIsPrimary = m_bIsPrimary;
  1289. dlg.m_bIsStub = m_bIsStub;
  1290. dlg.m_bDSIntegrated = m_bDSIntegrated;
  1291. if (IDCANCEL == dlg.DoModal())
  1292. {
  1293. return;
  1294. }
  1295. BOOL bDirty = (m_bIsPrimary != dlg.m_bIsPrimary) ||
  1296. (m_bDSIntegrated != dlg.m_bDSIntegrated) ||
  1297. (m_bIsStub != dlg.m_bIsStub);
  1298. if (!bDirty)
  1299. {
  1300. return;
  1301. }
  1302. CString szZoneStorage;
  1303. GetFileNameEdit()->GetWindowText(szZoneStorage);
  1304. if (dlg.m_bDSIntegrated == FALSE &&
  1305. m_bDSIntegrated == TRUE &&
  1306. szZoneStorage.IsEmpty())
  1307. {
  1308. //
  1309. // we have no file name, synthesize one
  1310. //
  1311. CString szZoneName = pZoneNode->GetDisplayName();
  1312. int nLen = szZoneName.GetLength();
  1313. if (nLen == 0)
  1314. {
  1315. szZoneStorage.Empty();
  1316. }
  1317. else if (nLen == 1 && szZoneName[0] == TEXT('.'))
  1318. {
  1319. szZoneStorage = _T("root.dns");
  1320. }
  1321. else
  1322. {
  1323. LPCTSTR lpszFmt = ( TEXT('.') == szZoneName.GetAt(nLen-1))
  1324. ? _T("%sdns") : _T("%s.dns");
  1325. szZoneStorage.Format(lpszFmt, (LPCTSTR)szZoneName);
  1326. }
  1327. GetFileNameEdit()->SetWindowText(szZoneStorage);
  1328. }
  1329. else if (dlg.m_bDSIntegrated == TRUE &&
  1330. m_bDSIntegrated == FALSE)
  1331. {
  1332. //
  1333. // Set the default replication
  1334. // if the zone was previously file based
  1335. //
  1336. if (pZoneNode->GetServerNode()->GetDomainVersion() > DS_BEHAVIOR_WIN2000)
  1337. {
  1338. m_replType = domain;
  1339. }
  1340. else
  1341. {
  1342. m_replType = w2k;
  1343. }
  1344. }
  1345. m_bIsPrimary = dlg.m_bIsPrimary;
  1346. m_bDSIntegrated = dlg.m_bDSIntegrated;
  1347. m_bIsStub = dlg.m_bIsStub;
  1348. SetDirty(TRUE);
  1349. ChangeUIControls();
  1350. #ifdef USE_NDNC
  1351. SetTextForReplicationScope();
  1352. #endif
  1353. }
  1354. void CDNSZone_GeneralPropertyPage::OnPauseStartButton()
  1355. {
  1356. ASSERT(!m_bIsExpired); // the button should not be enabled
  1357. SetDirty(TRUE);
  1358. m_bIsPaused = !m_bIsPaused;
  1359. m_pauseStartHelper.SetToggleState(!m_bIsPaused);
  1360. m_statusHelper.SetStateX(m_bIsPaused ? N_ZONE_STATUS_PAUSED : N_ZONE_STATUS_RUNNING);
  1361. }
  1362. void CDNSZone_GeneralPropertyPage::OnBrowseMasters()
  1363. {
  1364. ASSERT(!m_bIsPrimary);
  1365. CDNSZonePropertyPageHolder* pZoneHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1366. if (!m_mastersEditor.BrowseFromDNSNamespace(pZoneHolder->GetComponentData(),
  1367. pZoneHolder,
  1368. TRUE,
  1369. pZoneHolder->GetZoneNode()->GetServerNode()->GetDisplayName()))
  1370. {
  1371. DNSMessageBox(IDS_MSG_ZONE_MASTERS_BROWSE_FAIL);
  1372. }
  1373. }
  1374. void CDNSZone_GeneralPropertyPage::OnFindMastersNames()
  1375. {
  1376. m_mastersEditor.FindMastersNames();
  1377. }
  1378. void CDNSZone_GeneralPropertyPage::SetPrimaryDynamicUpdateComboVal(UINT nAllowsDynamicUpdate)
  1379. {
  1380. int nIndex = 0;
  1381. switch (nAllowsDynamicUpdate)
  1382. {
  1383. case ZONE_UPDATE_OFF:
  1384. nIndex = 0;
  1385. break;
  1386. case ZONE_UPDATE_UNSECURE:
  1387. nIndex = 1;
  1388. break;
  1389. case ZONE_UPDATE_SECURE:
  1390. nIndex = 2;
  1391. break;
  1392. default:
  1393. ASSERT(FALSE);
  1394. }
  1395. VERIFY(CB_ERR != GetPrimaryDynamicUpdateCombo()->SetCurSel(nIndex));
  1396. }
  1397. UINT CDNSZone_GeneralPropertyPage::GetPrimaryDynamicUpdateComboVal()
  1398. {
  1399. int nIndex = GetPrimaryDynamicUpdateCombo()->GetCurSel();
  1400. ASSERT(nIndex != CB_ERR);
  1401. UINT nVal = 0;
  1402. switch (nIndex)
  1403. {
  1404. case 0:
  1405. nVal = ZONE_UPDATE_OFF;
  1406. break;
  1407. case 1:
  1408. nVal = ZONE_UPDATE_UNSECURE;
  1409. break;
  1410. case 2:
  1411. nVal = ZONE_UPDATE_SECURE;
  1412. break;
  1413. default:
  1414. ASSERT(FALSE);
  1415. }
  1416. return nVal;
  1417. }
  1418. void CDNSZone_GeneralPropertyPage::ChangeUIControlHelper(CWnd* pChild, BOOL bEnable)
  1419. {
  1420. pChild->EnableWindow(bEnable);
  1421. pChild->ShowWindow(bEnable);
  1422. }
  1423. void CDNSZone_GeneralPropertyPage::ChangeUIControls()
  1424. {
  1425. // change button label
  1426. int nType;
  1427. if (m_bIsPrimary)
  1428. {
  1429. nType = m_bDSIntegrated ? N_ZONE_TYPES_DS_PRIMARY : N_ZONE_TYPES_PRIMARY;
  1430. }
  1431. else
  1432. {
  1433. if (m_bIsStub)
  1434. {
  1435. nType = N_ZONE_TYPES_STUB;
  1436. }
  1437. else
  1438. {
  1439. nType = N_ZONE_TYPES_SECONDARY;
  1440. }
  1441. }
  1442. m_typeStaticHelper.SetStateX(nType);
  1443. //
  1444. // file name controls (show for secondary and for non DS integrated primary and stub)
  1445. //
  1446. BOOL bNotDSIntegrated = (!m_bIsPrimary && !m_bIsStub) ||
  1447. (m_bIsPrimary && !m_bDSIntegrated) ||
  1448. (m_bIsStub && !m_bDSIntegrated);
  1449. m_zoneStorageStaticHelper.SetToggleState(bNotDSIntegrated); // bNotDSIntegrated == bShowEdit
  1450. ChangeUIControlHelper(GetFileNameEdit(), bNotDSIntegrated); // bNotDSIntegrated == bShowEdit
  1451. //
  1452. // change primary zone controls
  1453. CComboBox* pPrimaryDynamicUpdateCombo = GetPrimaryDynamicUpdateCombo();
  1454. //
  1455. // see if the combo box had a selection in it and save it
  1456. //
  1457. UINT nAllowsDynamicUpdateSaved = ZONE_UPDATE_OFF;
  1458. if (pPrimaryDynamicUpdateCombo->GetCurSel() != CB_ERR)
  1459. {
  1460. nAllowsDynamicUpdateSaved = GetPrimaryDynamicUpdateComboVal();
  1461. }
  1462. //
  1463. // set strings in the combo box
  1464. //
  1465. UINT nMaxAddCount = PRIMARY_DYN_UPD_COMBO_ITEM_COUNT;
  1466. //
  1467. // the last item in the combo box would be the "secure dynamic udate"
  1468. // which is valid only for DS integrated primaries
  1469. //
  1470. if (bNotDSIntegrated)
  1471. {
  1472. nMaxAddCount--; // remove the last one
  1473. }
  1474. VERIFY(LoadStringsToComboBox(_Module.GetModuleInstance(),
  1475. pPrimaryDynamicUpdateCombo,
  1476. IDS_ZONE_PRIMARY_DYN_UPD_OPTIONS,
  1477. 256, nMaxAddCount));
  1478. //
  1479. // reset selection
  1480. //
  1481. if (bNotDSIntegrated && (nAllowsDynamicUpdateSaved == ZONE_UPDATE_SECURE))
  1482. {
  1483. //
  1484. // the selected secure update otion is gone, so turn off secure update
  1485. //
  1486. nAllowsDynamicUpdateSaved = ZONE_UPDATE_OFF;
  1487. }
  1488. SetPrimaryDynamicUpdateComboVal(nAllowsDynamicUpdateSaved);
  1489. ChangeUIControlHelper(GetPrimaryDynamicUpdateStatic(), m_bIsPrimary);
  1490. ChangeUIControlHelper(GetPrimaryDynamicUpdateCombo(), m_bIsPrimary);
  1491. ChangeUIControlHelper(GetPrimaryDynamicWarningText(), m_bIsPrimary);
  1492. ChangeUIControlHelper(GetPrimaryDynamicWarningIcon(), m_bIsPrimary);
  1493. //
  1494. // change secondary zone controls
  1495. //
  1496. GetIPLabel()->ShowWindow(!m_bIsPrimary);
  1497. GetIPLabel()->EnableWindow(!m_bIsPrimary);
  1498. m_mastersEditor.ShowUI(!m_bIsPrimary);
  1499. CButton* pBrowseButton = GetMastersBrowseButton();
  1500. pBrowseButton->ShowWindow(!m_bIsPrimary);
  1501. pBrowseButton->EnableWindow(!m_bIsPrimary);
  1502. CButton* pFindMastersNamesButton = GetFindMastersNamesButton();
  1503. pFindMastersNamesButton->ShowWindow(!m_bIsPrimary);
  1504. pFindMastersNamesButton->EnableWindow(!m_bIsPrimary && m_mastersEditor.GetCount()>0);
  1505. GetDlgItem(IDC_LOCAL_LIST_CHECK)->EnableWindow(m_bIsStub && !bNotDSIntegrated);
  1506. GetDlgItem(IDC_LOCAL_LIST_CHECK)->ShowWindow(m_bIsStub && !bNotDSIntegrated);
  1507. GetDlgItem(IDC_AGING_STATIC)->EnableWindow(m_bIsPrimary);
  1508. GetDlgItem(IDC_AGING_STATIC)->ShowWindow(m_bIsPrimary);
  1509. GetDlgItem(IDC_AGING_BUTTON)->EnableWindow(m_bIsPrimary);
  1510. GetDlgItem(IDC_AGING_BUTTON)->ShowWindow(m_bIsPrimary);
  1511. }
  1512. void CDNSZone_GeneralPropertyPage::GetStorageName(CString& szDataStorageName)
  1513. {
  1514. //
  1515. // only for secondary ad for non DS integrated primary)
  1516. //
  1517. GetFileNameEdit()->GetWindowText(szDataStorageName);
  1518. szDataStorageName.TrimLeft();
  1519. szDataStorageName.TrimRight();
  1520. }
  1521. ///////////////////////////////////////////////////////////////////////////////
  1522. // CDNSZone_ZoneTransferPropertyPage
  1523. void CDNSZone_ZoneTransferPropertyPage::CDNSSecondariesIPEditor::OnChangeData()
  1524. {
  1525. CDNSZone_ZoneTransferPropertyPage* pPage = (CDNSZone_ZoneTransferPropertyPage*)GetParentWnd();
  1526. pPage->SetDirty(TRUE);
  1527. }
  1528. BEGIN_MESSAGE_MAP(CDNSZone_ZoneTransferPropertyPage, CPropertyPageBase)
  1529. ON_BN_CLICKED(IDC_CHECK_ALLOW_TRANSFERS, OnRadioSecSecureNone)
  1530. ON_BN_CLICKED(IDC_RADIO_SECSECURE_OFF, OnRadioSecSecureOff)
  1531. ON_BN_CLICKED(IDC_RADIO_SECSECURE_NS, OnRadioSecSecureNS)
  1532. ON_BN_CLICKED(IDC_RADIO_SECSECURE_LIST, OnRadioSecSecureList)
  1533. ON_BN_CLICKED(IDC_BUTTON_NOTIFY, OnButtonNotify)
  1534. END_MESSAGE_MAP()
  1535. CDNSZone_ZoneTransferPropertyPage::CDNSZone_ZoneTransferPropertyPage()
  1536. : CPropertyPageBase(IDD_ZONE_ZONE_TRANSFER_PAGE)
  1537. {
  1538. m_fNotifyLevel = (DWORD)-1;
  1539. m_cNotify = 0;
  1540. m_aipNotify = NULL;
  1541. m_bStub = FALSE;
  1542. }
  1543. CDNSZone_ZoneTransferPropertyPage::~CDNSZone_ZoneTransferPropertyPage()
  1544. {
  1545. if (m_aipNotify != NULL)
  1546. free(m_aipNotify);
  1547. }
  1548. BOOL CDNSZone_ZoneTransferPropertyPage::OnSetActive()
  1549. {
  1550. CDNSZonePropertyPageHolder* pHolder =
  1551. (CDNSZonePropertyPageHolder*)GetHolder();
  1552. m_bStub = pHolder->IsStubZoneUI();
  1553. GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS)->EnableWindow(!m_bStub);
  1554. return CPropertyPageBase::OnSetActive();
  1555. }
  1556. void CDNSZone_ZoneTransferPropertyPage::OnButtonNotify()
  1557. {
  1558. CDNSZonePropertyPageHolder* pHolder =
  1559. (CDNSZonePropertyPageHolder*)GetHolder();
  1560. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1561. FIX_THREAD_STATE_MFC_BUG();
  1562. CThemeContextActivator activator;
  1563. CDNSZoneNotifyDialog dlg(this, pZoneNode->GetZoneType() == DNS_ZONE_TYPE_SECONDARY,
  1564. pHolder->GetComponentData());
  1565. if (IDOK == dlg.DoModal())
  1566. {
  1567. //
  1568. // the dialog already updated the notify data
  1569. //
  1570. SetDirty(TRUE);
  1571. }
  1572. }
  1573. void CDNSZone_ZoneTransferPropertyPage::SyncUIRadioHelper(UINT nRadio)
  1574. {
  1575. BOOL bState = ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->GetCheck();
  1576. GetNotifyButton()->EnableWindow(bState);
  1577. m_secondariesListEditor.EnableUI(IDC_RADIO_SECSECURE_LIST == nRadio, TRUE);
  1578. if (IDC_RADIO_SECSECURE_LIST != nRadio)
  1579. m_secondariesListEditor.Clear();
  1580. SetDirty(TRUE);
  1581. if (IDC_CHECK_ALLOW_TRANSFERS == nRadio)
  1582. {
  1583. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->EnableWindow(bState);
  1584. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->EnableWindow(bState);
  1585. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_NS))->EnableWindow(bState);
  1586. BOOL bRadioState = ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->GetCheck();
  1587. m_secondariesListEditor.EnableUI(bRadioState && bState, TRUE);
  1588. }
  1589. }
  1590. int CDNSZone_ZoneTransferPropertyPage::SetRadioState(DWORD fSecureSecondaries)
  1591. {
  1592. int nRadio = 0;
  1593. switch (fSecureSecondaries)
  1594. {
  1595. case ZONE_SECSECURE_NONE:
  1596. nRadio = IDC_CHECK_ALLOW_TRANSFERS;
  1597. ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->SetCheck(FALSE);
  1598. break;
  1599. case ZONE_SECSECURE_LIST:
  1600. nRadio = IDC_RADIO_SECSECURE_LIST;
  1601. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->SetCheck(TRUE);
  1602. ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->SetCheck(TRUE);
  1603. break;
  1604. case ZONE_SECSECURE_OFF:
  1605. nRadio = IDC_RADIO_SECSECURE_OFF;
  1606. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->SetCheck(TRUE);
  1607. ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->SetCheck(TRUE);
  1608. break;
  1609. case ZONE_SECSECURE_NS:
  1610. nRadio = IDC_RADIO_SECSECURE_NS;
  1611. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_NS))->SetCheck(TRUE);
  1612. ((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->SetCheck(TRUE);
  1613. break;
  1614. }
  1615. ASSERT(nRadio != 0);
  1616. return nRadio;
  1617. }
  1618. DWORD CDNSZone_ZoneTransferPropertyPage::GetRadioState()
  1619. {
  1620. int nRadio = 0;
  1621. if (!((CButton*)GetDlgItem(IDC_CHECK_ALLOW_TRANSFERS))->GetCheck())
  1622. {
  1623. nRadio = IDC_CHECK_ALLOW_TRANSFERS;
  1624. }
  1625. else
  1626. {
  1627. if (((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->GetCheck())
  1628. {
  1629. nRadio = IDC_RADIO_SECSECURE_OFF;
  1630. }
  1631. else if (((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->GetCheck())
  1632. {
  1633. nRadio = IDC_RADIO_SECSECURE_LIST;
  1634. }
  1635. else if (((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_NS))->GetCheck())
  1636. {
  1637. nRadio = IDC_RADIO_SECSECURE_NS;
  1638. }
  1639. }
  1640. ASSERT(nRadio != 0);
  1641. DWORD fSecureSecondaries = (DWORD)-1;
  1642. switch (nRadio)
  1643. {
  1644. case IDC_CHECK_ALLOW_TRANSFERS:
  1645. fSecureSecondaries = ZONE_SECSECURE_NONE;
  1646. break;
  1647. case IDC_RADIO_SECSECURE_LIST:
  1648. fSecureSecondaries = ZONE_SECSECURE_LIST;
  1649. break;
  1650. case IDC_RADIO_SECSECURE_OFF:
  1651. fSecureSecondaries = ZONE_SECSECURE_OFF;
  1652. break;
  1653. case IDC_RADIO_SECSECURE_NS:
  1654. fSecureSecondaries = ZONE_SECSECURE_NS;
  1655. break;
  1656. }
  1657. ASSERT(fSecureSecondaries != (DWORD)-1);
  1658. return fSecureSecondaries;
  1659. }
  1660. BOOL CDNSZone_ZoneTransferPropertyPage::OnInitDialog()
  1661. {
  1662. //
  1663. // NOTE: this control has to be initialized before the
  1664. // base class OnInitDialog is called because the
  1665. // base class OnInitDialog calls SetUIData() in
  1666. // this derived class which uses this control
  1667. //
  1668. VERIFY(m_secondariesListEditor.Initialize(this,
  1669. GetParent(),
  1670. IDC_BUTTON_UP,
  1671. IDC_BUTTON_DOWN,
  1672. IDC_BUTTON_ADD,
  1673. IDC_BUTTON_REMOVE,
  1674. IDC_IPEDIT,
  1675. IDC_LIST));
  1676. CPropertyPageBase::OnInitDialog();
  1677. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1678. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1679. DWORD fSecureSecondaries;
  1680. DWORD cSecondaries;
  1681. PIP_ADDRESS aipSecondaries;
  1682. ASSERT(m_fNotifyLevel == (DWORD)-1);
  1683. ASSERT(m_cNotify == 0);
  1684. ASSERT(m_aipNotify == NULL);
  1685. pZoneNode->GetSecondariesInfo(&fSecureSecondaries, &cSecondaries, &aipSecondaries,
  1686. &m_fNotifyLevel, &m_cNotify, &m_aipNotify);
  1687. BOOL bSecondaryZone = pZoneNode->GetZoneType() == DNS_ZONE_TYPE_SECONDARY ||
  1688. pZoneNode->GetZoneType() == DNS_ZONE_TYPE_STUB;
  1689. if (bSecondaryZone)
  1690. {
  1691. //
  1692. // just to make sure here...
  1693. //
  1694. ASSERT(m_fNotifyLevel != ZONE_NOTIFY_ALL);
  1695. if (m_fNotifyLevel == ZONE_NOTIFY_ALL)
  1696. {
  1697. m_fNotifyLevel = ZONE_NOTIFY_OFF;
  1698. }
  1699. }
  1700. if ( (m_cNotify > 0) && (m_aipNotify != NULL) )
  1701. {
  1702. //
  1703. // make a deep copy
  1704. //
  1705. PIP_ADDRESS aipNotifyTemp = (DWORD*) malloc(sizeof(DWORD)*m_cNotify);
  1706. if (aipNotifyTemp != NULL)
  1707. {
  1708. memcpy(aipNotifyTemp, m_aipNotify, sizeof(DWORD)*m_cNotify);
  1709. m_aipNotify = aipNotifyTemp;
  1710. }
  1711. }
  1712. if ( (ZONE_SECSECURE_LIST == fSecureSecondaries) && (cSecondaries > 0) )
  1713. {
  1714. m_secondariesListEditor.AddAddresses(aipSecondaries, cSecondaries);
  1715. }
  1716. SyncUIRadioHelper(SetRadioState(fSecureSecondaries));
  1717. BOOL bListState = ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_LIST))->GetCheck();
  1718. BOOL bAllState = ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->GetCheck();
  1719. BOOL bNSState = ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_NS))->GetCheck();
  1720. if (!bAllState && !bListState && !bNSState)
  1721. {
  1722. ((CButton*)GetDlgItem(IDC_RADIO_SECSECURE_OFF))->SetCheck(TRUE);
  1723. }
  1724. SetDirty(FALSE);
  1725. return TRUE; // return TRUE unless you set the focus to a control
  1726. // EXCEPTION: OCX Property Pages should return FALSE
  1727. }
  1728. BOOL CDNSZone_ZoneTransferPropertyPage::OnApply()
  1729. {
  1730. CDNSZonePropertyPageHolder* pHolder =
  1731. (CDNSZonePropertyPageHolder*)GetHolder();
  1732. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1733. // first commit possible zone type transition changes
  1734. if (!pHolder->ApplyGeneralPageChanges())
  1735. return FALSE;
  1736. if (!IsDirty())
  1737. return TRUE;
  1738. DWORD fSecureSecondaries = GetRadioState();
  1739. DWORD cSecondaries = 0;
  1740. DWORD* aipSecondaries = NULL;
  1741. if (fSecureSecondaries == ZONE_SECSECURE_LIST)
  1742. {
  1743. cSecondaries = m_secondariesListEditor.GetCount();
  1744. aipSecondaries = (cSecondaries > 0) ? (DWORD*) malloc(sizeof(DWORD)*cSecondaries) : NULL;
  1745. if (aipSecondaries != NULL && cSecondaries > 0)
  1746. {
  1747. int nFilled = 0;
  1748. m_secondariesListEditor.GetAddresses(aipSecondaries, cSecondaries, &nFilled);
  1749. ASSERT(nFilled == (int)cSecondaries);
  1750. }
  1751. }
  1752. BOOL bRet = TRUE;
  1753. // write to server
  1754. DNS_STATUS err = pZoneNode->ResetSecondaries(fSecureSecondaries, cSecondaries, aipSecondaries,
  1755. m_fNotifyLevel, m_cNotify, m_aipNotify);
  1756. if (err != 0)
  1757. {
  1758. DNSErrorDialog(err, IDS_MSG_ZONE_FAIL_UPDATE_ZONE_TRANSFERS);
  1759. bRet = FALSE;
  1760. }
  1761. if (aipSecondaries)
  1762. {
  1763. free (aipSecondaries);
  1764. aipSecondaries = 0;
  1765. }
  1766. // all went fine
  1767. if (bRet)
  1768. {
  1769. SetDirty(FALSE);
  1770. }
  1771. return bRet;
  1772. }
  1773. ////////////////////////////////////////////////////////////////////////////
  1774. // CDNSZone_SOA_PropertyPage
  1775. void CDNS_SOA_SerialNumberEditGroup::OnEditChange()
  1776. {
  1777. m_pPage->SetDirty(TRUE);
  1778. }
  1779. void CDNS_SOA_TimeIntervalEditGroup::OnEditChange()
  1780. {
  1781. m_pPage->SetDirty(TRUE);
  1782. }
  1783. BEGIN_MESSAGE_MAP(CDNSZone_SOA_PropertyPage, CDNSRecordPropertyPage)
  1784. ON_EN_CHANGE(IDC_PRIMARY_SERV_EDIT, OnPrimaryServerChange)
  1785. ON_EN_CHANGE(IDC_RESP_PARTY_EDIT, OnResponsiblePartyChange)
  1786. ON_EN_CHANGE(IDC_MIN_TTLEDIT, OnMinTTLChange)
  1787. ON_BN_CLICKED(IDC_BROWSE_SERV_BUTTON, OnBrowseServer)
  1788. ON_BN_CLICKED(IDC_BROWSE_PARTY_BUTTON, OnBrowseResponsibleParty)
  1789. END_MESSAGE_MAP()
  1790. CDNSZone_SOA_PropertyPage::CDNSZone_SOA_PropertyPage(BOOL bZoneRoot)
  1791. : CDNSRecordPropertyPage(IDD_RR_SOA)
  1792. {
  1793. m_pTempSOARecord = NULL;
  1794. m_bZoneRoot = bZoneRoot;
  1795. }
  1796. CDNSZone_SOA_PropertyPage::~CDNSZone_SOA_PropertyPage()
  1797. {
  1798. if (m_bZoneRoot && (m_pTempSOARecord != NULL))
  1799. delete m_pTempSOARecord;
  1800. }
  1801. void _DisableDialogControls(HWND hWnd)
  1802. {
  1803. HWND hWndCurr = ::GetWindow(hWnd, GW_CHILD);
  1804. if (hWndCurr != NULL)
  1805. {
  1806. ::ShowWindow(hWndCurr,FALSE);
  1807. ::EnableWindow(hWndCurr,FALSE);
  1808. hWndCurr = ::GetNextWindow(hWndCurr, GW_HWNDNEXT);
  1809. while (hWndCurr)
  1810. {
  1811. ::ShowWindow(hWndCurr,FALSE);
  1812. ::EnableWindow(hWndCurr,FALSE);
  1813. hWndCurr = ::GetNextWindow(hWndCurr, GW_HWNDNEXT);
  1814. }
  1815. }
  1816. }
  1817. void CDNSZone_SOA_PropertyPage::ShowErrorUI()
  1818. {
  1819. _DisableDialogControls(m_hWnd);
  1820. CStatic* pErrorStatic = GetErrorStatic();
  1821. // need to move the error control to the center
  1822. CRect r;
  1823. pErrorStatic->GetWindowRect(&r);
  1824. ScreenToClient(r);
  1825. int dx = r.right - r.left;
  1826. int dy = r.bottom - r.top;
  1827. CRect rThis;
  1828. GetClientRect(rThis);
  1829. int x = ((rThis.right - rThis.left) - dx)/2;
  1830. int y = 4*dy;
  1831. r.top = y;
  1832. r.bottom = y + dy;
  1833. r.left = x;
  1834. r.right = x + dx;
  1835. pErrorStatic->MoveWindow(r, TRUE);
  1836. pErrorStatic->EnableWindow(TRUE);
  1837. pErrorStatic->ShowWindow(TRUE);
  1838. }
  1839. BOOL CDNSZone_SOA_PropertyPage::OnInitDialog()
  1840. {
  1841. CPropertyPageBase::OnInitDialog();
  1842. ASSERT(m_pTempSOARecord == NULL);
  1843. // create temporary record
  1844. if (m_bZoneRoot)
  1845. {
  1846. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1847. CDNSZoneNode* pZoneNode = pHolder->GetZoneNode();
  1848. if (pZoneNode->HasSOARecord())
  1849. {
  1850. m_pTempSOARecord = pZoneNode->GetSOARecordCopy();
  1851. }
  1852. else
  1853. {
  1854. // something is wrong, need to disable
  1855. ShowErrorUI();
  1856. }
  1857. }
  1858. else
  1859. {
  1860. // we are in the cache here...
  1861. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  1862. m_pTempSOARecord = (CDNS_SOA_Record*)pHolder->GetTempDNSRecord();
  1863. }
  1864. // initialize controls
  1865. m_serialNumberEditGroup.m_pPage = this;
  1866. VERIFY(m_serialNumberEditGroup.Initialize(this,
  1867. IDC_SERIAL_NUMBER_EDIT,IDC_SERIAL_UP, IDC_SERIAL_DOWN));
  1868. m_serialNumberEditGroup.SetRange(0,(UINT)-1);
  1869. m_refreshIntervalEditGroup.m_pPage = this;
  1870. m_retryIntervalEditGroup.m_pPage = this;
  1871. m_expireIntervalEditGroup.m_pPage = this;
  1872. m_minTTLIntervalEditGroup.m_pPage = this;
  1873. VERIFY(m_refreshIntervalEditGroup.Initialize(this,
  1874. IDC_REFR_INT_EDIT, IDC_REFR_INT_COMBO,IDS_TIME_INTERVAL_UNITS));
  1875. VERIFY(m_retryIntervalEditGroup.Initialize(this,
  1876. IDC_RETRY_INT_EDIT, IDC_RETRY_INT_COMBO,IDS_TIME_INTERVAL_UNITS));
  1877. VERIFY(m_expireIntervalEditGroup.Initialize(this,
  1878. IDC_EXP_INT_EDIT, IDC_EXP_INT_COMBO,IDS_TIME_INTERVAL_UNITS));
  1879. VERIFY(m_minTTLIntervalEditGroup.Initialize(this,
  1880. IDC_MINTTL_INT_EDIT, IDC_MINTTL_INT_COMBO, IDS_TIME_INTERVAL_UNITS));
  1881. HWND dialogHwnd = GetSafeHwnd();
  1882. // Disable IME support on the controls
  1883. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_REFR_INT_EDIT), NULL);
  1884. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_RETRY_INT_EDIT), NULL);
  1885. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_EXP_INT_EDIT), NULL);
  1886. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_MINTTL_INT_EDIT), NULL);
  1887. ImmAssociateContext(::GetDlgItem(dialogHwnd, IDC_SERIAL_NUMBER_EDIT), NULL);
  1888. // load data
  1889. SetUIData();
  1890. if (!m_bZoneRoot)
  1891. {
  1892. // we are in the cache here...
  1893. EnableDialogControls(m_hWnd, FALSE);
  1894. }
  1895. SetDirty(FALSE);
  1896. return TRUE;
  1897. }
  1898. BOOL CDNSZone_SOA_PropertyPage::OnApply()
  1899. {
  1900. if (!IsDirty())
  1901. {
  1902. return TRUE;
  1903. }
  1904. DNS_STATUS err = 0;
  1905. if (m_bZoneRoot)
  1906. {
  1907. //
  1908. // we are in a real zone
  1909. //
  1910. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1911. ASSERT(!pHolder->IsWizardMode());
  1912. //
  1913. // first commit possible zone type transition changes
  1914. //
  1915. if (!pHolder->ApplyGeneralPageChanges())
  1916. {
  1917. return FALSE;
  1918. }
  1919. if ((m_pTempSOARecord == NULL) || !IsDirty() || !pHolder->IsPrimaryZoneUI())
  1920. {
  1921. return TRUE;
  1922. }
  1923. //
  1924. // No need to verify success here because we don't return anything that isn't valid
  1925. //
  1926. err = GetUIDataEx(FALSE);
  1927. if (err != 0)
  1928. {
  1929. return FALSE;
  1930. }
  1931. err = pHolder->NotifyConsole(this);
  1932. }
  1933. else
  1934. {
  1935. //
  1936. // we are in the cache, that is read only...
  1937. //
  1938. return TRUE;
  1939. }
  1940. if (err != 0)
  1941. {
  1942. DNSErrorDialog(err,IDS_MSG_ZONE_SOA_UPDATE_FAILED);
  1943. return FALSE;
  1944. }
  1945. else
  1946. {
  1947. SetUIData();
  1948. SetDirty(FALSE);
  1949. }
  1950. return TRUE; // all is cool
  1951. }
  1952. BOOL CDNSZone_SOA_PropertyPage::OnPropertyChange(BOOL, long*)
  1953. {
  1954. ASSERT(m_pTempSOARecord != NULL);
  1955. if (m_pTempSOARecord == NULL)
  1956. return FALSE;
  1957. DNS_STATUS err = 0;
  1958. if (m_bZoneRoot)
  1959. {
  1960. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1961. err = pHolder->GetZoneNode()->UpdateSOARecord(m_pTempSOARecord, NULL);
  1962. }
  1963. else
  1964. {
  1965. ASSERT(FALSE);
  1966. }
  1967. if (err != 0)
  1968. GetHolder()->SetError(err);
  1969. return (err == 0);
  1970. }
  1971. void CDNSZone_SOA_PropertyPage::SetUIData()
  1972. {
  1973. CDNS_SOA_Record* pRecord = m_pTempSOARecord;
  1974. if (pRecord == NULL)
  1975. return;
  1976. GetPrimaryServerEdit()->SetWindowText(pRecord->m_szNamePrimaryServer);
  1977. GetResponsiblePartyEdit()->SetWindowText(pRecord->m_szResponsibleParty);
  1978. m_serialNumberEditGroup.SetVal(pRecord->m_dwSerialNo);
  1979. m_refreshIntervalEditGroup.SetVal(pRecord->m_dwRefresh);
  1980. m_retryIntervalEditGroup.SetVal(pRecord->m_dwRetry);
  1981. m_expireIntervalEditGroup.SetVal(pRecord->m_dwExpire);
  1982. m_minTTLIntervalEditGroup.SetVal(pRecord->m_dwMinimumTtl);
  1983. GetTTLCtrl()->SetTTL(pRecord->m_dwTtlSeconds);
  1984. if (m_bZoneRoot)
  1985. {
  1986. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  1987. EnableDialogControls(m_hWnd, pHolder->IsPrimaryZoneUI());
  1988. }
  1989. }
  1990. DNS_STATUS CDNSZone_SOA_PropertyPage::GetUIDataEx(BOOL)
  1991. {
  1992. DNS_STATUS err = 0;
  1993. CDNS_SOA_Record* pRecord = m_pTempSOARecord;
  1994. if (pRecord == NULL)
  1995. return err;
  1996. GetPrimaryServerEdit()->GetWindowText(pRecord->m_szNamePrimaryServer);
  1997. GetResponsiblePartyEdit()->GetWindowText(pRecord->m_szResponsibleParty);
  1998. //
  1999. // Check to see if the Responsible Party field contains an '@'
  2000. //
  2001. if (-1 != pRecord->m_szResponsibleParty.Find(L'@'))
  2002. {
  2003. UINT nResult = DNSMessageBox(IDS_MSG_RESPONSIBLE_PARTY_CONTAINS_AT, MB_YESNOCANCEL | MB_ICONWARNING);
  2004. if (IDYES == nResult)
  2005. {
  2006. //
  2007. // Replace '@' with '.'
  2008. //
  2009. pRecord->m_szResponsibleParty.Replace(L'@', L'.');
  2010. }
  2011. else if (IDCANCEL == nResult)
  2012. {
  2013. //
  2014. // Don't make any changes but don't let the apply continue
  2015. //
  2016. err = DNS_ERROR_INVALID_NAME_CHAR;
  2017. }
  2018. else
  2019. {
  2020. //
  2021. // We will allow IDNO to continue to set the responsible party with the '@'
  2022. //
  2023. err = 0;
  2024. }
  2025. }
  2026. pRecord->m_dwSerialNo = m_serialNumberEditGroup.GetVal();
  2027. pRecord->m_dwRefresh = m_refreshIntervalEditGroup.GetVal();
  2028. pRecord->m_dwRetry = m_retryIntervalEditGroup.GetVal();
  2029. pRecord->m_dwExpire = m_expireIntervalEditGroup.GetVal();
  2030. pRecord->m_dwMinimumTtl = m_minTTLIntervalEditGroup.GetVal();
  2031. GetTTLCtrl()->GetTTL(&(pRecord->m_dwTtlSeconds));
  2032. return err;
  2033. }
  2034. void CDNSZone_SOA_PropertyPage::OnPrimaryServerChange()
  2035. {
  2036. SetDirty(TRUE);
  2037. }
  2038. void CDNSZone_SOA_PropertyPage::OnResponsiblePartyChange()
  2039. {
  2040. SetDirty(TRUE);
  2041. }
  2042. void CDNSZone_SOA_PropertyPage::OnMinTTLChange()
  2043. {
  2044. SetDirty(TRUE);
  2045. }
  2046. void CDNSZone_SOA_PropertyPage::OnBrowseServer()
  2047. {
  2048. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2049. FIX_THREAD_STATE_MFC_BUG();
  2050. CThemeContextActivator activator;
  2051. CDNSBrowserDlg dlg(GetHolder()->GetComponentData(), GetHolder(), RECORD_A_AND_CNAME);
  2052. if (IDOK == dlg.DoModal())
  2053. {
  2054. CEdit* pEdit = GetPrimaryServerEdit();
  2055. pEdit->SetWindowText(dlg.GetSelectionString());
  2056. }
  2057. }
  2058. void CDNSZone_SOA_PropertyPage::OnBrowseResponsibleParty()
  2059. {
  2060. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2061. FIX_THREAD_STATE_MFC_BUG();
  2062. CThemeContextActivator activator;
  2063. CDNSBrowserDlg dlg(GetHolder()->GetComponentData(), GetHolder(), RECORD_RP);
  2064. if (IDOK == dlg.DoModal())
  2065. {
  2066. CEdit* pEdit = GetResponsiblePartyEdit();
  2067. pEdit->SetWindowText(dlg.GetSelectionString());
  2068. }
  2069. }
  2070. ////////////////////////////////////////////////////////////////////////////
  2071. // CWinsAdvancedDialog
  2072. class CWinsAdvancedDialog : public CHelpDialog
  2073. {
  2074. public:
  2075. CWinsAdvancedDialog(CPropertyPageHolderBase* pHolder, BOOL bReverse);
  2076. // data
  2077. BOOL m_bNetBios;
  2078. DWORD m_dwLookupTimeout;
  2079. DWORD m_dwCacheTimeout;
  2080. protected:
  2081. virtual BOOL OnInitDialog();
  2082. virtual void OnOK();
  2083. virtual void OnCancel();
  2084. DECLARE_MESSAGE_MAP()
  2085. private:
  2086. CPropertyPageHolderBase* m_pHolder;
  2087. BOOL m_bReverse;
  2088. CButton* GetNetBiosCheck()
  2089. { return (CButton*)GetDlgItem(IDC_NETBIOS_CHECK);}
  2090. CDNSTTLControl* GetCacheTimeoutTTLCtrl()
  2091. { return (CDNSTTLControl*)GetDlgItem(IDC_CACHE_TIMEOUT_TTLEDIT);}
  2092. CDNSTTLControl* GetLookupTimeoutTTLCtrl()
  2093. { return (CDNSTTLControl*)GetDlgItem(IDC_LOOKUP_TIMEOUT_TTLEDIT);}
  2094. };
  2095. BEGIN_MESSAGE_MAP(CWinsAdvancedDialog, CHelpDialog)
  2096. END_MESSAGE_MAP()
  2097. CWinsAdvancedDialog::CWinsAdvancedDialog(CPropertyPageHolderBase* pHolder,
  2098. BOOL bReverse)
  2099. : CHelpDialog(IDD_ZONE_WINS_ADVANCED, pHolder->GetComponentData())
  2100. {
  2101. ASSERT(pHolder != NULL);
  2102. m_pHolder = pHolder;
  2103. m_bReverse = bReverse;
  2104. m_bNetBios = FALSE;
  2105. m_dwLookupTimeout = 0x0;
  2106. m_dwCacheTimeout = 0x0;
  2107. }
  2108. BOOL CWinsAdvancedDialog::OnInitDialog()
  2109. {
  2110. CHelpDialog::OnInitDialog();
  2111. m_pHolder->PushDialogHWnd(GetSafeHwnd());
  2112. if (m_bReverse)
  2113. {
  2114. GetNetBiosCheck()->SetCheck(m_bNetBios);
  2115. }
  2116. else
  2117. {
  2118. GetNetBiosCheck()->EnableWindow(FALSE);
  2119. GetNetBiosCheck()->ShowWindow(FALSE);
  2120. }
  2121. GetCacheTimeoutTTLCtrl()->SetTTL(m_dwCacheTimeout);
  2122. GetLookupTimeoutTTLCtrl()->SetTTL(m_dwLookupTimeout);
  2123. return TRUE; // return TRUE unless you set the focus to a control
  2124. }
  2125. void CWinsAdvancedDialog::OnCancel()
  2126. {
  2127. ASSERT(m_pHolder != NULL);
  2128. m_pHolder->PopDialogHWnd();
  2129. CHelpDialog::OnCancel();
  2130. }
  2131. void CWinsAdvancedDialog::OnOK()
  2132. {
  2133. if (m_bReverse)
  2134. {
  2135. m_bNetBios = GetNetBiosCheck()->GetCheck();
  2136. }
  2137. GetCacheTimeoutTTLCtrl()->GetTTL(&m_dwCacheTimeout);
  2138. GetLookupTimeoutTTLCtrl()->GetTTL(&m_dwLookupTimeout);
  2139. ASSERT(m_pHolder != NULL);
  2140. m_pHolder->PopDialogHWnd();
  2141. CHelpDialog::OnOK();
  2142. }
  2143. ////////////////////////////////////////////////////////////////////////////
  2144. // CDNSZone_WINSBase_PropertyPage
  2145. BEGIN_MESSAGE_MAP(CDNSZone_WINSBase_PropertyPage, CDNSRecordPropertyPage)
  2146. ON_BN_CLICKED(IDC_USE_WINS_RES_CHECK, OnUseWinsResolutionChange)
  2147. ON_BN_CLICKED(IDC_NOT_REPL_CHECK, OnDoNotReplicateChange)
  2148. END_MESSAGE_MAP()
  2149. CDNSZone_WINSBase_PropertyPage::CDNSZone_WINSBase_PropertyPage(UINT nIDTemplate)
  2150. : CDNSRecordPropertyPage(nIDTemplate)
  2151. {
  2152. m_pTempRecord = NULL;
  2153. m_action = none;
  2154. m_iWINSMsg = 0;
  2155. }
  2156. CDNSZone_WINSBase_PropertyPage::~CDNSZone_WINSBase_PropertyPage()
  2157. {
  2158. if (m_pTempRecord != NULL)
  2159. delete m_pTempRecord;
  2160. }
  2161. BOOL CDNSZone_WINSBase_PropertyPage::OnPropertyChange(BOOL, long*)
  2162. {
  2163. ASSERT(m_action != none);
  2164. ASSERT(m_pTempRecord != NULL);
  2165. if (m_pTempRecord == NULL)
  2166. return FALSE;
  2167. CComponentDataObject* pComponentData = GetZoneHolder()->GetComponentData();
  2168. DNS_STATUS err = 0;
  2169. if (IsValidTempRecord())
  2170. {
  2171. switch(m_action)
  2172. {
  2173. case remove:
  2174. err = GetZoneNode()->DeleteWINSRecord(pComponentData);
  2175. break;
  2176. case add:
  2177. err = GetZoneNode()->CreateWINSRecord(m_pTempRecord, pComponentData);
  2178. break;
  2179. case edit:
  2180. err = GetZoneNode()->UpdateWINSRecord(m_pTempRecord, pComponentData);
  2181. break;
  2182. }
  2183. }
  2184. else
  2185. {
  2186. if (m_action == remove)
  2187. {
  2188. err = GetZoneNode()->DeleteWINSRecord(pComponentData);
  2189. }
  2190. else
  2191. {
  2192. err = ERROR_INVALID_DATA;
  2193. }
  2194. }
  2195. if (err != 0)
  2196. GetZoneHolder()->SetError(err);
  2197. return (err == 0);
  2198. }
  2199. CDNSZoneNode* CDNSZone_WINSBase_PropertyPage::GetZoneNode()
  2200. {
  2201. return GetZoneHolder()->GetZoneNode();
  2202. }
  2203. BOOL CDNSZone_WINSBase_PropertyPage::OnInitDialog()
  2204. {
  2205. CPropertyPageBase::OnInitDialog();
  2206. CDNSRootData* pRootData = (CDNSRootData*)GetHolder()->GetComponentData()->GetRootData();
  2207. ASSERT(pRootData != NULL);
  2208. EnableTTLCtrl(pRootData->IsAdvancedView());
  2209. BOOL bUseWins = GetZoneNode()->HasWinsRecord();
  2210. // unabe disable the WINS checkbox
  2211. GetUseWinsCheck()->SetCheck(bUseWins);
  2212. // get new temporary record
  2213. if (bUseWins)
  2214. m_pTempRecord = GetZoneNode()->GetWINSRecordCopy();
  2215. else
  2216. m_pTempRecord = GetZoneNode()->IsReverse() ?
  2217. (CDNSRecord*)(new CDNS_NBSTAT_Record) : (CDNSRecord*)(new CDNS_WINS_Record);
  2218. ASSERT(m_pTempRecord != NULL);
  2219. SetUIData();
  2220. SetDirty(FALSE);
  2221. // EnableUI(bUseWins);
  2222. return TRUE;
  2223. }
  2224. BOOL CDNSZone_WINSBase_PropertyPage::OnSetActive()
  2225. {
  2226. BOOL bRet = CDNSRecordPropertyPage::OnSetActive();
  2227. if (bRet)
  2228. {
  2229. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  2230. m_bPrimaryZone = pHolder->IsPrimaryZoneUI();
  2231. m_bStub = pHolder->IsStubZoneUI();
  2232. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2233. if (pRecord)
  2234. {
  2235. m_bLocalRecord = (pRecord->m_dwMappingFlag & DNS_WINS_FLAG_LOCAL);
  2236. }
  2237. BOOL bUseWins = GetZoneNode()->HasWinsRecord();
  2238. if (bUseWins && m_bLocalRecord)
  2239. {
  2240. m_nState = wins_local_state;
  2241. }
  2242. else if (bUseWins && !m_bLocalRecord)
  2243. {
  2244. m_nState = wins_not_local_state;
  2245. }
  2246. else // (!bUseWins && !m_bLocalRecord) || (!bUseWins && m_bLocalRecord)
  2247. {
  2248. m_nState = no_wins_state;
  2249. }
  2250. EnableUI();
  2251. CString szCheckText;
  2252. if (m_bPrimaryZone)
  2253. {
  2254. m_nReplCheckTextID = IDS_CHECK_TEXT_NOT_REPLICATE;
  2255. }
  2256. szCheckText.LoadString(m_nReplCheckTextID);
  2257. GetDoNotReplicateCheck()->SetWindowText((LPWSTR)(LPCWSTR)szCheckText);
  2258. }
  2259. return bRet;
  2260. }
  2261. BOOL CDNSZone_WINSBase_PropertyPage::OnApply()
  2262. {
  2263. CDNSZonePropertyPageHolder* pHolder =
  2264. (CDNSZonePropertyPageHolder*)GetHolder();
  2265. // first commit possible zone type transition changes
  2266. if (!pHolder->ApplyGeneralPageChanges())
  2267. return FALSE;
  2268. BOOL bUseWins = GetZoneNode()->HasWinsRecord(); // current state in the zone
  2269. BOOL bNewUseWins = GetUseWinsCheck()->GetCheck(); // current state in the UI
  2270. if (bUseWins && !bNewUseWins)
  2271. {
  2272. m_action = remove;
  2273. }
  2274. else if (!bUseWins && bNewUseWins)
  2275. {
  2276. m_action = add;
  2277. }
  2278. else if (bUseWins && bNewUseWins && IsDirty())
  2279. {
  2280. m_action = edit;
  2281. }
  2282. if (m_action == none)
  2283. return TRUE;
  2284. // No need to verify the return value here because we don't return anything except success
  2285. DNS_STATUS err = GetUIDataEx(FALSE);
  2286. if (err != 0)
  2287. {
  2288. ASSERT(FALSE);
  2289. return (err == 0);
  2290. }
  2291. err = GetZoneHolder()->NotifyConsole(this);
  2292. if (err != 0)
  2293. {
  2294. DNSErrorDialog(err, m_iWINSMsg);
  2295. }
  2296. else
  2297. {
  2298. // reset dirty flag!!!
  2299. }
  2300. m_action = none;
  2301. return (err == 0);
  2302. }
  2303. void CDNSZone_WINSBase_PropertyPage::OnUseWinsResolutionChange()
  2304. {
  2305. SetDirty(TRUE);
  2306. if (m_bPrimaryZone)
  2307. {
  2308. EnableUI(GetUseWinsCheck()->GetCheck());
  2309. }
  2310. else
  2311. {
  2312. switch (m_nState)
  2313. {
  2314. case wins_local_state :
  2315. #ifdef DBG
  2316. ASSERT(!GetUseWinsCheck()->GetCheck());
  2317. ASSERT(GetUseWinsCheck()->IsWindowEnabled());
  2318. ASSERT(GetDoNotReplicateCheck()->GetCheck());
  2319. ASSERT(!GetDoNotReplicateCheck()->IsWindowEnabled());
  2320. #endif
  2321. m_nState = no_wins_state;
  2322. break;
  2323. case wins_not_local_state : // should never happen
  2324. #ifdef DBG
  2325. ASSERT(FALSE);
  2326. #endif
  2327. break;
  2328. case no_wins_state :
  2329. #ifdef DBG
  2330. ASSERT(GetUseWinsCheck()->GetCheck());
  2331. ASSERT(GetUseWinsCheck()->IsWindowEnabled());
  2332. ASSERT(GetDoNotReplicateCheck()->GetCheck());
  2333. ASSERT(!GetDoNotReplicateCheck()->IsWindowEnabled());
  2334. #endif
  2335. m_nState = wins_local_state;
  2336. break;
  2337. default : // illegal state
  2338. #ifdef DBG
  2339. ASSERT(FALSE);
  2340. #endif
  2341. break;
  2342. }
  2343. EnableUI();
  2344. }
  2345. }
  2346. void CDNSZone_WINSBase_PropertyPage::OnDoNotReplicateChange()
  2347. {
  2348. SetDirty(TRUE);
  2349. if (!m_bPrimaryZone)
  2350. {
  2351. switch (m_nState)
  2352. {
  2353. case wins_local_state : // should never happen
  2354. #ifdef DBG
  2355. ASSERT(FALSE);
  2356. #endif
  2357. break;
  2358. case wins_not_local_state :
  2359. #ifdef DBG
  2360. ASSERT(GetUseWinsCheck()->GetCheck());
  2361. ASSERT(!GetUseWinsCheck()->IsWindowEnabled());
  2362. ASSERT(GetDoNotReplicateCheck()->GetCheck());
  2363. ASSERT(GetDoNotReplicateCheck()->IsWindowEnabled());
  2364. #endif
  2365. m_nState = wins_local_state;
  2366. break;
  2367. case no_wins_state : // should never happen
  2368. #ifdef DBG
  2369. ASSERT(FALSE);
  2370. #endif
  2371. break;
  2372. default : // illegal state
  2373. #ifdef DBG
  2374. ASSERT(FALSE);
  2375. #endif
  2376. break;
  2377. }
  2378. EnableUI();
  2379. }
  2380. }
  2381. void CDNSZone_WINSBase_PropertyPage::EnableUI(BOOL bEnable)
  2382. {
  2383. GetDoNotReplicateCheck()->EnableWindow(bEnable);
  2384. GetAdvancedButton()->EnableWindow(bEnable);
  2385. GetTTLCtrl()->EnableWindow(bEnable);
  2386. }
  2387. void CDNSZone_WINSBase_PropertyPage::EnableUI()
  2388. {
  2389. if (m_bPrimaryZone)
  2390. {
  2391. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(TRUE);
  2392. if (!IsDirty())
  2393. {
  2394. EnableUI(GetZoneNode()->HasWinsRecord());
  2395. }
  2396. }
  2397. else if (m_bStub)
  2398. {
  2399. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(FALSE);
  2400. EnableUI(FALSE);
  2401. }
  2402. else //secondary
  2403. {
  2404. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(TRUE);
  2405. switch (m_nState)
  2406. {
  2407. case wins_local_state :
  2408. GetDoNotReplicateCheck()->SetCheck(TRUE);
  2409. GetDoNotReplicateCheck()->EnableWindow(FALSE);
  2410. GetUseWinsCheck()->SetCheck(TRUE);
  2411. GetUseWinsCheck()->EnableWindow(TRUE);
  2412. GetTTLCtrl()->EnableWindow(TRUE);
  2413. GetAdvancedButton()->EnableWindow(TRUE);
  2414. break;
  2415. case wins_not_local_state :
  2416. GetDoNotReplicateCheck()->SetCheck(FALSE);
  2417. GetDoNotReplicateCheck()->EnableWindow(TRUE);
  2418. GetUseWinsCheck()->SetCheck(TRUE);
  2419. GetUseWinsCheck()->EnableWindow(FALSE);
  2420. GetTTLCtrl()->EnableWindow(FALSE);
  2421. GetAdvancedButton()->EnableWindow(FALSE);
  2422. break;
  2423. case no_wins_state :
  2424. GetDoNotReplicateCheck()->SetCheck(TRUE);
  2425. GetDoNotReplicateCheck()->EnableWindow(FALSE);
  2426. GetUseWinsCheck()->SetCheck(FALSE);
  2427. GetUseWinsCheck()->EnableWindow(TRUE);
  2428. GetTTLCtrl()->EnableWindow(FALSE);
  2429. GetAdvancedButton()->EnableWindow(FALSE);
  2430. break;
  2431. default : // Illegal state
  2432. break;
  2433. }
  2434. }
  2435. }
  2436. void CDNSZone_WINSBase_PropertyPage::SetUIData()
  2437. {
  2438. GetTTLCtrl()->SetTTL(m_pTempRecord->m_dwTtlSeconds);
  2439. }
  2440. DNS_STATUS CDNSZone_WINSBase_PropertyPage::GetUIDataEx(BOOL)
  2441. {
  2442. GetTTLCtrl()->GetTTL(&(m_pTempRecord->m_dwTtlSeconds));
  2443. return 0;
  2444. }
  2445. ////////////////////////////////////////////////////////////////////////////
  2446. // CDNSZone_WINS_PropertyPage
  2447. void CDNSZone_WINS_WinsServersIPEditor::OnChangeData()
  2448. {
  2449. CDNSZone_WINS_PropertyPage* pPage =
  2450. (CDNSZone_WINS_PropertyPage*)GetParentWnd();
  2451. pPage->SetDirty(TRUE);
  2452. }
  2453. BEGIN_MESSAGE_MAP(CDNSZone_WINS_PropertyPage, CDNSZone_WINSBase_PropertyPage)
  2454. ON_BN_CLICKED(IDC_ADVANCED_BUTTON, OnAdvancedButton)
  2455. END_MESSAGE_MAP()
  2456. CDNSZone_WINS_PropertyPage::CDNSZone_WINS_PropertyPage()
  2457. : CDNSZone_WINSBase_PropertyPage(IDD_ZONE_WINS_PAGE)
  2458. {
  2459. m_iWINSMsg = IDS_MSG_ZONE_WINS_FAILED;
  2460. m_nReplCheckTextID = IDS_CHECK_TEXT_USE_LOCAL_WINS;
  2461. m_bStub = FALSE;
  2462. }
  2463. BOOL CDNSZone_WINS_PropertyPage::OnInitDialog()
  2464. {
  2465. //
  2466. // NOTE: this control has to be initialized before the
  2467. // base class OnInitDialog is called because the
  2468. // base class OnInitDialog calls SetUIData() in
  2469. // this derived class which uses this control
  2470. //
  2471. VERIFY(m_winsServersEditor.Initialize(this,
  2472. GetParent(),
  2473. IDC_BUTTON_UP,
  2474. IDC_BUTTON_DOWN,
  2475. IDC_BUTTON_ADD,
  2476. IDC_BUTTON_REMOVE,
  2477. IDC_IPEDIT,
  2478. IDC_LIST));
  2479. CDNSZone_WINSBase_PropertyPage::OnInitDialog();
  2480. return TRUE;
  2481. }
  2482. void CDNSZone_WINS_PropertyPage::EnableUI(BOOL bEnable)
  2483. {
  2484. CDNSZone_WINSBase_PropertyPage::EnableUI(bEnable);
  2485. m_winsServersEditor.EnableUI(bEnable);
  2486. GetDlgItem(IDC_IP_STATIC)->EnableWindow(bEnable);
  2487. }
  2488. void CDNSZone_WINS_PropertyPage::EnableUI()
  2489. {
  2490. CDNSZone_WINSBase_PropertyPage::EnableUI();
  2491. if (m_bPrimaryZone)
  2492. {
  2493. if (!IsDirty())
  2494. {
  2495. m_winsServersEditor.EnableUI(GetZoneNode()->HasWinsRecord());
  2496. GetDlgItem(IDC_IP_STATIC)->EnableWindow(GetZoneNode()->HasWinsRecord());
  2497. }
  2498. }
  2499. else // secondary zone
  2500. {
  2501. switch (m_nState)
  2502. {
  2503. case wins_local_state :
  2504. m_winsServersEditor.EnableUI(TRUE);
  2505. GetDlgItem(IDC_IP_STATIC)->EnableWindow(FALSE);
  2506. break;
  2507. case wins_not_local_state :
  2508. case no_wins_state :
  2509. m_winsServersEditor.EnableUI(FALSE);
  2510. GetDlgItem(IDC_IP_STATIC)->EnableWindow(FALSE);
  2511. break;
  2512. default : // Illegal state
  2513. break;
  2514. }
  2515. }
  2516. }
  2517. BOOL CDNSZone_WINS_PropertyPage::IsValidTempRecord()
  2518. {
  2519. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2520. return (pRecord->m_nWinsServerCount > 0);
  2521. }
  2522. void CDNSZone_WINS_PropertyPage::SetUIData()
  2523. {
  2524. CDNSZone_WINSBase_PropertyPage::SetUIData();
  2525. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2526. GetDoNotReplicateCheck()->SetCheck(pRecord->m_dwMappingFlag & DNS_WINS_FLAG_LOCAL);
  2527. m_winsServersEditor.Clear();
  2528. if (pRecord->m_nWinsServerCount > 0)
  2529. {
  2530. DWORD* pTemp = (DWORD*)malloc(sizeof(DWORD)*pRecord->m_nWinsServerCount);
  2531. if (pTemp)
  2532. {
  2533. for (int k=0; k< pRecord->m_nWinsServerCount; k++)
  2534. {
  2535. pTemp[k] = pRecord->m_ipWinsServersArray[k];
  2536. }
  2537. m_winsServersEditor.AddAddresses(pTemp, pRecord->m_nWinsServerCount);
  2538. free(pTemp);
  2539. pTemp = 0;
  2540. }
  2541. }
  2542. }
  2543. DNS_STATUS CDNSZone_WINS_PropertyPage::GetUIDataEx(BOOL bSilent)
  2544. {
  2545. DNS_STATUS err = CDNSZone_WINSBase_PropertyPage::GetUIDataEx(bSilent);
  2546. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2547. pRecord->m_dwMappingFlag = GetDoNotReplicateCheck()->GetCheck() ?
  2548. pRecord->m_dwMappingFlag |= DNS_WINS_FLAG_LOCAL :
  2549. pRecord->m_dwMappingFlag &= ~DNS_WINS_FLAG_LOCAL;
  2550. pRecord->m_nWinsServerCount = m_winsServersEditor.GetCount();
  2551. if (pRecord->m_nWinsServerCount > 0)
  2552. {
  2553. DWORD* pTemp = (DWORD*)malloc(sizeof(DWORD)*pRecord->m_nWinsServerCount);
  2554. if (pTemp)
  2555. {
  2556. int nFilled;
  2557. m_winsServersEditor.GetAddresses(pTemp, pRecord->m_nWinsServerCount, &nFilled);
  2558. ASSERT(nFilled == pRecord->m_nWinsServerCount);
  2559. for (int k=0; k<nFilled; k++)
  2560. pRecord->m_ipWinsServersArray.SetAtGrow(k, pTemp[k]);
  2561. free(pTemp);
  2562. pTemp = 0;
  2563. }
  2564. else
  2565. {
  2566. err = ERROR_OUTOFMEMORY;
  2567. }
  2568. }
  2569. return err;
  2570. }
  2571. void CDNSZone_WINS_PropertyPage::OnAdvancedButton()
  2572. {
  2573. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2574. FIX_THREAD_STATE_MFC_BUG();
  2575. CThemeContextActivator activator;
  2576. CDNS_WINS_Record* pRecord = (CDNS_WINS_Record*)m_pTempRecord;
  2577. CWinsAdvancedDialog dlg(GetHolder(), FALSE);
  2578. dlg.m_dwLookupTimeout = pRecord->m_dwLookupTimeout;
  2579. dlg.m_dwCacheTimeout = pRecord->m_dwCacheTimeout;
  2580. if (IDOK == dlg.DoModal() )
  2581. {
  2582. pRecord->m_dwLookupTimeout = dlg.m_dwLookupTimeout;
  2583. pRecord->m_dwCacheTimeout = dlg.m_dwCacheTimeout;
  2584. SetDirty(TRUE);
  2585. }
  2586. }
  2587. ////////////////////////////////////////////////////////////////////////////
  2588. // CDNSZone_NBSTAT_PropertyPage
  2589. BEGIN_MESSAGE_MAP(CDNSZone_NBSTAT_PropertyPage, CDNSZone_WINSBase_PropertyPage)
  2590. ON_EN_CHANGE(IDC_DOMAIN_NAME_EDIT, OnDomainNameEditChange)
  2591. ON_BN_CLICKED(IDC_ADVANCED_BUTTON, OnAdvancedButton)
  2592. END_MESSAGE_MAP()
  2593. CDNSZone_NBSTAT_PropertyPage::CDNSZone_NBSTAT_PropertyPage()
  2594. : CDNSZone_WINSBase_PropertyPage(IDD_ZONE_NBSTAT_PAGE)
  2595. {
  2596. m_iWINSMsg = IDS_MSG_ZONE_NBSTAT_FAILED;
  2597. m_nReplCheckTextID = IDS_CHECK_TEXT_USE_LOCAL_WINSR;
  2598. }
  2599. void CDNSZone_NBSTAT_PropertyPage::OnDomainNameEditChange()
  2600. {
  2601. SetDirty(TRUE);
  2602. }
  2603. void CDNSZone_NBSTAT_PropertyPage::EnableUI(BOOL bEnable)
  2604. {
  2605. CDNSZone_WINSBase_PropertyPage::EnableUI(bEnable);
  2606. GetDomainNameEdit()->EnableWindow(bEnable);
  2607. }
  2608. void CDNSZone_NBSTAT_PropertyPage::EnableUI()
  2609. {
  2610. CDNSZone_WINSBase_PropertyPage::EnableUI();
  2611. if (m_bPrimaryZone)
  2612. {
  2613. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(TRUE);
  2614. GetDomainNameEdit()->EnableWindow(GetZoneNode()->HasWinsRecord());
  2615. }
  2616. else if (m_bStub)
  2617. {
  2618. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(FALSE);
  2619. EnableUI(FALSE);
  2620. }
  2621. else // secondary zone
  2622. {
  2623. GetDlgItem(IDC_USE_WINS_RES_CHECK)->EnableWindow(TRUE);
  2624. switch (m_nState)
  2625. {
  2626. case wins_local_state :
  2627. GetDomainNameEdit()->EnableWindow(TRUE);
  2628. break;
  2629. case wins_not_local_state :
  2630. GetDomainNameEdit()->EnableWindow(FALSE);
  2631. break;
  2632. case no_wins_state :
  2633. GetDomainNameEdit()->EnableWindow(FALSE);
  2634. break;
  2635. default : // Illegal state
  2636. break;
  2637. }
  2638. }
  2639. }
  2640. BOOL CDNSZone_NBSTAT_PropertyPage::IsValidTempRecord()
  2641. {
  2642. CDNS_NBSTAT_Record* pRecord = (CDNS_NBSTAT_Record*)m_pTempRecord;
  2643. CString szTemp = pRecord->m_szNameResultDomain;
  2644. szTemp.TrimLeft();
  2645. szTemp.TrimRight();
  2646. return (!szTemp.IsEmpty());
  2647. }
  2648. void CDNSZone_NBSTAT_PropertyPage::SetUIData()
  2649. {
  2650. CDNSZone_WINSBase_PropertyPage::SetUIData();
  2651. CDNS_NBSTAT_Record* pRecord = (CDNS_NBSTAT_Record*)m_pTempRecord;
  2652. GetDoNotReplicateCheck()->SetCheck(pRecord->m_dwMappingFlag & DNS_WINS_FLAG_LOCAL);
  2653. // strip out the "in-addr.arpa" suffix
  2654. CString szTemp = pRecord->m_szNameResultDomain;
  2655. //VERIFY(RemoveInAddrArpaSuffix(szTemp.GetBuffer(1)));
  2656. //szTemp.ReleaseBuffer();
  2657. GetDomainNameEdit()->SetWindowText(szTemp);
  2658. }
  2659. DNS_STATUS CDNSZone_NBSTAT_PropertyPage::GetUIDataEx(BOOL bSilent)
  2660. {
  2661. DNS_STATUS err = CDNSZone_WINSBase_PropertyPage::GetUIDataEx(bSilent);
  2662. CDNS_NBSTAT_Record* pRecord = (CDNS_NBSTAT_Record*)m_pTempRecord;
  2663. pRecord->m_dwMappingFlag = GetDoNotReplicateCheck()->GetCheck() ?
  2664. pRecord->m_dwMappingFlag |= DNS_WINS_FLAG_LOCAL :
  2665. pRecord->m_dwMappingFlag &= ~DNS_WINS_FLAG_LOCAL;
  2666. GetDomainNameEdit()->GetWindowText(pRecord->m_szNameResultDomain);
  2667. return err;
  2668. }
  2669. void CDNSZone_NBSTAT_PropertyPage::OnAdvancedButton()
  2670. {
  2671. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  2672. FIX_THREAD_STATE_MFC_BUG();
  2673. CThemeContextActivator activator;
  2674. CDNS_NBSTAT_Record* pRecord = (CDNS_NBSTAT_Record*)m_pTempRecord;
  2675. CWinsAdvancedDialog dlg(GetHolder(), TRUE);
  2676. dlg.m_dwLookupTimeout = pRecord->m_dwLookupTimeout;
  2677. dlg.m_dwCacheTimeout = pRecord->m_dwCacheTimeout;
  2678. dlg.m_bNetBios = pRecord->m_dwMappingFlag & DNS_WINS_FLAG_SCOPE;
  2679. if (IDOK == dlg.DoModal())
  2680. {
  2681. pRecord->m_dwLookupTimeout = dlg.m_dwLookupTimeout;
  2682. pRecord->m_dwCacheTimeout = dlg.m_dwCacheTimeout;
  2683. pRecord->m_dwMappingFlag = dlg.m_bNetBios ?
  2684. pRecord->m_dwMappingFlag |= DNS_WINS_FLAG_SCOPE :
  2685. pRecord->m_dwMappingFlag &= ~DNS_WINS_FLAG_SCOPE;
  2686. SetDirty(TRUE);
  2687. }
  2688. }
  2689. ///////////////////////////////////////////////////////////////////////////////
  2690. // CDNSZoneNameServersPropertyPage
  2691. BOOL CDNSZoneNameServersPropertyPage::OnSetActive()
  2692. {
  2693. BOOL bRet = CDNSNameServersPropertyPage::OnSetActive();
  2694. if (bRet)
  2695. {
  2696. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  2697. BOOL bReadOnly = !pHolder->IsPrimaryZoneUI();
  2698. if (m_bReadOnly != bReadOnly)
  2699. {
  2700. m_bReadOnly = bReadOnly;
  2701. EnableButtons(!m_bReadOnly);
  2702. }
  2703. }
  2704. return bRet;
  2705. }
  2706. void CDNSZoneNameServersPropertyPage::ReadRecordNodesList()
  2707. {
  2708. ASSERT(m_pCloneInfoList != NULL);
  2709. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  2710. CDNSZoneNode* pDomainNode = pHolder->GetZoneNode();
  2711. SetDomainNode(pDomainNode);
  2712. pDomainNode->GetNSRecordNodesInfo(m_pCloneInfoList);
  2713. }
  2714. BOOL CDNSZoneNameServersPropertyPage::WriteNSRecordNodesList()
  2715. {
  2716. ASSERT(m_pCloneInfoList != NULL);
  2717. CDNSZonePropertyPageHolder* pHolder = (CDNSZonePropertyPageHolder*)GetHolder();
  2718. CDNSZoneNode* pDomainNode = pHolder->GetZoneNode();
  2719. return pDomainNode->UpdateNSRecordNodesInfo(m_pCloneInfoList, pHolder->GetComponentData());
  2720. }
  2721. ///////////////////////////////////////////////////////////////////////////////
  2722. // CDNSZonePropertyPageHolder
  2723. CDNSZonePropertyPageHolder::CDNSZonePropertyPageHolder(CCathegoryFolderNode* pFolderNode,
  2724. CDNSZoneNode* pZoneNode, CComponentDataObject* pComponentData)
  2725. : CPropertyPageHolderBase(pFolderNode, pZoneNode, pComponentData)
  2726. {
  2727. ASSERT(pComponentData != NULL);
  2728. ASSERT(pFolderNode != NULL);
  2729. ASSERT(pFolderNode == GetContainerNode());
  2730. ASSERT(pZoneNode != NULL);
  2731. ASSERT(pZoneNode == GetZoneNode());
  2732. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  2733. int nCurrPage = 0;
  2734. m_nGenPage = -1;
  2735. m_nSOAPage = -1;
  2736. m_nWINSorWINSRPage = -1;
  2737. m_nNSPage = -1;
  2738. // add pages
  2739. m_nGenPage = nCurrPage;
  2740. AddPageToList((CPropertyPageBase*)&m_generalPage);
  2741. nCurrPage++;
  2742. m_nSOAPage = nCurrPage;
  2743. AddPageToList((CPropertyPageBase*)&m_SOARecordPage);
  2744. nCurrPage++;
  2745. m_nNSPage = nCurrPage;
  2746. AddPageToList((CPropertyPageBase*)&m_nameServersPage);
  2747. nCurrPage++;
  2748. if (pZoneNode->IsReverse())
  2749. {
  2750. m_nWINSorWINSRPage = nCurrPage;
  2751. AddPageToList((CPropertyPageBase*)&m_NBSTATRecordPage);
  2752. nCurrPage++;
  2753. }
  2754. else
  2755. {
  2756. m_nWINSorWINSRPage = nCurrPage;
  2757. AddPageToList((CPropertyPageBase*)&m_WINSRecordPage);
  2758. nCurrPage++;
  2759. }
  2760. AddPageToList((CPropertyPageBase*)&m_zoneTransferPage);
  2761. // security page added only if needed
  2762. m_pAclEditorPage = NULL;
  2763. if (pZoneNode->IsDSIntegrated())
  2764. {
  2765. CString szPath;
  2766. pZoneNode->GetServerNode()->CreateDsZoneLdapPath(pZoneNode, szPath);
  2767. if (!szPath.IsEmpty())
  2768. m_pAclEditorPage = CAclEditorPage::CreateInstance(szPath, this);
  2769. }
  2770. // determine if we need/can have advanced view
  2771. CDNSRootData* pRootData = (CDNSRootData*)pComponentData->GetRootData();
  2772. ASSERT(pRootData != NULL);
  2773. m_bAdvancedView = pRootData->IsAdvancedView();
  2774. }
  2775. CDNSZonePropertyPageHolder::~CDNSZonePropertyPageHolder()
  2776. {
  2777. if (m_pAclEditorPage != NULL)
  2778. delete m_pAclEditorPage;
  2779. }
  2780. int CDNSZonePropertyPageHolder::OnSelectPageMessage(long nPageCode)
  2781. {
  2782. TRACE(_T("CDNSZonePropertyPageHolder::OnSelectPageMessage()\n"));
  2783. switch (nPageCode)
  2784. {
  2785. case ZONE_HOLDER_GEN:
  2786. return m_nGenPage;
  2787. case ZONE_HOLDER_SOA:
  2788. return m_nSOAPage;
  2789. case ZONE_HOLDER_NS:
  2790. return m_nNSPage;
  2791. case ZONE_HOLDER_WINS:
  2792. return m_nWINSorWINSRPage;
  2793. }
  2794. return -1;
  2795. }
  2796. HRESULT CDNSZonePropertyPageHolder::OnAddPage(int nPage, CPropertyPageBase*)
  2797. {
  2798. // add the ACL editor page after the last, if present
  2799. if ( (nPage != -1) || (m_pAclEditorPage == NULL) )
  2800. return S_OK;
  2801. // add the ACLU page
  2802. HPROPSHEETPAGE hPage = m_pAclEditorPage->CreatePage();
  2803. if (hPage == NULL)
  2804. return E_FAIL;
  2805. // add the raw HPROPSHEETPAGE to sheet, not in the list
  2806. return AddPageToSheetRaw(hPage);
  2807. }