Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2690 lines
75 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: zonewiz.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 "ZoneWiz.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. #define N_ZONEWIZ_TYPES 4
  30. #define N_ZONEWIZ_TYPES_PRIMARY 0
  31. #define N_ZONEWIZ_TYPES_DS_PRIMARY 1
  32. #define N_ZONEWIZ_TYPES_SECONDARY 2
  33. #define N_ZONEWIZ_TYPES_STUB 3
  34. ///////////////////////////////////////////////////////////////////////////////
  35. // CDNSCreateZoneInfo
  36. CDNSCreateZoneInfo::CDNSCreateZoneInfo()
  37. {
  38. m_bPrimary = TRUE;
  39. m_bForward = m_bWasForward = TRUE;
  40. m_bIsStub = FALSE;
  41. m_storageType = useADS;
  42. m_ipMastersArray = NULL;
  43. m_nMastersCount = 0;
  44. m_bLocalListOfMasters = FALSE;
  45. m_nDynamicUpdate = ZONE_UPDATE_OFF;
  46. #ifdef USE_NDNC
  47. m_replType = none;
  48. #endif
  49. }
  50. CDNSCreateZoneInfo::~CDNSCreateZoneInfo()
  51. {
  52. ResetIpArr();
  53. }
  54. void CDNSCreateZoneInfo::ResetIpArr()
  55. {
  56. if (m_ipMastersArray != NULL)
  57. {
  58. ASSERT(m_nMastersCount > 0);
  59. delete[] m_ipMastersArray;
  60. m_ipMastersArray = NULL;
  61. m_nMastersCount = 0;
  62. }
  63. }
  64. void CDNSCreateZoneInfo::SetIpArr(PIP_ADDRESS ipMastersArray, DWORD nMastersCount)
  65. {
  66. ResetIpArr();
  67. m_nMastersCount = nMastersCount;
  68. if (m_nMastersCount > 0)
  69. {
  70. ASSERT(ipMastersArray != NULL);
  71. m_ipMastersArray = new IP_ADDRESS[m_nMastersCount];
  72. memcpy(m_ipMastersArray, ipMastersArray, sizeof(IP_ADDRESS)*nMastersCount);
  73. }
  74. }
  75. const CDNSCreateZoneInfo& CDNSCreateZoneInfo::operator=(const CDNSCreateZoneInfo& info)
  76. {
  77. m_bPrimary = info.m_bPrimary;
  78. m_bForward = info.m_bForward;
  79. m_bIsStub = info.m_bIsStub;
  80. m_szZoneName = info.m_szZoneName;
  81. m_szZoneStorage = info.m_szZoneStorage;
  82. m_storageType = info.m_storageType;
  83. SetIpArr(info.m_ipMastersArray, info.m_nMastersCount);
  84. m_bLocalListOfMasters = info.m_bLocalListOfMasters;
  85. m_bWasForward = info.m_bWasForward;
  86. m_nDynamicUpdate = info.m_nDynamicUpdate;
  87. return *this;
  88. }
  89. ///////////////////////////////////////////////////////////////////////////////
  90. // CDNSZoneWizardHolder
  91. CDNSZoneWizardHolder::CDNSZoneWizardHolder(CComponentDataObject* pComponentData)
  92. : CPropertyPageHolderBase(NULL, NULL, pComponentData)
  93. {
  94. m_bAutoDelete = FALSE; // use on the stack or embedded
  95. m_forceContextHelpButton = forceOff;
  96. m_pZoneInfo = &m_zoneInfo;
  97. // default settings for zone creation
  98. m_bKnowZoneLookupType = FALSE;
  99. m_bKnowZoneLookupTypeEx = FALSE;
  100. m_bServerPage = FALSE;
  101. m_bFinishPage = TRUE;
  102. m_nNextToPage = 0;
  103. m_nBackToPage = 0;
  104. }
  105. void CDNSZoneWizardHolder::Initialize(CDNSServerNode* pServerNode, // might be null,
  106. BOOL bServerPage, BOOL bFinishPage)
  107. {
  108. m_bServerPage = bServerPage;
  109. m_bFinishPage = bFinishPage;
  110. if (pServerNode != NULL)
  111. SetServerNode(pServerNode);
  112. // page creation
  113. // add start page only if not embedded in other wizard
  114. if (pServerNode != NULL)
  115. {
  116. m_pStartPage = new CDNSZoneWiz_StartPropertyPage;
  117. ASSERT(m_pStartPage != NULL);
  118. AddPageToList((CPropertyPageBase*)m_pStartPage);
  119. }
  120. // if there is no server context and we are not embedded,
  121. // then add first page to pick the server
  122. if (pServerNode == NULL && m_bServerPage)
  123. {
  124. m_pTargetServerPage = new CDNSZoneWiz_SelectServerPropertyPage;
  125. ASSERT(m_pTargetServerPage != NULL);
  126. AddPageToList((CPropertyPageBase*)m_pTargetServerPage);
  127. }
  128. // add the page to select primary or secondary zone
  129. m_pReplicationTypePage = new CDNSZoneWiz_ZoneTypePropertyPage;
  130. ASSERT(m_pReplicationTypePage != NULL);
  131. AddPageToList((CPropertyPageBase*)m_pReplicationTypePage);
  132. // page for lookup type (fwd/rev) on primary only
  133. m_pZoneLookupPage = new CDNSZoneWiz_ZoneLookupPropertyPage;
  134. ASSERT(m_pZoneLookupPage != NULL);
  135. AddPageToList((CPropertyPageBase*)m_pZoneLookupPage);
  136. // pages for zone name on primary only
  137. m_pFwdZoneNamePage = new CDNSZoneWiz_FwdZoneNamePropertyPage;
  138. ASSERT(m_pFwdZoneNamePage != NULL);
  139. AddPageToList((CPropertyPageBase*)m_pFwdZoneNamePage);
  140. m_pRevZoneNamePage = new CDNSZoneWiz_RevZoneNamePropertyPage;
  141. ASSERT(m_pRevZoneNamePage != NULL);
  142. AddPageToList((CPropertyPageBase*)m_pRevZoneNamePage);
  143. // page for masters on secondary only
  144. m_pMastersPage = new CDNSZoneWiz_MastersPropertyPage;
  145. AddPageToList((CPropertyPageBase*)m_pMastersPage);
  146. ASSERT(m_pMastersPage != NULL);
  147. //
  148. // page for dynamic update on primary only
  149. //
  150. m_pDynamicPage = new CDNSZoneWiz_DynamicPropertyPage;
  151. AddPageToList((CPropertyPageBase*)m_pDynamicPage);
  152. ASSERT(m_pDynamicPage != NULL);
  153. // storage page, common
  154. m_pStoragePage = new CDNSZoneWiz_StoragePropertyPage;
  155. AddPageToList((CPropertyPageBase*)m_pStoragePage);
  156. ASSERT(m_pStoragePage != NULL);
  157. #ifdef USE_NDNC
  158. // AD replication page, only for Whistler servers
  159. m_pADReplPage = new CDNSZoneWiz_ADReplicationPropertyPage;
  160. AddPageToList((CPropertyPageBase*)m_pADReplPage);
  161. ASSERT(m_pADReplPage != NULL);
  162. #endif // USE_NDNC
  163. // finish page, common
  164. if (m_bFinishPage)
  165. {
  166. m_pFinishPage = new CDNSZoneWiz_FinishPropertyPage;
  167. AddPageToList((CPropertyPageBase*)m_pFinishPage);
  168. ASSERT(m_pFinishPage != NULL);
  169. }
  170. }
  171. void CDNSZoneWizardHolder::PreSetZoneLookupType(BOOL bForward)
  172. {
  173. m_bKnowZoneLookupType = TRUE;
  174. m_bKnowZoneLookupTypeEx = FALSE;
  175. m_pZoneInfo->m_bForward = bForward;
  176. }
  177. void CDNSZoneWizardHolder::PreSetZoneLookupTypeEx(BOOL bForward, UINT nZoneType, BOOL bADIntegrated)
  178. {
  179. m_bKnowZoneLookupTypeEx = TRUE;
  180. m_pZoneInfo->m_bForward = bForward;
  181. if (bADIntegrated)
  182. {
  183. m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::useADS;
  184. }
  185. else
  186. {
  187. m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::newFile;
  188. }
  189. if (nZoneType != (UINT)-1)
  190. {
  191. switch (nZoneType)
  192. {
  193. case DNS_ZONE_TYPE_PRIMARY:
  194. m_pZoneInfo->m_bPrimary = TRUE;
  195. m_pZoneInfo->m_bIsStub = FALSE;
  196. break;
  197. case DNS_ZONE_TYPE_SECONDARY:
  198. m_pZoneInfo->m_bPrimary = FALSE;
  199. m_pZoneInfo->m_bIsStub = FALSE;
  200. break;
  201. case DNS_ZONE_TYPE_STUB:
  202. m_pZoneInfo->m_bPrimary = FALSE;
  203. m_pZoneInfo->m_bIsStub = TRUE;
  204. break;
  205. default:
  206. ASSERT(FALSE);
  207. break;
  208. }
  209. }
  210. }
  211. void CDNSZoneWizardHolder::SetContextPages(UINT nNextToPage, UINT nBackToPage)
  212. {
  213. m_nNextToPage = nNextToPage;
  214. m_nBackToPage = nBackToPage;
  215. }
  216. UINT CDNSZoneWizardHolder::GetFirstEntryPointPageID()
  217. {
  218. if (m_bKnowZoneLookupTypeEx)
  219. {
  220. if (m_pZoneInfo->m_bForward)
  221. {
  222. return CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  223. }
  224. else
  225. {
  226. return CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  227. }
  228. }
  229. return CDNSZoneWiz_ZoneTypePropertyPage::IDD;
  230. }
  231. UINT CDNSZoneWizardHolder::GetLastEntryPointPageID()
  232. {
  233. if (m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  234. {
  235. //
  236. // if DS primary or secondary, skip storage page
  237. //
  238. if (m_pZoneInfo->m_bIsStub)
  239. {
  240. //
  241. // AD-integrated Stub zone
  242. //
  243. return CDNSZoneWiz_MastersPropertyPage::IDD;
  244. }
  245. else
  246. {
  247. if (m_pZoneInfo->m_bForward)
  248. {
  249. //
  250. // AD-integrated Fwd lookup zone
  251. //
  252. return CDNSZoneWiz_DynamicPropertyPage::IDD;
  253. }
  254. else
  255. {
  256. //
  257. // AD-integrated Rev lookup zone
  258. //
  259. return CDNSZoneWiz_DynamicPropertyPage::IDD;
  260. }
  261. }
  262. }
  263. else
  264. {
  265. //
  266. // File based zones
  267. //
  268. if (m_pZoneInfo->m_bIsStub)
  269. {
  270. //
  271. // File based stub zone
  272. //
  273. return CDNSZoneWiz_MastersPropertyPage::IDD;
  274. }
  275. else if (m_pZoneInfo->m_bPrimary)
  276. {
  277. //
  278. // standard primary
  279. //
  280. return CDNSZoneWiz_DynamicPropertyPage::IDD;
  281. }
  282. else
  283. {
  284. //
  285. // Secondary zone
  286. //
  287. return CDNSZoneWiz_MastersPropertyPage::IDD;
  288. }
  289. }
  290. return CDNSZoneWiz_StoragePropertyPage::IDD;
  291. }
  292. DNS_STATUS CDNSZoneWizardHolder::CreateZoneHelper(CDNSServerNode* pServerNode,
  293. CDNSCreateZoneInfo* pZoneInfo,
  294. CComponentDataObject* pComponentData)
  295. {
  296. ASSERT(pServerNode != NULL);
  297. ASSERT(pZoneInfo != NULL);
  298. ASSERT(pComponentData != NULL);
  299. BOOL bLoadExisting = TRUE;
  300. if (pZoneInfo->m_bPrimary)
  301. {
  302. BOOL bUseADS = pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS;
  303. if (!bUseADS)
  304. bLoadExisting = pZoneInfo->m_storageType == CDNSCreateZoneInfo::importFile;
  305. UINT nDynamicUpdate = pZoneInfo->m_nDynamicUpdate;
  306. #ifdef USE_NDNC
  307. return pServerNode->CreatePrimaryZone(
  308. pZoneInfo->m_szZoneName,
  309. pZoneInfo->m_szZoneStorage,
  310. bLoadExisting,
  311. pZoneInfo->m_bForward,
  312. bUseADS,
  313. nDynamicUpdate,
  314. pComponentData,
  315. pZoneInfo->m_replType,
  316. pZoneInfo->m_szCustomReplName);
  317. #else
  318. return pServerNode->CreatePrimaryZone(
  319. pZoneInfo->m_szZoneName,
  320. pZoneInfo->m_szZoneStorage,
  321. bLoadExisting,
  322. pZoneInfo->m_bForward,
  323. bUseADS,
  324. nDynamicUpdate,
  325. pComponentData);
  326. #endif // USE_NDNC
  327. }
  328. else if (pZoneInfo->m_bIsStub)
  329. {
  330. BOOL bUseADS = pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS;
  331. if (!bUseADS)
  332. {
  333. bLoadExisting = pZoneInfo->m_storageType == CDNSCreateZoneInfo::importFile;
  334. }
  335. #ifdef USE_NDNC
  336. return pServerNode->CreateStubZone(pZoneInfo->m_szZoneName,
  337. pZoneInfo->m_szZoneStorage,
  338. bLoadExisting,
  339. bUseADS,
  340. pZoneInfo->m_bForward,
  341. pZoneInfo->m_ipMastersArray,
  342. pZoneInfo->m_nMastersCount,
  343. pZoneInfo->m_bLocalListOfMasters,
  344. pComponentData,
  345. pZoneInfo->m_replType,
  346. pZoneInfo->m_szCustomReplName);
  347. #else
  348. return pServerNode->CreateStubZone(pZoneInfo->m_szZoneName,
  349. pZoneInfo->m_szZoneStorage,
  350. bLoadExisting,
  351. bUseADS,
  352. pZoneInfo->m_bForward,
  353. pZoneInfo->m_ipMastersArray,
  354. pZoneInfo->m_nMastersCount,
  355. pZoneInfo->m_bLocalListOfMasters,
  356. pComponentData);
  357. #endif // USE_NDNC
  358. }
  359. else // secondary
  360. {
  361. ASSERT(pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS);
  362. bLoadExisting = pZoneInfo->m_storageType == CDNSCreateZoneInfo::importFile;
  363. return pServerNode->CreateSecondaryZone(
  364. pZoneInfo->m_szZoneName,
  365. pZoneInfo->m_szZoneStorage,
  366. bLoadExisting,
  367. pZoneInfo->m_bForward,
  368. pZoneInfo->m_ipMastersArray,
  369. pZoneInfo->m_nMastersCount,
  370. pComponentData);
  371. }
  372. }
  373. BOOL CDNSZoneWizardHolder::CreateZone()
  374. {
  375. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  376. CDNSServerNode* pServerNode = GetServerNode();
  377. ASSERT(pServerNode != NULL);
  378. ASSERT(GetComponentData() != NULL);
  379. USES_CONVERSION;
  380. DNS_STATUS err = CreateZoneHelper(pServerNode, m_pZoneInfo, GetComponentData());
  381. if (err != 0)
  382. {
  383. if (err == DNS_ERROR_DP_NOT_ENLISTED ||
  384. err == DNS_ERROR_DP_DOES_NOT_EXIST)
  385. {
  386. CString szErr;
  387. if (m_pZoneInfo->m_replType == domain)
  388. {
  389. szErr.Format(IDS_ERRMSG_NO_NDNC_DOMAIN_FORMAT, UTF8_TO_W(pServerNode->GetDomainName()));
  390. }
  391. else if (m_pZoneInfo->m_replType == forest)
  392. {
  393. szErr.Format(IDS_ERRMSG_NO_NDNC_FOREST_FORMAT, UTF8_TO_W(pServerNode->GetForestName()));
  394. }
  395. else
  396. {
  397. ASSERT(FALSE);
  398. }
  399. DNSMessageBox(szErr, MB_OK | MB_ICONERROR);
  400. }
  401. else
  402. {
  403. DNSErrorDialog(err, IDS_MSG_ZWIZ_FAIL);
  404. }
  405. }
  406. /* else
  407. {
  408. CString szMsg, szFmt;
  409. szFmt.LoadString(IDS_MSG_ZWIZ_SUCCESS);
  410. szMsg.Format((LPCTSTR)szFmt, (LPCTSTR)m_pZoneInfo->m_szZoneName);
  411. DNSMessageBox(szMsg);
  412. }
  413. */
  414. return err == 0;
  415. }
  416. ///////////////////////////////////////////////////////////////////////////////
  417. // CDNSZoneWiz_StartPropertyPage
  418. CDNSZoneWiz_StartPropertyPage::CDNSZoneWiz_StartPropertyPage()
  419. : CPropertyPageBase(CDNSZoneWiz_StartPropertyPage::IDD)
  420. {
  421. InitWiz97(TRUE,0,0);
  422. }
  423. BOOL CDNSZoneWiz_StartPropertyPage::OnInitDialog()
  424. {
  425. CPropertyPageBase::OnInitDialog();
  426. SetBigBoldFont(m_hWnd, IDC_STATIC_WELCOME);
  427. return TRUE;
  428. }
  429. BOOL CDNSZoneWiz_StartPropertyPage::OnSetActive()
  430. {
  431. GetHolder()->SetWizardButtonsFirst(TRUE);
  432. return TRUE;
  433. }
  434. //////////////////////////////////////////////////////////////////////////
  435. // CDNSZoneWiz_SelectServerPropertyPage
  436. CDNSZoneWiz_SelectServerPropertyPage::CDNSZoneWiz_SelectServerPropertyPage()
  437. : CPropertyPageBase(CDNSZoneWiz_SelectServerPropertyPage::IDD)
  438. {
  439. InitWiz97(FALSE,IDS_ZWIZ_SELECT_SERVER_TITLE,IDS_ZWIZ_SELECT_SERVER_SUBTITLE);
  440. }
  441. BEGIN_MESSAGE_MAP(CDNSZoneWiz_SelectServerPropertyPage, CPropertyPageBase)
  442. ON_LBN_SELCHANGE(IDC_SERVERS_LIST, OnListboxSelChange)
  443. END_MESSAGE_MAP()
  444. void CDNSZoneWiz_SelectServerPropertyPage::OnListboxSelChange()
  445. {
  446. GetHolder()->SetWizardButtonsFirst(GetServerListBox()->GetCurSel() != -1);
  447. }
  448. BOOL CDNSZoneWiz_SelectServerPropertyPage::OnSetActive()
  449. {
  450. GetHolder()->SetWizardButtonsFirst(GetServerListBox()->GetCurSel() != -1);
  451. return CPropertyPageBase::OnSetActive();
  452. }
  453. LRESULT CDNSZoneWiz_SelectServerPropertyPage::OnWizardNext()
  454. {
  455. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  456. CListBox* pServerListBox = GetServerListBox();
  457. int nSel = pServerListBox->GetCurSel();
  458. ASSERT((nSel >= 0) && (nSel < pServerListBox->GetCount()));
  459. CDNSServerNode* pServerNode = (CDNSServerNode*)pServerListBox->GetItemData(nSel);
  460. pHolder->SetServerNode(pServerNode);
  461. return CPropertyPageBase::OnWizardNext();
  462. }
  463. BOOL CDNSZoneWiz_SelectServerPropertyPage::OnInitDialog()
  464. {
  465. CPropertyPageBase::OnInitDialog();
  466. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  467. ASSERT(pHolder->GetServerNode() == NULL);
  468. ASSERT(pHolder->GetComponentData() != NULL);
  469. CDNSRootData* pRootData = (CDNSRootData*)pHolder->GetComponentData()->GetRootData();
  470. ASSERT(pRootData != NULL);
  471. CListBox* pServerListBox = GetServerListBox();
  472. ASSERT(pServerListBox != NULL);
  473. POSITION pos;
  474. CNodeList* pChildList = pRootData->GetContainerChildList();
  475. int k = 0;
  476. // fill in the listbox
  477. for (pos = pChildList->GetHeadPosition(); pos != NULL; )
  478. {
  479. CDNSServerNode* pServerNode = (CDNSServerNode*)pChildList->GetNext(pos);
  480. pServerListBox->InsertString(k, pServerNode->GetDisplayName());
  481. pServerListBox->SetItemData(k,(DWORD_PTR)pServerNode);
  482. k++;
  483. }
  484. ASSERT(k > 0); // we have to have at least a server in the list
  485. ASSERT(pServerListBox->GetCount() == k);
  486. // select the first item, if any
  487. pServerListBox->SetCurSel((pServerListBox->GetCount() > 0) ? 0 : -1);
  488. return TRUE; // return TRUE unless you set the focus to a control
  489. // EXCEPTION: OCX Property Pages should return FALSE
  490. }
  491. BOOL CDNSZoneWiz_SelectServerPropertyPage::OnKillActive()
  492. {
  493. #ifdef _DEBUG
  494. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  495. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  496. ASSERT(pServerNode != NULL);
  497. #endif
  498. return CPropertyPage::OnKillActive();
  499. }
  500. //////////////////////////////////////////////////////////////////////////
  501. // CDNSZoneWiz_ZoneTypePropertyPage
  502. CDNSZoneWiz_ZoneTypePropertyPage::CDNSZoneWiz_ZoneTypePropertyPage()
  503. : CPropertyPageBase(CDNSZoneWiz_ZoneTypePropertyPage::IDD)
  504. {
  505. InitWiz97(FALSE,IDS_ZWIZ_ZONE_TYPE_TITLE,IDS_ZWIZ_ZONE_TYPE_SUBTITLE);
  506. }
  507. BEGIN_MESSAGE_MAP(CDNSZoneWiz_ZoneTypePropertyPage, CPropertyPageBase)
  508. ON_BN_CLICKED(IDC_RADIO_PRIMARY_ZONE, OnRadioChange)
  509. ON_BN_CLICKED(IDC_RADIO_STUB, OnRadioChange)
  510. ON_BN_CLICKED(IDC_RADIO_SECONDARY,OnRadioChange)
  511. ON_BN_CLICKED(IDC_ADINT_CHECK, OnRadioChange)
  512. END_MESSAGE_MAP()
  513. void CDNSZoneWiz_ZoneTypePropertyPage::OnRadioChange()
  514. {
  515. if (SendDlgItemMessage(IDC_RADIO_SECONDARY, BM_GETCHECK, 0, 0) == BST_CHECKED)
  516. {
  517. SendDlgItemMessage(IDC_ADINT_CHECK, BM_SETCHECK, BST_UNCHECKED, 0);
  518. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(FALSE);
  519. }
  520. else
  521. {
  522. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  523. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  524. if (pServerNode->CanUseADS())
  525. {
  526. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(TRUE);
  527. }
  528. }
  529. }
  530. BOOL CDNSZoneWiz_ZoneTypePropertyPage::OnSetActive()
  531. {
  532. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  533. pHolder->SetWizardButtonsMiddle(TRUE);
  534. SetUIState();
  535. return CPropertyPageBase::OnSetActive();
  536. }
  537. #ifdef USE_NDNC
  538. LRESULT CDNSZoneWiz_ZoneTypePropertyPage::OnWizardNext()
  539. {
  540. GetUIState();
  541. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  542. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  543. UINT nextPage = static_cast<UINT>(-1);
  544. if (pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS ||
  545. pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  546. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  547. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER))
  548. {
  549. if (pHolder->m_bKnowZoneLookupType)
  550. {
  551. if (pHolder->m_pZoneInfo->m_bForward)
  552. {
  553. nextPage = CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  554. }
  555. else
  556. {
  557. nextPage = CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  558. }
  559. }
  560. else
  561. {
  562. nextPage = CDNSZoneWiz_ZoneLookupPropertyPage::IDD;
  563. }
  564. }
  565. else
  566. {
  567. nextPage = CDNSZoneWiz_ADReplicationPropertyPage::IDD;
  568. }
  569. return (LRESULT)nextPage;
  570. }
  571. #else
  572. LRESULT CDNSZoneWiz_ZoneTypePropertyPage::OnWizardNext()
  573. {
  574. GetUIState();
  575. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  576. UINT nextPage = static_cast<UINT>(-1);
  577. if (pHolder->m_bKnowZoneLookupType)
  578. {
  579. if (pHolder->m_pZoneInfo->m_bForward)
  580. nextPage = CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  581. else
  582. nextPage = CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  583. }
  584. else
  585. nextPage = CDNSZoneWiz_ZoneLookupPropertyPage::IDD;
  586. return (LRESULT)nextPage;
  587. }
  588. #endif // USE_NDNC
  589. LRESULT CDNSZoneWiz_ZoneTypePropertyPage::OnWizardBack()
  590. {
  591. UINT nPrevPage = static_cast<UINT>(-1); // first page by default
  592. GetUIState();
  593. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  594. if (pHolder->m_bServerPage)
  595. nPrevPage = CDNSZoneWiz_SelectServerPropertyPage::IDD;
  596. else if (pHolder->m_nBackToPage > 0)
  597. nPrevPage = pHolder->m_nBackToPage;
  598. else
  599. nPrevPage = CDNSZoneWiz_StartPropertyPage::IDD;
  600. return nPrevPage;
  601. }
  602. BOOL CDNSZoneWiz_ZoneTypePropertyPage::OnInitDialog()
  603. {
  604. CPropertyPageBase::OnInitDialog();
  605. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  606. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  607. if (!pServerNode->CanUseADS())
  608. {
  609. SendDlgItemMessage(IDC_ADINT_CHECK, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  610. GetDlgItem(IDC_ADINT_CHECK)->EnableWindow(FALSE);
  611. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::newFile;
  612. }
  613. SendDlgItemMessage(IDC_RADIO_PRIMARY_ZONE, BM_SETCHECK, BST_CHECKED, 0);
  614. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  615. pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  616. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER)
  617. {
  618. //
  619. // Disable Stub zones for pre-Whistler servers
  620. //
  621. GetDlgItem(IDC_RADIO_STUB)->EnableWindow(FALSE);
  622. GetDlgItem(IDC_STUB_STATIC)->EnableWindow(FALSE);
  623. }
  624. return TRUE; // return TRUE unless you set the focus to a control
  625. // EXCEPTION: OCX Property Pages should return FALSE
  626. }
  627. BOOL CDNSZoneWiz_ZoneTypePropertyPage::OnKillActive()
  628. {
  629. return CPropertyPage::OnKillActive();
  630. }
  631. void CDNSZoneWiz_ZoneTypePropertyPage::SetUIState()
  632. {
  633. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  634. CButton* pPrimaryButton = (CButton*)GetDlgItem(IDC_RADIO_PRIMARY_ZONE);
  635. CButton* pStubButton = (CButton*)GetDlgItem(IDC_RADIO_STUB);
  636. CButton* pSecondaryButton = (CButton*)GetDlgItem(IDC_RADIO_SECONDARY);
  637. CButton* pADIntCheck = (CButton*)GetDlgItem(IDC_ADINT_CHECK);
  638. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  639. if (pHolder->m_pZoneInfo->m_bPrimary)
  640. {
  641. if (pServerNode->CanUseADS())
  642. {
  643. pADIntCheck->EnableWindow(TRUE);
  644. }
  645. else
  646. {
  647. pADIntCheck->EnableWindow(FALSE);
  648. pADIntCheck->SetCheck(FALSE);
  649. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::newFile;
  650. }
  651. if (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  652. {
  653. //
  654. // primary DS integrated
  655. //
  656. pPrimaryButton->SetCheck(TRUE);
  657. pStubButton->SetCheck(FALSE);
  658. pSecondaryButton->SetCheck(FALSE);
  659. pADIntCheck->SetCheck(TRUE);
  660. }
  661. else
  662. {
  663. // primary standard
  664. pPrimaryButton->SetCheck(TRUE);
  665. pStubButton->SetCheck(FALSE);
  666. pSecondaryButton->SetCheck(FALSE);
  667. pADIntCheck->SetCheck(FALSE);
  668. }
  669. }
  670. else
  671. {
  672. if (pHolder->m_pZoneInfo->m_bIsStub)
  673. {
  674. //
  675. // Stub zone
  676. //
  677. pPrimaryButton->SetCheck(FALSE);
  678. pStubButton->SetCheck(TRUE);
  679. pSecondaryButton->SetCheck(FALSE);
  680. if (pServerNode->CanUseADS())
  681. {
  682. pADIntCheck->EnableWindow(TRUE);
  683. }
  684. if (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  685. {
  686. pADIntCheck->SetCheck(TRUE);
  687. }
  688. else
  689. {
  690. pADIntCheck->SetCheck(FALSE);
  691. }
  692. }
  693. else
  694. {
  695. //
  696. // Secondary
  697. //
  698. pPrimaryButton->SetCheck(FALSE);
  699. pStubButton->SetCheck(FALSE);
  700. pSecondaryButton->SetCheck(TRUE);
  701. pADIntCheck->EnableWindow(FALSE);
  702. }
  703. }
  704. }
  705. void CDNSZoneWiz_ZoneTypePropertyPage::GetUIState()
  706. {
  707. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  708. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  709. if ( ((CButton*)GetDlgItem(IDC_RADIO_SECONDARY))->GetCheck() )
  710. {
  711. pHolder->m_pZoneInfo->m_bIsStub = FALSE;
  712. // we were primary, need to pick a storage
  713. pHolder->m_pZoneInfo->m_bPrimary = FALSE;
  714. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::newFile;
  715. }
  716. else if ( ((CButton*)GetDlgItem(IDC_RADIO_PRIMARY_ZONE))->GetCheck() )
  717. {
  718. pHolder->m_pZoneInfo->m_bPrimary = TRUE;
  719. pHolder->m_pZoneInfo->m_bIsStub = FALSE;
  720. if (((CButton*)GetDlgItem(IDC_ADINT_CHECK))->GetCheck())
  721. {
  722. //
  723. // AD integrated primary
  724. //
  725. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::useADS;
  726. }
  727. else
  728. {
  729. //
  730. // Standard primary
  731. //
  732. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::newFile;
  733. }
  734. }
  735. else if (((CButton*)GetDlgItem(IDC_RADIO_STUB))->GetCheck())
  736. {
  737. //
  738. // Stub zone
  739. //
  740. //
  741. // Should not happen for pre-Whistler server
  742. //
  743. ASSERT(pServerNode->GetBuildNumber() >= DNS_SRV_BUILD_NUMBER_WHISTLER ||
  744. pServerNode->GetMajorVersion() >= DNS_SRV_MAJOR_VERSION_NT_5 &&
  745. pServerNode->GetMinorVersion() >= DNS_SRV_MINOR_VERSION_WHISTLER);
  746. pHolder->m_pZoneInfo->m_bPrimary = FALSE;
  747. pHolder->m_pZoneInfo->m_bIsStub = TRUE;
  748. if (((CButton*)GetDlgItem(IDC_ADINT_CHECK))->GetCheck())
  749. {
  750. //
  751. // AD integrated Stub zone
  752. //
  753. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::useADS;
  754. }
  755. else
  756. {
  757. //
  758. // Standard Stub zone
  759. //
  760. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::newFile;
  761. }
  762. }
  763. }
  764. //////////////////////////////////////////////////////////////////////////
  765. // CDNSZoneWiz_ZoneLookupPropertyPage
  766. CDNSZoneWiz_ZoneLookupPropertyPage::CDNSZoneWiz_ZoneLookupPropertyPage()
  767. : CPropertyPageBase(CDNSZoneWiz_ZoneLookupPropertyPage::IDD)
  768. {
  769. InitWiz97(FALSE,IDS_ZWIZ_ZONE_LOOKUP_TITLE,IDS_ZWIZ_ZONE_LOOKUP_SUBTITLE);
  770. }
  771. BOOL CDNSZoneWiz_ZoneLookupPropertyPage::OnSetActive()
  772. {
  773. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  774. pHolder->SetWizardButtonsMiddle(TRUE);
  775. return TRUE;
  776. }
  777. #ifdef USE_NDNC
  778. LRESULT CDNSZoneWiz_ZoneLookupPropertyPage::OnWizardNext()
  779. {
  780. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  781. // save the old setting
  782. pHolder->m_pZoneInfo->m_bWasForward = pHolder->m_pZoneInfo->m_bForward;
  783. // get the new setting
  784. pHolder->m_pZoneInfo->m_bForward =
  785. (GetCheckedRadioButton(IDC_RADIO_FWD, IDC_RADIO_REV) ==
  786. IDC_RADIO_FWD);
  787. if (pHolder->m_pZoneInfo->m_bForward)
  788. {
  789. return CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  790. }
  791. return CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  792. }
  793. LRESULT CDNSZoneWiz_ZoneLookupPropertyPage::OnWizardBack()
  794. {
  795. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  796. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  797. if (pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS ||
  798. pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  799. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  800. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER))
  801. {
  802. return CDNSZoneWiz_ZoneTypePropertyPage::IDD;
  803. }
  804. return CDNSZoneWiz_ADReplicationPropertyPage::IDD;
  805. }
  806. #else
  807. LRESULT CDNSZoneWiz_ZoneLookupPropertyPage::OnWizardNext()
  808. {
  809. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  810. // save the old setting
  811. pHolder->m_pZoneInfo->m_bWasForward = pHolder->m_pZoneInfo->m_bForward;
  812. // get the new setting
  813. pHolder->m_pZoneInfo->m_bForward =
  814. (GetCheckedRadioButton(IDC_RADIO_FWD, IDC_RADIO_REV) ==
  815. IDC_RADIO_FWD);
  816. if (pHolder->m_pZoneInfo->m_bForward)
  817. return CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  818. // This was an else but the sundown build didn't like having a control path not return a value
  819. return CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  820. }
  821. LRESULT CDNSZoneWiz_ZoneLookupPropertyPage::OnWizardBack()
  822. {
  823. return CDNSZoneWiz_ZoneTypePropertyPage::IDD;
  824. }
  825. #endif // USE_NDNC
  826. BOOL CDNSZoneWiz_ZoneLookupPropertyPage::OnInitDialog()
  827. {
  828. CPropertyPageBase::OnInitDialog();
  829. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  830. CheckRadioButton(IDC_RADIO_FWD, IDC_RADIO_REV,
  831. pHolder->m_pZoneInfo->m_bForward ? IDC_RADIO_FWD : IDC_RADIO_REV);
  832. return TRUE;
  833. }
  834. //////////////////////////////////////////////////////////////////////////
  835. // CDNSZoneWiz_ZoneNamePropertyPageBase
  836. BEGIN_MESSAGE_MAP(CDNSZoneWiz_ZoneNamePropertyPageBase, CPropertyPageBase)
  837. ON_EN_CHANGE(IDC_EDIT_ZONE_NAME, OnChangeEditZoneName)
  838. ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowse)
  839. END_MESSAGE_MAP()
  840. CDNSZoneWiz_ZoneNamePropertyPageBase::CDNSZoneWiz_ZoneNamePropertyPageBase(UINT nIDD)
  841. : CPropertyPageBase(nIDD)
  842. {
  843. }
  844. BOOL CDNSZoneWiz_ZoneNamePropertyPageBase::OnSetActive()
  845. {
  846. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  847. // enable and show browse button only if secondary
  848. CButton* pBrowseButton = GetBrowseButton();
  849. pBrowseButton->EnableWindow(!pHolder->m_pZoneInfo->m_bPrimary);
  850. pBrowseButton->ShowWindow(!pHolder->m_pZoneInfo->m_bPrimary);
  851. //
  852. // Limit the zone name to MAX_DNS_NAME_LEN characters
  853. //
  854. SendDlgItemMessage(IDC_EDIT_ZONE_NAME, EM_LIMITTEXT, (WPARAM)MAX_DNS_NAME_LEN, 0);
  855. pHolder->SetWizardButtonsMiddle(FALSE);
  856. SetUIState();
  857. return CPropertyPageBase::OnSetActive();
  858. }
  859. #ifdef USE_NDNC
  860. LRESULT CDNSZoneWiz_ZoneNamePropertyPageBase::OnWizardNext()
  861. {
  862. GetUIState();
  863. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  864. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  865. DNS_STATUS err = ::ValidateDnsNameAgainstServerFlags(pHolder->m_pZoneInfo->m_szZoneName,
  866. DnsNameDomain,
  867. pServerNode->GetNameCheckFlag());
  868. if (err != 0)
  869. {
  870. //
  871. // Bring up an error for an invalid name
  872. //
  873. CString szFmt, szMsg;
  874. szFmt.LoadString(IDS_MSG_ZONE_INVALID_NAME);
  875. szMsg.Format((LPCWSTR)szFmt, pHolder->m_pZoneInfo->m_szZoneName);
  876. if (DNSMessageBox(szMsg, MB_YESNO) == IDYES)
  877. {
  878. err = 0;
  879. }
  880. }
  881. if (err == 0)
  882. {
  883. if (pHolder->m_pZoneInfo->m_bPrimary)
  884. {
  885. if (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  886. {
  887. return CDNSZoneWiz_DynamicPropertyPage::IDD;
  888. }
  889. else
  890. {
  891. return CDNSZoneWiz_StoragePropertyPage::IDD;
  892. }
  893. }
  894. else
  895. {
  896. if (pHolder->m_pZoneInfo->m_bIsStub &&
  897. pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS)
  898. {
  899. return CDNSZoneWiz_StoragePropertyPage::IDD;
  900. }
  901. else
  902. {
  903. return CDNSZoneWiz_MastersPropertyPage::IDD;
  904. }
  905. }
  906. }
  907. return -1;
  908. }
  909. LRESULT CDNSZoneWiz_ZoneNamePropertyPageBase::OnWizardBack()
  910. {
  911. GetUIState();
  912. LRESULT nPrevPage = -1;
  913. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  914. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  915. if (pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS ||
  916. pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  917. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  918. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER))
  919. {
  920. if (pHolder->m_bKnowZoneLookupType && !pHolder->m_bKnowZoneLookupTypeEx)
  921. {
  922. nPrevPage = (LRESULT)CDNSZoneWiz_ZoneTypePropertyPage::IDD;
  923. }
  924. else if (pHolder->m_bKnowZoneLookupTypeEx && pHolder->m_nBackToPage > 0)
  925. {
  926. nPrevPage = pHolder->m_nBackToPage;
  927. }
  928. else
  929. {
  930. nPrevPage = CDNSZoneWiz_ZoneLookupPropertyPage::IDD;
  931. }
  932. }
  933. else
  934. {
  935. if (pHolder->m_bKnowZoneLookupType && !pHolder->m_bKnowZoneLookupTypeEx)
  936. {
  937. nPrevPage = (LRESULT)CDNSZoneWiz_ADReplicationPropertyPage::IDD;
  938. }
  939. else if (pHolder->m_bKnowZoneLookupTypeEx && pHolder->m_nBackToPage > 0)
  940. {
  941. nPrevPage = pHolder->m_nBackToPage;
  942. }
  943. else
  944. {
  945. nPrevPage = CDNSZoneWiz_ZoneLookupPropertyPage::IDD;
  946. }
  947. }
  948. return nPrevPage;
  949. }
  950. #else
  951. LRESULT CDNSZoneWiz_ZoneNamePropertyPageBase::OnWizardNext()
  952. {
  953. GetUIState();
  954. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  955. DNS_STATUS err = ::ValidateDnsNameAgainstServerFlags(pHolder->m_pZoneInfo->m_szZoneName,
  956. DnsNameDomain,
  957. pHolder->GetServerNode()->GetNameCheckFlag());
  958. if (err != 0)
  959. {
  960. //
  961. // Bring up an error for an invalid name
  962. //
  963. CString szFmt, szMsg;
  964. szFmt.LoadString(IDS_MSG_ZONE_INVALID_NAME);
  965. szMsg.Format((LPCWSTR)szFmt, pHolder->m_pZoneInfo->m_szZoneName);
  966. if (DNSMessageBox(szMsg, MB_YESNO) == IDYES)
  967. {
  968. err = 0;
  969. }
  970. }
  971. if (err == 0)
  972. {
  973. if (pHolder->m_pZoneInfo->m_bPrimary)
  974. {
  975. if (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  976. {
  977. return CDNSZoneWiz_DynamicPropertyPage::IDD;
  978. }
  979. else
  980. {
  981. return CDNSZoneWiz_StoragePropertyPage::IDD;
  982. }
  983. }
  984. else
  985. {
  986. if (pHolder->m_pZoneInfo->m_bIsStub &&
  987. pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS)
  988. {
  989. return CDNSZoneWiz_StoragePropertyPage::IDD;
  990. }
  991. return CDNSZoneWiz_MastersPropertyPage::IDD;
  992. }
  993. }
  994. return -1;
  995. }
  996. LRESULT CDNSZoneWiz_ZoneNamePropertyPageBase::OnWizardBack()
  997. {
  998. GetUIState();
  999. LRESULT nPrevPage = -1;
  1000. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1001. if (pHolder->m_bKnowZoneLookupType && !pHolder->m_bKnowZoneLookupTypeEx)
  1002. {
  1003. nPrevPage = (LRESULT)CDNSZoneWiz_ZoneTypePropertyPage::IDD;
  1004. }
  1005. else if (pHolder->m_bKnowZoneLookupTypeEx && pHolder->m_nBackToPage > 0)
  1006. {
  1007. nPrevPage = pHolder->m_nBackToPage;
  1008. }
  1009. else
  1010. {
  1011. nPrevPage = CDNSZoneWiz_ZoneLookupPropertyPage::IDD;
  1012. }
  1013. return nPrevPage;
  1014. }
  1015. #endif // USE_NDNC
  1016. void CDNSZoneWiz_ZoneNamePropertyPageBase::OnChangeEditZoneName()
  1017. {
  1018. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1019. CString sz;
  1020. GetZoneNameEdit()->GetWindowText(sz);
  1021. sz.TrimLeft();
  1022. sz.TrimRight();
  1023. pHolder->SetWizardButtonsMiddle(
  1024. IsValidDnsZoneName(sz, pHolder->m_pZoneInfo->m_bForward));
  1025. }
  1026. void CDNSZoneWiz_ZoneNamePropertyPageBase::OnBrowse()
  1027. {
  1028. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1029. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1030. CComponentDataObject* pComponentDataObject =
  1031. GetHolder()->GetComponentData();
  1032. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  1033. ASSERT(pServerNode != NULL);
  1034. CDNSBrowserDlg dlg(pComponentDataObject, pHolder,
  1035. pHolder->m_pZoneInfo->m_bForward ? ZONE_FWD : ZONE_REV,
  1036. FALSE /* bEnableEdit */, pServerNode->GetDisplayName() );
  1037. if (IDOK == dlg.DoModal())
  1038. {
  1039. CEdit* pEdit = GetZoneNameEdit();
  1040. pEdit->SetWindowText(dlg.GetSelectionString());
  1041. }
  1042. }
  1043. void CDNSZoneWiz_ZoneNamePropertyPageBase::SetUIState()
  1044. {
  1045. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1046. // if we changed zone lookup type, need to clear zone name
  1047. if (pHolder->m_pZoneInfo->m_bWasForward != pHolder->m_pZoneInfo->m_bForward)
  1048. {
  1049. pHolder->m_pZoneInfo->m_szZoneName.Empty();
  1050. pHolder->m_pZoneInfo->m_bWasForward = pHolder->m_pZoneInfo->m_bForward;
  1051. }
  1052. GetZoneNameEdit()->SetWindowText(pHolder->m_pZoneInfo->m_szZoneName);
  1053. }
  1054. void CDNSZoneWiz_ZoneNamePropertyPageBase::GetUIState()
  1055. {
  1056. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1057. CString szZoneName;
  1058. GetZoneNameEdit()->GetWindowText(szZoneName);
  1059. // need to trim blanks
  1060. szZoneName.TrimLeft();
  1061. szZoneName.TrimRight();
  1062. // provide a suggested file name
  1063. if (pHolder->m_pZoneInfo->m_szZoneName != szZoneName)
  1064. {
  1065. pHolder->m_pZoneInfo->m_szZoneName = szZoneName;
  1066. int nLen = szZoneName.GetLength();
  1067. if (nLen == 0)
  1068. {
  1069. pHolder->m_pZoneInfo->m_szZoneStorage.Empty();
  1070. }
  1071. else if (nLen == 1 && szZoneName[0] == TEXT('.'))
  1072. {
  1073. pHolder->m_pZoneInfo->m_szZoneStorage = _T("root.dns");
  1074. }
  1075. else
  1076. {
  1077. LPCTSTR lpszFmt = ( TEXT('.') == szZoneName.GetAt(nLen-1))
  1078. ? _T("%sdns") : _T("%s.dns");
  1079. pHolder->m_pZoneInfo->m_szZoneStorage.Format(lpszFmt, (LPCTSTR)pHolder->m_pZoneInfo->m_szZoneName);
  1080. //
  1081. // Added by JEFFJON 2/11/99 - changes any illegal file name characters (\/:*?"<>|) to '_'
  1082. // and truncates any filename to _MAX_FNAME length
  1083. //
  1084. LPCWSTR lpszZoneStorage = (LPCWSTR)pHolder->m_pZoneInfo->m_szZoneStorage;
  1085. int iCount = pHolder->m_pZoneInfo->m_szZoneStorage.GetLength();
  1086. if (iCount > _MAX_FNAME)
  1087. {
  1088. pHolder->m_pZoneInfo->m_szZoneStorage = pHolder->m_pZoneInfo->m_szZoneStorage.Left(_MAX_FNAME - 4);
  1089. pHolder->m_pZoneInfo->m_szZoneStorage += L".dns";
  1090. }
  1091. for (int idx = 0; idx < iCount + 1; idx++)
  1092. {
  1093. if (lpszZoneStorage[0] == L'\\' ||
  1094. lpszZoneStorage[0] == L'/' ||
  1095. lpszZoneStorage[0] == L':' ||
  1096. lpszZoneStorage[0] == L'*' ||
  1097. lpszZoneStorage[0] == L'?' ||
  1098. lpszZoneStorage[0] == L'"' ||
  1099. lpszZoneStorage[0] == L'<' ||
  1100. lpszZoneStorage[0] == L'>' ||
  1101. lpszZoneStorage[0] == L'|')
  1102. {
  1103. pHolder->m_pZoneInfo->m_szZoneStorage.SetAt(idx, L'_');
  1104. }
  1105. lpszZoneStorage++;
  1106. }
  1107. }
  1108. }
  1109. }
  1110. //////////////////////////////////////////////////////////////////////////
  1111. // CDNSZoneWiz_FwdZoneNamePropertyPage
  1112. CDNSZoneWiz_FwdZoneNamePropertyPage::CDNSZoneWiz_FwdZoneNamePropertyPage()
  1113. : CDNSZoneWiz_ZoneNamePropertyPageBase(CDNSZoneWiz_FwdZoneNamePropertyPage::IDD)
  1114. {
  1115. InitWiz97(FALSE,IDS_ZWIZ_FWD_ZONE_NAME_TITLE,IDS_ZWIZ_FWD_ZONE_NAME_SUBTITLE);
  1116. }
  1117. //////////////////////////////////////////////////////////////////////////
  1118. // CDNSZoneWiz_RevZoneNamePropertyPage
  1119. BEGIN_MESSAGE_MAP(CDNSZoneWiz_RevZoneNamePropertyPage, CDNSZoneWiz_ZoneNamePropertyPageBase)
  1120. ON_EN_CHANGE(IDC_SUBNET_IPEDIT, OnChangeSubnetIPv4Ctrl)
  1121. // ON_EN_CHANGE(IDC_MASK_IPEDIT, OnChangeMaskIPv4Ctrl)
  1122. ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton)
  1123. ON_BN_CLICKED(IDC_USE_IP_RADIO, OnChangeUseIPRadio)
  1124. ON_BN_CLICKED(IDC_USE_EDIT_RADIO, OnChangeUseEditRadio)
  1125. END_MESSAGE_MAP()
  1126. CDNSZoneWiz_RevZoneNamePropertyPage::CDNSZoneWiz_RevZoneNamePropertyPage()
  1127. : CDNSZoneWiz_ZoneNamePropertyPageBase(CDNSZoneWiz_RevZoneNamePropertyPage::IDD)
  1128. {
  1129. InitWiz97(FALSE,IDS_ZWIZ_REV_ZONE_NAME_TITLE,IDS_ZWIZ_REV_ZONE_NAME_SUBTITLE);
  1130. m_bUseIP = TRUE; // default is to use IP ctrl for input
  1131. }
  1132. BOOL CDNSZoneWiz_RevZoneNamePropertyPage::OnInitDialog()
  1133. {
  1134. CPropertyPageBase::OnInitDialog();
  1135. ResetIPEditAndNameValue();
  1136. SyncRadioButtons(m_bUseIP);
  1137. return TRUE;
  1138. }
  1139. BOOL CDNSZoneWiz_RevZoneNamePropertyPage::OnSetActive()
  1140. {
  1141. if (!CDNSZoneWiz_ZoneNamePropertyPageBase::OnSetActive())
  1142. return FALSE;
  1143. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1144. if (m_bUseIP)
  1145. {
  1146. OnChangeSubnetIPv4Ctrl();
  1147. }
  1148. if (pHolder->m_pZoneInfo->m_szZoneName.IsEmpty())
  1149. ResetIPEditAndNameValue();
  1150. return TRUE;
  1151. }
  1152. INT
  1153. _fastcall
  1154. DnsGetDefaultClassNetworkOctetCountFromFirstOctect(
  1155. IN WORD dwFirstOctect
  1156. )
  1157. /*++
  1158. Routine Description:
  1159. Gets count of octets in network portion IP address.
  1160. Note, this is standard IP network class for given,
  1161. obviously subnetting is unknown.
  1162. Arguments:
  1163. dwFirstOctect -- first octet expressed as DWORD
  1164. Return Value:
  1165. Count of network address octets.
  1166. --*/
  1167. {
  1168. if ( dwFirstOctect > 255 )
  1169. {
  1170. // huh?
  1171. return( 0 );
  1172. }
  1173. // note addresses are in netbyte order
  1174. // which we are treating as byte flipped and hence
  1175. // test the high bits in the low byte
  1176. // class A?
  1177. if ( ! (0x80 & dwFirstOctect) )
  1178. {
  1179. return( 1 );
  1180. }
  1181. // class B?
  1182. if ( ! (0x40 & dwFirstOctect) )
  1183. {
  1184. return( 2 );
  1185. }
  1186. // then class C
  1187. // yes, there's some multicast BS out there, I don't
  1188. // believe it requires any special handling
  1189. return( 3 );
  1190. }
  1191. int _ValidFields(DWORD* dwArr)
  1192. {
  1193. // we count contiguous non empty fields
  1194. ASSERT(dwArr[3] == (DWORD)-1); // last field must be zero (disabled)
  1195. int nFields = 0;
  1196. if (dwArr[3] == (DWORD)-1)
  1197. {
  1198. if ( (dwArr[0] != (DWORD)-1) && (dwArr[1] == (DWORD)-1) && (dwArr[2] == (DWORD)-1) )
  1199. nFields = 1;
  1200. else if ( (dwArr[0] != (DWORD)-1) && (dwArr[1] != (DWORD)-1) && (dwArr[2] == (DWORD)-1) )
  1201. nFields = 2;
  1202. else if ( (dwArr[0] != (DWORD)-1) && (dwArr[1] != (DWORD)-1) && (dwArr[2] != (DWORD)-1) )
  1203. nFields = 3;
  1204. }
  1205. return nFields;
  1206. }
  1207. int _ValidMaskFields(DWORD* dwArr)
  1208. {
  1209. int nFields = _ValidFields(dwArr);
  1210. if (nFields == 0)
  1211. return nFields;
  1212. // REVIEW_MARCOC: should ask for contiguous octects....
  1213. // we currently check for non zero
  1214. for (int k=0; k<nFields; k++)
  1215. {
  1216. if (dwArr[k] == 0)
  1217. return k;
  1218. }
  1219. return nFields;
  1220. }
  1221. int _NumericFieldCount(DWORD* dwArr)
  1222. {
  1223. ASSERT(dwArr[3] == 0);
  1224. // assume [3] is always zero, check [2],[1],[0]
  1225. for (int k=2; k>=0; k--)
  1226. {
  1227. if ( (dwArr[k] > 0) && (dwArr[k] <= 255) )
  1228. return k+1;
  1229. }
  1230. return 0;
  1231. }
  1232. BOOL CDNSZoneWiz_RevZoneNamePropertyPage::BuildZoneName(DWORD* dwSubnetArr /*, DWORD* dwMaskArr*/)
  1233. {
  1234. int nSubnetFields = _ValidFields(dwSubnetArr);
  1235. WCHAR szBuf[128];
  1236. szBuf[0] = NULL; // clear edit field
  1237. // count the number of non zero/empty fields in the mask
  1238. /* int nMaskFields = 0;
  1239. if (nSubnetFields > 0)
  1240. nMaskFields = _ValidMaskFields(dwMaskArr);
  1241. if (nMaskFields > nSubnetFields)
  1242. {
  1243. // mask extends into blank subnet fields, torn them into zeroes
  1244. for (int k=nSubnetFields; k< nMaskFields; k++)
  1245. dwSubnetArr[k] = (DWORD)0;
  1246. }
  1247. */
  1248. // format the zone name
  1249. // switch (nMaskFields)
  1250. switch (nSubnetFields)
  1251. {
  1252. case 0:
  1253. wsprintf(szBuf, L"???%s", INADDR_ARPA_SUFFIX);
  1254. break;
  1255. case 1:
  1256. ASSERT(dwSubnetArr[0] != (DWORD)-1);
  1257. wsprintf(szBuf, L"%d%s", dwSubnetArr[0], INADDR_ARPA_SUFFIX);
  1258. break;
  1259. case 2:
  1260. ASSERT(dwSubnetArr[0] != (DWORD)-1);
  1261. ASSERT(dwSubnetArr[1] != (DWORD)-1);
  1262. wsprintf(szBuf, L"%d.%d%s", dwSubnetArr[1], dwSubnetArr[0], INADDR_ARPA_SUFFIX);
  1263. break;
  1264. case 3:
  1265. ASSERT(dwSubnetArr[0] != (DWORD)-1);
  1266. ASSERT(dwSubnetArr[1] != (DWORD)-1);
  1267. ASSERT(dwSubnetArr[2] != (DWORD)-1);
  1268. wsprintf(szBuf, L"%d.%d.%d%s", dwSubnetArr[2], dwSubnetArr[1], dwSubnetArr[0], INADDR_ARPA_SUFFIX);
  1269. break;
  1270. };
  1271. GetZoneNameEdit()->SetWindowText(szBuf);
  1272. // return (nMaskFields > 0);
  1273. return (nSubnetFields > 0);
  1274. }
  1275. void CDNSZoneWiz_RevZoneNamePropertyPage::OnHelpButton()
  1276. {
  1277. CComPtr<IDisplayHelp> spHelp;
  1278. HRESULT hr = GetHolder()->GetComponentData()->GetConsole()->QueryInterface(IID_IDisplayHelp, (void **)&spHelp);
  1279. if (SUCCEEDED(hr))
  1280. spHelp->ShowTopic(L"DNSConcepts.chm::/sag_DNS_und_ReverseLookup.htm");
  1281. }
  1282. void CDNSZoneWiz_RevZoneNamePropertyPage::OnChangeSubnetIPv4Ctrl()
  1283. {
  1284. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1285. BOOL bEnableNext = FALSE;
  1286. // retrieve subnet IP ctrl value
  1287. DWORD dwSubnetArr[4] = {0};
  1288. GetSubnetIPv4Ctrl()->GetArray(dwSubnetArr,4);
  1289. ASSERT(dwSubnetArr[3] == (DWORD)-1); // last field must be zero (disabled)
  1290. // determine address class
  1291. // if the first field is empty or zero, invalid class
  1292. int nSubnetValidFields = _ValidFields(dwSubnetArr);
  1293. int nClass;
  1294. if ( (dwSubnetArr[0] == (DWORD)-1) || (dwSubnetArr[0] == 0) )
  1295. nClass = 0;
  1296. else
  1297. {
  1298. if (nSubnetValidFields > 0)
  1299. nClass = DnsGetDefaultClassNetworkOctetCountFromFirstOctect(LOWORD(dwSubnetArr[0]));
  1300. else
  1301. nClass = 0; // bad format
  1302. }
  1303. ASSERT( (nClass >= 0) && (nClass <= 3) );
  1304. // set the default mask value to all zeroes
  1305. // look if the subnet extends beyond mask
  1306. /* DWORD dwMaskArr[4];
  1307. dwMaskArr[0] = dwMaskArr[1] = dwMaskArr[2] = dwMaskArr[3] = (DWORD)0;
  1308. if ((nSubnetValidFields > 0) && (nClass >0))
  1309. {
  1310. // look for last nonzero field
  1311. int nNumericCount = _NumericFieldCount(dwSubnetArr);
  1312. int j = nClass;
  1313. if (nNumericCount > nClass)
  1314. j = nNumericCount;
  1315. ASSERT((j>0) && (j<=3));
  1316. for (int i=0; i<j; i++)
  1317. dwMaskArr[i] = (DWORD)255;
  1318. }
  1319. // set the mask IP control
  1320. GetMaskIPv4Ctrl()->SetArray(dwMaskArr,4);
  1321. */
  1322. // rebuild the zone name
  1323. bEnableNext = BuildZoneName(dwSubnetArr /*,dwMaskArr*/);
  1324. pHolder->SetWizardButtonsMiddle(bEnableNext);
  1325. }
  1326. /*
  1327. void CDNSZoneWiz_RevZoneNamePropertyPage::OnChangeMaskIPv4Ctrl()
  1328. {
  1329. ASSERT(m_bUseIP);
  1330. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1331. BOOL bEnableNext = FALSE;
  1332. // retrieve subnet IP ctrl value
  1333. DWORD dwSubnetArr[4];
  1334. GetSubnetIPv4Ctrl()->GetArray(dwSubnetArr,4);
  1335. ASSERT(dwSubnetArr[3] == 0); // last field must be zero (disabled)
  1336. // retrieve mask IP ctrl value
  1337. DWORD dwMaskArr[4];
  1338. GetMaskIPv4Ctrl()->GetArray(dwMaskArr,4);
  1339. // rebuild the zone name
  1340. bEnableNext = BuildZoneName(dwSubnetArr,dwMaskArr);
  1341. pHolder->SetWizardButtonsMiddle(bEnableNext);
  1342. }
  1343. */
  1344. /*
  1345. void CDNSZoneWiz_RevZoneNamePropertyPage::OnChangeSubnetIPv4Ctrl()
  1346. {
  1347. ASSERT(m_bUseIP);
  1348. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1349. BOOL bEnable = FALSE;
  1350. // retrieve IP ctrl value
  1351. DWORD dwArr[4];
  1352. GetSubnetIPv4Ctrl()->GetArray(dwArr,4);
  1353. int nFields = -1;
  1354. WCHAR szBuf[128];
  1355. szBuf[0] = NULL; // clear edit field
  1356. ASSERT(dwArr[3] == 0); // last field must be zero (disabled)
  1357. if (dwArr[3] == 0)
  1358. {
  1359. if ( (dwArr[0] != (DWORD)-1) && (dwArr[1] == (DWORD)-1) && (dwArr[2] == (DWORD)-1) )
  1360. nFields = 1;
  1361. else if ( (dwArr[0] != (DWORD)-1) && (dwArr[1] != (DWORD)-1) && (dwArr[2] == (DWORD)-1) )
  1362. nFields = 2;
  1363. else if ( (dwArr[0] != (DWORD)-1) && (dwArr[1] != (DWORD)-1) && (dwArr[2] != (DWORD)-1) )
  1364. nFields = 3;
  1365. // convert to text, reverse and insert
  1366. // into the edit control
  1367. // do not consider trailing zeroes
  1368. int nValidOctect = DnsGetDefaultClassNetworkOctetCountFromFirstOctect(LOWORD(dwArr[0]));
  1369. while ((dwArr[nFields-1] == 0) && (nFields > nValidOctect) )
  1370. {
  1371. nFields--;
  1372. }
  1373. switch (nFields)
  1374. {
  1375. case 1:
  1376. wsprintf(szBuf, L"%d%s", dwArr[0], INADDR_ARPA_SUFFIX);
  1377. break;
  1378. case 2:
  1379. wsprintf(szBuf, L"%d.%d%s", dwArr[1], dwArr[0], INADDR_ARPA_SUFFIX);
  1380. break;
  1381. case 3:
  1382. wsprintf(szBuf, L"%d.%d.%d%s", dwArr[2], dwArr[1], dwArr[0], INADDR_ARPA_SUFFIX);
  1383. break;
  1384. };
  1385. }
  1386. GetZoneNameEdit()->SetWindowText(szBuf);
  1387. pHolder->SetWizardButtonsMiddle(nFields != -1);
  1388. }
  1389. */
  1390. void CDNSZoneWiz_RevZoneNamePropertyPage::OnChangeUseIPRadio()
  1391. {
  1392. BOOL bPrevUseIP = m_bUseIP;
  1393. m_bUseIP = !m_bUseIP;
  1394. SyncRadioButtons(bPrevUseIP);
  1395. }
  1396. void CDNSZoneWiz_RevZoneNamePropertyPage::OnChangeUseEditRadio()
  1397. {
  1398. BOOL bPrevUseIP = m_bUseIP;
  1399. m_bUseIP = !m_bUseIP;
  1400. SyncRadioButtons(bPrevUseIP);
  1401. }
  1402. void CDNSZoneWiz_RevZoneNamePropertyPage::ResetIPEditAndNameValue()
  1403. {
  1404. DWORD dwArr[4];
  1405. dwArr[0] = (DWORD)-1;
  1406. dwArr[1] = dwArr[2] = dwArr[3] = (DWORD)-1;
  1407. GetSubnetIPv4Ctrl()->SetArray(dwArr, 4);
  1408. GetZoneNameEdit()->SetWindowText(NULL);
  1409. }
  1410. void CDNSZoneWiz_RevZoneNamePropertyPage::SyncRadioButtons(BOOL bPrevUseIP)
  1411. {
  1412. CButton* pUseIPRadio = GetUseIPRadio();
  1413. CButton* pUseEditRadio = GetUseEditRadio();
  1414. CDNSIPv4Control* pSubnetIPv4Ctrl = GetSubnetIPv4Ctrl();
  1415. // CDNSIPv4Control* pMaskIPv4Ctrl = GetMaskIPv4Ctrl();
  1416. // change selection
  1417. pUseIPRadio->SetCheck(m_bUseIP);
  1418. pUseEditRadio->SetCheck(!m_bUseIP);
  1419. GetZoneNameEdit()->EnableWindow(!m_bUseIP);
  1420. pSubnetIPv4Ctrl->EnableWindow(m_bUseIP);
  1421. pSubnetIPv4Ctrl->EnableField(3, FALSE); // always keep the last field disabled
  1422. // pMaskIPv4Ctrl->EnableWindow(m_bUseIP);
  1423. // pMaskIPv4Ctrl->EnableField(3, FALSE); // always keep the last field disabled
  1424. if (bPrevUseIP && !m_bUseIP)
  1425. {
  1426. // we are moving from editbox to IP control
  1427. // need to set values all over again
  1428. CString szZoneText;
  1429. GetZoneNameEdit()->GetWindowText(szZoneText);
  1430. DWORD dwArr[4];
  1431. dwArr[0] = (DWORD)-1;
  1432. dwArr[1] = dwArr[2] = dwArr[3] = (DWORD)-1;
  1433. pSubnetIPv4Ctrl->SetArray(dwArr, 4);
  1434. // dwArr[1] = dwArr[2] = (DWORD)-1;
  1435. // pMaskIPv4Ctrl->SetArray(dwArr, 4);
  1436. GetZoneNameEdit()->SetWindowText(szZoneText);
  1437. }
  1438. else
  1439. {
  1440. GetZoneNameEdit()->SetWindowText(NULL);
  1441. }
  1442. }
  1443. //////////////////////////////////////////////////////////////////////////
  1444. // CDNSZoneWiz_MastersPropertyPage
  1445. void CZoneWiz_MastersIPEditor::OnChangeData()
  1446. {
  1447. CDNSZoneWiz_MastersPropertyPage* pPage =
  1448. (CDNSZoneWiz_MastersPropertyPage*)GetParentWnd();
  1449. pPage->SetValidIPArray(GetCount() > 0);
  1450. }
  1451. CDNSZoneWiz_MastersPropertyPage::CDNSZoneWiz_MastersPropertyPage()
  1452. : CPropertyPageBase(CDNSZoneWiz_MastersPropertyPage::IDD)
  1453. {
  1454. InitWiz97(FALSE,IDS_ZWIZ_MASTERS_TITLE,IDS_ZWIZ_MASTERS_SUBTITLE);
  1455. m_bValidIPArray = FALSE;
  1456. }
  1457. BEGIN_MESSAGE_MAP(CDNSZoneWiz_MastersPropertyPage, CPropertyPageBase)
  1458. ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowse)
  1459. END_MESSAGE_MAP()
  1460. BOOL CDNSZoneWiz_MastersPropertyPage::OnSetActive()
  1461. {
  1462. // this page has to appear only for secondary zone
  1463. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1464. ASSERT(!pHolder->m_pZoneInfo->m_bPrimary);
  1465. SetUIState();
  1466. pHolder->SetWizardButtonsMiddle(m_bValidIPArray);
  1467. return CPropertyPageBase::OnSetActive();
  1468. }
  1469. LRESULT CDNSZoneWiz_MastersPropertyPage::OnWizardNext()
  1470. {
  1471. GetUIState();
  1472. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1473. // skip storage page for a secondary zone
  1474. if (pHolder->m_bFinishPage)
  1475. return CDNSZoneWiz_FinishPropertyPage::IDD;
  1476. // This was an else but the sundown build did not like having a control path not return a value
  1477. ASSERT(pHolder->m_nNextToPage != 0);
  1478. return pHolder->m_nNextToPage;
  1479. }
  1480. #ifdef USE_NDNC
  1481. LRESULT CDNSZoneWiz_MastersPropertyPage::OnWizardBack()
  1482. {
  1483. GetUIState();
  1484. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1485. if (pHolder->m_pZoneInfo->m_bIsStub &&
  1486. pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS)
  1487. {
  1488. return (LRESULT)CDNSZoneWiz_StoragePropertyPage::IDD;
  1489. }
  1490. if (pHolder->m_pZoneInfo->m_bIsStub &&
  1491. pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  1492. {
  1493. //
  1494. // If its a pre-Whistler server then go back to the name page
  1495. //
  1496. if (pHolder->m_pZoneInfo->m_bForward)
  1497. {
  1498. return (LRESULT)CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  1499. }
  1500. else
  1501. {
  1502. return (LRESULT)CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  1503. }
  1504. }
  1505. if (pHolder->m_pZoneInfo->m_bForward)
  1506. {
  1507. return (LRESULT)CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  1508. }
  1509. return (LRESULT)CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  1510. }
  1511. #else
  1512. LRESULT CDNSZoneWiz_MastersPropertyPage::OnWizardBack()
  1513. {
  1514. GetUIState();
  1515. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1516. if (pHolder->m_pZoneInfo->m_bIsStub &&
  1517. pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS)
  1518. {
  1519. return (LRESULT)CDNSZoneWiz_StoragePropertyPage::IDD;
  1520. }
  1521. if (pHolder->m_pZoneInfo->m_bForward)
  1522. return (LRESULT)CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  1523. // This was an else but the sundown build did not like having a control path not return a value
  1524. return (LRESULT)CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  1525. }
  1526. #endif // USE_NDNC
  1527. BOOL CDNSZoneWiz_MastersPropertyPage::OnInitDialog()
  1528. {
  1529. CPropertyPageBase::OnInitDialog();
  1530. VERIFY(m_editor.Initialize(this,
  1531. GetParent(),
  1532. IDC_BUTTON_UP,
  1533. IDC_BUTTON_DOWN,
  1534. IDC_BUTTON_ADD,
  1535. IDC_BUTTON_REMOVE,
  1536. IDC_IPEDIT,
  1537. IDC_LIST));
  1538. return TRUE; // return TRUE unless you set the focus to a control
  1539. // EXCEPTION: OCX Property Pages should return FALSE
  1540. }
  1541. void CDNSZoneWiz_MastersPropertyPage::SetValidIPArray(BOOL b)
  1542. {
  1543. m_bValidIPArray = b;
  1544. GetHolder()->SetWizardButtonsMiddle(m_bValidIPArray);
  1545. }
  1546. void CDNSZoneWiz_MastersPropertyPage::SetUIState()
  1547. {
  1548. m_editor.Clear();
  1549. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1550. if ( pHolder->m_pZoneInfo->m_ipMastersArray != NULL)
  1551. {
  1552. ASSERT(pHolder->m_pZoneInfo->m_nMastersCount > 0);
  1553. m_editor.AddAddresses(pHolder->m_pZoneInfo->m_ipMastersArray, pHolder->m_pZoneInfo->m_nMastersCount);
  1554. }
  1555. if ( pHolder->m_pZoneInfo->m_bIsStub &&
  1556. pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  1557. {
  1558. GetDlgItem(IDC_LOCAL_LIST_CHECK)->EnableWindow(TRUE);
  1559. GetDlgItem(IDC_LOCAL_LIST_CHECK)->ShowWindow(TRUE);
  1560. }
  1561. else
  1562. {
  1563. GetDlgItem(IDC_LOCAL_LIST_CHECK)->EnableWindow(FALSE);
  1564. GetDlgItem(IDC_LOCAL_LIST_CHECK)->ShowWindow(FALSE);
  1565. }
  1566. }
  1567. void CDNSZoneWiz_MastersPropertyPage::GetUIState()
  1568. {
  1569. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1570. pHolder->m_pZoneInfo->ResetIpArr();
  1571. pHolder->m_pZoneInfo->m_nMastersCount = m_editor.GetCount();
  1572. if (pHolder->m_pZoneInfo->m_nMastersCount > 0)
  1573. {
  1574. pHolder->m_pZoneInfo->m_ipMastersArray = new IP_ADDRESS[pHolder->m_pZoneInfo->m_nMastersCount];
  1575. int nFilled;
  1576. m_editor.GetAddresses(pHolder->m_pZoneInfo->m_ipMastersArray, pHolder->m_pZoneInfo->m_nMastersCount, &nFilled);
  1577. ASSERT(nFilled == (int)(pHolder->m_pZoneInfo->m_nMastersCount));
  1578. LRESULT lLocalList = SendDlgItemMessage(IDC_LOCAL_LIST_CHECK, BM_GETCHECK, 0, 0);
  1579. pHolder->m_pZoneInfo->m_bLocalListOfMasters = (lLocalList == BST_CHECKED);
  1580. }
  1581. }
  1582. void CDNSZoneWiz_MastersPropertyPage::OnBrowse()
  1583. {
  1584. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1585. if (!m_editor.BrowseFromDNSNamespace(pHolder->GetComponentData(),
  1586. pHolder,
  1587. TRUE,
  1588. pHolder->GetServerNode()->GetDisplayName()))
  1589. {
  1590. DNSMessageBox(IDS_MSG_ZONE_MASTERS_BROWSE_FAIL);
  1591. }
  1592. }
  1593. //////////////////////////////////////////////////////////////////////////
  1594. // CDNSZoneWiz_DynamicPropertyPage
  1595. CDNSZoneWiz_DynamicPropertyPage::CDNSZoneWiz_DynamicPropertyPage()
  1596. : CPropertyPageBase(CDNSZoneWiz_DynamicPropertyPage::IDD)
  1597. {
  1598. InitWiz97(FALSE,IDS_ZWIZ_DYNAMIC_TITLE,IDS_ZWIZ_DYNAMIC_SUBTITLE);
  1599. }
  1600. BEGIN_MESSAGE_MAP(CDNSZoneWiz_DynamicPropertyPage, CPropertyPageBase)
  1601. END_MESSAGE_MAP()
  1602. BOOL CDNSZoneWiz_DynamicPropertyPage::OnSetActive()
  1603. {
  1604. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1605. SetUIState();
  1606. pHolder->SetWizardButtonsMiddle(TRUE);
  1607. return CPropertyPageBase::OnSetActive();
  1608. }
  1609. LRESULT CDNSZoneWiz_DynamicPropertyPage::OnWizardNext()
  1610. {
  1611. GetUIState();
  1612. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1613. //
  1614. // skip storage page for a secondary zone
  1615. //
  1616. if (pHolder->m_bFinishPage)
  1617. {
  1618. return CDNSZoneWiz_FinishPropertyPage::IDD;
  1619. }
  1620. //
  1621. // This was an else but the sundown build did not like having a control path not return a value
  1622. //
  1623. ASSERT(pHolder->m_nNextToPage != 0);
  1624. return pHolder->m_nNextToPage;
  1625. }
  1626. #ifdef USE_NDNC
  1627. LRESULT CDNSZoneWiz_DynamicPropertyPage::OnWizardBack()
  1628. {
  1629. GetUIState();
  1630. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1631. LRESULT nIDD = 0;
  1632. if (pHolder->m_pZoneInfo->m_bPrimary)
  1633. {
  1634. if (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  1635. {
  1636. //
  1637. // If its a pre-Whistler server then go back to the name page
  1638. //
  1639. if (pHolder->m_pZoneInfo->m_bForward)
  1640. {
  1641. nIDD = (LRESULT)CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  1642. }
  1643. else
  1644. {
  1645. nIDD = (LRESULT)CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  1646. }
  1647. }
  1648. else
  1649. {
  1650. nIDD = (LRESULT)CDNSZoneWiz_StoragePropertyPage::IDD;
  1651. }
  1652. }
  1653. else
  1654. {
  1655. nIDD = (LRESULT)CDNSZoneWiz_MastersPropertyPage::IDD;
  1656. }
  1657. return nIDD;
  1658. }
  1659. #else
  1660. LRESULT CDNSZoneWiz_DynamicPropertyPage::OnWizardBack()
  1661. {
  1662. GetUIState();
  1663. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1664. LRESULT nIDD = 0;
  1665. if (pHolder->m_pZoneInfo->m_bPrimary)
  1666. {
  1667. if (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  1668. {
  1669. if (pHolder->m_pZoneInfo->m_bForward)
  1670. {
  1671. nIDD = (LRESULT)CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  1672. }
  1673. else
  1674. {
  1675. nIDD = (LRESULT)CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  1676. }
  1677. }
  1678. else
  1679. {
  1680. nIDD = (LRESULT)CDNSZoneWiz_StoragePropertyPage::IDD;
  1681. }
  1682. }
  1683. else
  1684. {
  1685. nIDD = (LRESULT)CDNSZoneWiz_MastersPropertyPage::IDD;
  1686. }
  1687. return nIDD;
  1688. }
  1689. #endif // USE_NDNC
  1690. BOOL CDNSZoneWiz_DynamicPropertyPage::OnInitDialog()
  1691. {
  1692. CPropertyPageBase::OnInitDialog();
  1693. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1694. //
  1695. // Set the default dynamic update depending on zone type
  1696. //
  1697. if (pHolder->m_pZoneInfo->m_bPrimary &&
  1698. pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS)
  1699. {
  1700. pHolder->m_pZoneInfo->m_nDynamicUpdate = ZONE_UPDATE_SECURE;
  1701. }
  1702. else
  1703. {
  1704. pHolder->m_pZoneInfo->m_nDynamicUpdate = ZONE_UPDATE_OFF;
  1705. }
  1706. return TRUE; // return TRUE unless you set the focus to a control
  1707. // EXCEPTION: OCX Property Pages should return FALSE
  1708. }
  1709. void CDNSZoneWiz_DynamicPropertyPage::SetUIState()
  1710. {
  1711. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1712. BOOL bSecureOK = (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS);
  1713. GetDlgItem(IDC_SECURE_DYNAMIC_RADIO)->EnableWindow(bSecureOK);
  1714. SendDlgItemMessage(IDC_SECURE_DYNAMIC_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
  1715. //
  1716. // If we are not allowing secure updates (standard primary) and
  1717. // the radio was checked before, change the flag so that we check
  1718. // the do not allow dynamic updates radio instead
  1719. //
  1720. UINT nDynamicUpdate = pHolder->m_pZoneInfo->m_nDynamicUpdate;
  1721. if (!bSecureOK && nDynamicUpdate == ZONE_UPDATE_SECURE)
  1722. {
  1723. nDynamicUpdate = ZONE_UPDATE_OFF;
  1724. pHolder->m_pZoneInfo->m_nDynamicUpdate = nDynamicUpdate;
  1725. }
  1726. //
  1727. // Set the radio buttons according to the zone info
  1728. //
  1729. if (nDynamicUpdate == ZONE_UPDATE_OFF)
  1730. {
  1731. SendDlgItemMessage(IDC_DENY_DYNAMIC_RADIO, BM_SETCHECK, BST_CHECKED, 0);
  1732. SendDlgItemMessage(IDC_ALLOW_DYNAMIC_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
  1733. SendDlgItemMessage(IDC_SECURE_DYNAMIC_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
  1734. }
  1735. else if (nDynamicUpdate == ZONE_UPDATE_UNSECURE)
  1736. {
  1737. SendDlgItemMessage(IDC_DENY_DYNAMIC_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
  1738. SendDlgItemMessage(IDC_ALLOW_DYNAMIC_RADIO, BM_SETCHECK, BST_CHECKED, 0);
  1739. SendDlgItemMessage(IDC_SECURE_DYNAMIC_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
  1740. }
  1741. else
  1742. {
  1743. SendDlgItemMessage(IDC_DENY_DYNAMIC_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
  1744. SendDlgItemMessage(IDC_ALLOW_DYNAMIC_RADIO, BM_SETCHECK, BST_UNCHECKED, 0);
  1745. SendDlgItemMessage(IDC_SECURE_DYNAMIC_RADIO, BM_SETCHECK, BST_CHECKED, 0);
  1746. }
  1747. }
  1748. void CDNSZoneWiz_DynamicPropertyPage::GetUIState()
  1749. {
  1750. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1751. UINT nDynamicUpdate = 0;
  1752. if (SendDlgItemMessage(IDC_DENY_DYNAMIC_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  1753. {
  1754. nDynamicUpdate = ZONE_UPDATE_OFF;
  1755. }
  1756. else if (SendDlgItemMessage(IDC_ALLOW_DYNAMIC_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  1757. {
  1758. nDynamicUpdate = ZONE_UPDATE_UNSECURE;
  1759. }
  1760. else
  1761. {
  1762. nDynamicUpdate = ZONE_UPDATE_SECURE;
  1763. }
  1764. pHolder->m_pZoneInfo->m_nDynamicUpdate = nDynamicUpdate;
  1765. }
  1766. //////////////////////////////////////////////////////////////////////////
  1767. // CDNSZoneWiz_StoragePropertyPage
  1768. CDNSZoneWiz_StoragePropertyPage::CDNSZoneWiz_StoragePropertyPage()
  1769. : CPropertyPageBase(CDNSZoneWiz_StoragePropertyPage::IDD)
  1770. {
  1771. InitWiz97(FALSE,IDS_ZWIZ_STORAGE_TITLE,IDS_ZWIZ_STORAGE_SUBTITLE);
  1772. }
  1773. BEGIN_MESSAGE_MAP(CDNSZoneWiz_StoragePropertyPage, CPropertyPageBase)
  1774. ON_EN_CHANGE(IDC_EDIT_NEW_FILE, OnChangeNewFileZoneName)
  1775. ON_EN_CHANGE(IDC_EDIT_IMPORT_FILE, OnChangeImportFileZoneName)
  1776. ON_BN_CLICKED(IDC_RADIO_CREATE_NEW_FILE, OnChangeRadioCreateNewFile)
  1777. ON_BN_CLICKED(IDC_RADIO_IMPORT_FILE, OnChangeRadioImportFile)
  1778. END_MESSAGE_MAP()
  1779. BOOL CDNSZoneWiz_StoragePropertyPage::OnSetActive()
  1780. {
  1781. GetHolder()->SetWizardButtonsMiddle(FALSE);
  1782. SetUIState();
  1783. return CPropertyPageBase::OnSetActive();
  1784. }
  1785. LRESULT CDNSZoneWiz_StoragePropertyPage::OnWizardNext()
  1786. {
  1787. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1788. GetUIState();
  1789. if (pHolder->m_pZoneInfo->m_bPrimary)
  1790. {
  1791. return CDNSZoneWiz_DynamicPropertyPage::IDD;
  1792. }
  1793. if (pHolder->m_pZoneInfo->m_bIsStub)
  1794. {
  1795. return CDNSZoneWiz_MastersPropertyPage::IDD;
  1796. }
  1797. if (pHolder->m_bFinishPage)
  1798. {
  1799. return CDNSZoneWiz_FinishPropertyPage::IDD;
  1800. }
  1801. // This was an else but the sundown build did not like having a control path not return a value
  1802. ASSERT(pHolder->m_nNextToPage != 0);
  1803. return pHolder->m_nNextToPage;
  1804. }
  1805. LRESULT CDNSZoneWiz_StoragePropertyPage::OnWizardBack()
  1806. {
  1807. GetUIState();
  1808. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1809. LRESULT nextPage = -1;
  1810. if (pHolder->m_pZoneInfo->m_bPrimary || pHolder->m_pZoneInfo->m_bIsStub)
  1811. {
  1812. if (pHolder->m_pZoneInfo->m_bForward)
  1813. nextPage = (LRESULT)CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  1814. else
  1815. nextPage = (LRESULT)CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  1816. }
  1817. else
  1818. {
  1819. nextPage = (LRESULT)CDNSZoneWiz_MastersPropertyPage::IDD;
  1820. }
  1821. return nextPage;
  1822. }
  1823. BOOL CDNSZoneWiz_StoragePropertyPage::OnInitDialog()
  1824. {
  1825. CPropertyPageBase::OnInitDialog();
  1826. SendDlgItemMessage(IDC_EDIT_NEW_FILE, EM_SETLIMITTEXT, (WPARAM)_MAX_FNAME, 0);
  1827. SendDlgItemMessage(IDC_EDIT_IMPORT_FILE, EM_SETLIMITTEXT, (WPARAM)_MAX_FNAME, 0);
  1828. return TRUE; // return TRUE unless you set the focus to a control
  1829. // EXCEPTION: OCX Property Pages should return FALSE
  1830. }
  1831. BOOL CDNSZoneWiz_StoragePropertyPage::OnKillActive()
  1832. {
  1833. // TODO
  1834. return CPropertyPage::OnKillActive();
  1835. }
  1836. void CDNSZoneWiz_StoragePropertyPage::SetUIState()
  1837. {
  1838. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1839. ASSERT(pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS);
  1840. CButton* pNewFileButton = (CButton*)GetDlgItem(IDC_RADIO_CREATE_NEW_FILE);
  1841. CButton* pImportFileButton = (CButton*)GetDlgItem(IDC_RADIO_IMPORT_FILE);
  1842. CEdit* pNewFileEdit = (CEdit*)GetDlgItem(IDC_EDIT_NEW_FILE);
  1843. CEdit* pImportFileEdit = (CEdit*)GetDlgItem(IDC_EDIT_IMPORT_FILE);
  1844. pNewFileEdit->SetWindowText(_T(""));
  1845. pImportFileEdit->SetWindowText(_T(""));
  1846. if (pHolder->m_pZoneInfo->m_bPrimary)
  1847. {
  1848. // all options are avalable, need to
  1849. pNewFileButton->EnableWindow(TRUE);
  1850. pNewFileButton->SetCheck(pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::newFile);
  1851. pNewFileEdit->EnableWindow(pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::newFile);
  1852. pImportFileButton->EnableWindow(TRUE);
  1853. pImportFileButton->SetCheck(pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::importFile);
  1854. pImportFileEdit->EnableWindow(pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::importFile);
  1855. if (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::newFile)
  1856. {
  1857. m_nCurrRadio = IDC_RADIO_CREATE_NEW_FILE;
  1858. pNewFileEdit->SetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1859. }
  1860. else if (pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::importFile)
  1861. {
  1862. m_nCurrRadio = IDC_RADIO_IMPORT_FILE;
  1863. pImportFileEdit->SetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1864. }
  1865. }
  1866. else
  1867. {
  1868. // only new file available
  1869. pNewFileButton->EnableWindow(TRUE);
  1870. pNewFileButton->SetCheck(TRUE);
  1871. pNewFileEdit->SetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1872. pNewFileEdit->EnableWindow(TRUE);
  1873. pImportFileButton->EnableWindow(FALSE);
  1874. pImportFileButton->SetCheck(FALSE);
  1875. pImportFileEdit->EnableWindow(FALSE);
  1876. m_nCurrRadio = IDC_RADIO_CREATE_NEW_FILE;
  1877. }
  1878. }
  1879. BOOL CDNSZoneWiz_StoragePropertyPage::ValidateEditBoxString(UINT nID)
  1880. {
  1881. CEdit* pEdit = (CEdit*)GetDlgItem(nID);
  1882. ASSERT(pEdit != NULL);
  1883. CString sz;
  1884. pEdit->GetWindowText(sz);
  1885. sz.TrimLeft();
  1886. sz.TrimRight();
  1887. return !sz.IsEmpty();
  1888. }
  1889. void CDNSZoneWiz_StoragePropertyPage::OnChangeNewFileZoneName()
  1890. {
  1891. GetHolder()->SetWizardButtonsMiddle(ValidateEditBoxString(IDC_EDIT_NEW_FILE));
  1892. }
  1893. void CDNSZoneWiz_StoragePropertyPage::OnChangeImportFileZoneName()
  1894. {
  1895. GetHolder()->SetWizardButtonsMiddle(ValidateEditBoxString(IDC_EDIT_IMPORT_FILE));
  1896. }
  1897. void CDNSZoneWiz_StoragePropertyPage::SyncRadioButtons(UINT nID)
  1898. {
  1899. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1900. ASSERT(pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS);
  1901. CButton* pNewFileButton = (CButton*)GetDlgItem(IDC_RADIO_CREATE_NEW_FILE);
  1902. CButton* pImportFileButton = (CButton*)GetDlgItem(IDC_RADIO_IMPORT_FILE);
  1903. CEdit* pNewFileEdit = (CEdit*)GetDlgItem(IDC_EDIT_NEW_FILE);
  1904. CEdit* pImportFileEdit = (CEdit*)GetDlgItem(IDC_EDIT_IMPORT_FILE);
  1905. if (m_nCurrRadio == IDC_RADIO_CREATE_NEW_FILE)
  1906. {
  1907. pNewFileEdit->GetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1908. }
  1909. else if(m_nCurrRadio == IDC_RADIO_IMPORT_FILE)
  1910. {
  1911. pImportFileEdit->GetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1912. }
  1913. switch (nID)
  1914. {
  1915. case IDC_RADIO_CREATE_NEW_FILE:
  1916. {
  1917. pImportFileEdit->SetWindowText(_T(""));
  1918. pNewFileEdit->SetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1919. pNewFileEdit->EnableWindow(TRUE);
  1920. pImportFileEdit->EnableWindow(FALSE);
  1921. pImportFileButton->SetCheck(FALSE);
  1922. }
  1923. break;
  1924. case IDC_RADIO_IMPORT_FILE:
  1925. {
  1926. pNewFileEdit->SetWindowText(_T(""));
  1927. pImportFileEdit->SetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1928. pNewFileEdit->EnableWindow(FALSE);
  1929. pImportFileEdit->EnableWindow(TRUE);
  1930. pNewFileButton->SetCheck(FALSE);
  1931. }
  1932. break;
  1933. }
  1934. m_nCurrRadio = nID;
  1935. }
  1936. void CDNSZoneWiz_StoragePropertyPage::OnChangeRadioCreateNewFile()
  1937. {
  1938. SyncRadioButtons(IDC_RADIO_CREATE_NEW_FILE);
  1939. }
  1940. void CDNSZoneWiz_StoragePropertyPage::OnChangeRadioImportFile()
  1941. {
  1942. SyncRadioButtons(IDC_RADIO_IMPORT_FILE);
  1943. }
  1944. void CDNSZoneWiz_StoragePropertyPage::GetUIState()
  1945. {
  1946. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1947. ASSERT(pHolder->m_pZoneInfo->m_storageType != CDNSCreateZoneInfo::useADS);
  1948. CButton* pNewFileButton = (CButton*)GetDlgItem(IDC_RADIO_CREATE_NEW_FILE);
  1949. CButton* pImportFileButton = (CButton*)GetDlgItem(IDC_RADIO_IMPORT_FILE);
  1950. CEdit* pNewFileEdit = (CEdit*)GetDlgItem(IDC_EDIT_NEW_FILE);
  1951. CEdit* pImportFileEdit = (CEdit*)GetDlgItem(IDC_EDIT_IMPORT_FILE);
  1952. if (pHolder->m_pZoneInfo->m_bPrimary)
  1953. {
  1954. // find the radio selection
  1955. if (pNewFileButton->GetCheck())
  1956. {
  1957. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::newFile;
  1958. pNewFileEdit->GetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1959. }
  1960. else if (pImportFileButton->GetCheck())
  1961. {
  1962. pHolder->m_pZoneInfo->m_storageType = CDNSCreateZoneInfo::importFile;
  1963. pImportFileEdit->GetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1964. }
  1965. }
  1966. else
  1967. {
  1968. pNewFileEdit->GetWindowText(pHolder->m_pZoneInfo->m_szZoneStorage);
  1969. }
  1970. }
  1971. #ifdef USE_NDNC
  1972. //////////////////////////////////////////////////////////////////////////
  1973. // CDNSZoneWiz_ADReplicationPropertyPage
  1974. CDNSZoneWiz_ADReplicationPropertyPage::CDNSZoneWiz_ADReplicationPropertyPage()
  1975. : CPropertyPageBase(CDNSZoneWiz_ADReplicationPropertyPage::IDD)
  1976. {
  1977. InitWiz97(FALSE,IDS_ZWIZ_ADREPLICATION_TITLE,IDS_ZWIZ_ADREPLICATION_SUBTITLE);
  1978. }
  1979. BEGIN_MESSAGE_MAP(CDNSZoneWiz_ADReplicationPropertyPage, CPropertyPageBase)
  1980. ON_BN_CLICKED(IDC_FOREST_RADIO, OnRadioChange)
  1981. ON_BN_CLICKED(IDC_DOMAIN_RADIO, OnRadioChange)
  1982. ON_BN_CLICKED(IDC_DOMAIN_DC_RADIO, OnRadioChange)
  1983. ON_BN_CLICKED(IDC_CUSTOM_RADIO, OnRadioChange)
  1984. ON_CBN_EDITCHANGE(IDC_CUSTOM_COMBO, OnRadioChange)
  1985. ON_CBN_SELCHANGE(IDC_CUSTOM_COMBO, OnCustomComboSelChange)
  1986. END_MESSAGE_MAP()
  1987. BOOL CDNSZoneWiz_ADReplicationPropertyPage::OnSetActive()
  1988. {
  1989. GetHolder()->SetWizardButtonsMiddle(TRUE);
  1990. SetUIState();
  1991. return CPropertyPageBase::OnSetActive();
  1992. }
  1993. LRESULT CDNSZoneWiz_ADReplicationPropertyPage::OnWizardNext()
  1994. {
  1995. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  1996. GetUIState();
  1997. if (pHolder->m_bKnowZoneLookupType && !pHolder->m_bKnowZoneLookupTypeEx)
  1998. {
  1999. if (pHolder->m_pZoneInfo->m_bForward)
  2000. return CDNSZoneWiz_FwdZoneNamePropertyPage::IDD;
  2001. else
  2002. return CDNSZoneWiz_RevZoneNamePropertyPage::IDD;
  2003. }
  2004. return CDNSZoneWiz_ZoneLookupPropertyPage::IDD;
  2005. }
  2006. LRESULT CDNSZoneWiz_ADReplicationPropertyPage::OnWizardBack()
  2007. {
  2008. GetUIState();
  2009. return CDNSZoneWiz_ZoneTypePropertyPage::IDD;
  2010. }
  2011. BOOL CDNSZoneWiz_ADReplicationPropertyPage::OnInitDialog()
  2012. {
  2013. CPropertyPageBase::OnInitDialog();
  2014. USES_CONVERSION;
  2015. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  2016. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  2017. //
  2018. // Get the forest and domain names and format them into the UI
  2019. //
  2020. PCWSTR pszDomainName = UTF8_TO_W(pServerNode->GetDomainName());
  2021. PCWSTR pszForestName = UTF8_TO_W(pServerNode->GetForestName());
  2022. ASSERT(pszDomainName);
  2023. ASSERT(pszForestName);
  2024. CString szWin2KReplText;
  2025. szWin2KReplText.Format(IDS_ZWIZ_AD_REPL_FORMAT, pszDomainName);
  2026. SetDlgItemText(IDC_DOMAIN_DC_RADIO, szWin2KReplText);
  2027. CString szDNSDomainText;
  2028. szDNSDomainText.Format(IDS_ZWIZ_AD_DOMAIN_FORMAT, pszDomainName);
  2029. SetDlgItemText(IDC_DOMAIN_RADIO, szDNSDomainText);
  2030. CString szDNSForestText;
  2031. szDNSForestText.Format(IDS_ZWIZ_AD_FOREST_FORMAT, pszForestName);
  2032. SetDlgItemText(IDC_FOREST_RADIO, szDNSForestText);
  2033. //
  2034. // Enumerate the NDNCs available for storage
  2035. //
  2036. PDNS_RPC_DP_LIST pDirectoryPartitions = NULL;
  2037. DWORD dwErr = ::DnssrvEnumDirectoryPartitions(pServerNode->GetRPCName(),
  2038. DNS_DP_ENLISTED,
  2039. &pDirectoryPartitions);
  2040. //
  2041. // Don't show an error if we are not able to get the available directory partitions
  2042. // We can still continue on and the user can type in the directory partition they need
  2043. //
  2044. if (dwErr == 0 && pDirectoryPartitions)
  2045. {
  2046. for (DWORD dwIdx = 0; dwIdx < pDirectoryPartitions->dwDpCount; dwIdx++)
  2047. {
  2048. PDNS_RPC_DP_INFO pDirectoryPartition = 0;
  2049. dwErr = ::DnssrvDirectoryPartitionInfo(pServerNode->GetRPCName(),
  2050. pDirectoryPartitions->DpArray[dwIdx]->pszDpFqdn,
  2051. &pDirectoryPartition);
  2052. if (dwErr == 0 && pDirectoryPartition)
  2053. {
  2054. //
  2055. // Only add the partition if it is not one of the autocreated ones
  2056. // and the DNS server is enlisted in the partition
  2057. //
  2058. if (!(pDirectoryPartition->dwFlags & DNS_DP_AUTOCREATED) &&
  2059. (pDirectoryPartition->dwFlags & DNS_DP_ENLISTED))
  2060. {
  2061. SendDlgItemMessage(IDC_CUSTOM_COMBO,
  2062. CB_ADDSTRING,
  2063. 0,
  2064. (LPARAM)UTF8_TO_W(pDirectoryPartition->pszDpFqdn));
  2065. }
  2066. ::DnssrvFreeDirectoryPartitionInfo(pDirectoryPartition);
  2067. }
  2068. }
  2069. ::DnssrvFreeDirectoryPartitionList(pDirectoryPartitions);
  2070. }
  2071. return TRUE; // return TRUE unless you set the focus to a control
  2072. // EXCEPTION: OCX Property Pages should return FALSE
  2073. }
  2074. BOOL CDNSZoneWiz_ADReplicationPropertyPage::OnKillActive()
  2075. {
  2076. // TODO
  2077. return CPropertyPage::OnKillActive();
  2078. }
  2079. void CDNSZoneWiz_ADReplicationPropertyPage::SetUIState()
  2080. {
  2081. SyncRadioButtons();
  2082. }
  2083. void CDNSZoneWiz_ADReplicationPropertyPage::OnRadioChange()
  2084. {
  2085. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  2086. if (SendDlgItemMessage(IDC_FOREST_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  2087. {
  2088. pHolder->m_pZoneInfo->m_replType = forest;
  2089. }
  2090. else if (SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  2091. {
  2092. pHolder->m_pZoneInfo->m_replType = domain;
  2093. }
  2094. else if (SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  2095. {
  2096. pHolder->m_pZoneInfo->m_replType = w2k;
  2097. }
  2098. else if (SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  2099. {
  2100. pHolder->m_pZoneInfo->m_replType = custom;
  2101. }
  2102. else
  2103. {
  2104. // at least one radio button must be selected
  2105. ASSERT(FALSE);
  2106. }
  2107. SyncRadioButtons();
  2108. }
  2109. void CDNSZoneWiz_ADReplicationPropertyPage::SyncRadioButtons()
  2110. {
  2111. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  2112. switch (pHolder->m_pZoneInfo->m_replType)
  2113. {
  2114. case forest:
  2115. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2116. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2117. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2118. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2119. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  2120. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  2121. break;
  2122. case domain:
  2123. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2124. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2125. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2126. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2127. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  2128. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  2129. break;
  2130. case w2k:
  2131. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2132. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2133. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2134. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2135. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  2136. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  2137. break;
  2138. case custom:
  2139. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2140. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2141. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2142. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2143. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(TRUE);
  2144. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(TRUE);
  2145. break;
  2146. default:
  2147. SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2148. SendDlgItemMessage(IDC_FOREST_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2149. SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2150. SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  2151. GetDlgItem(IDC_CUSTOM_COMBO)->EnableWindow(FALSE);
  2152. GetDlgItem(IDC_CUSTOM_STATIC)->EnableWindow(FALSE);
  2153. break;
  2154. }
  2155. if (BST_CHECKED == SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_GETCHECK, 0, 0))
  2156. {
  2157. CString szTemp;
  2158. GetDlgItemText(IDC_CUSTOM_COMBO, szTemp);
  2159. pHolder->SetWizardButtonsMiddle(!szTemp.IsEmpty());
  2160. }
  2161. else
  2162. {
  2163. pHolder->SetWizardButtonsMiddle(TRUE);
  2164. }
  2165. }
  2166. void CDNSZoneWiz_ADReplicationPropertyPage::OnCustomComboSelChange()
  2167. {
  2168. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  2169. LRESULT iSel = SendDlgItemMessage(IDC_CUSTOM_COMBO, CB_GETCURSEL, 0, 0);
  2170. if (CB_ERR != iSel)
  2171. {
  2172. CString szTemp;
  2173. CComboBox* pComboBox = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_CUSTOM_COMBO));
  2174. ASSERT(pComboBox);
  2175. pComboBox->GetLBText(static_cast<int>(iSel), szTemp);
  2176. pHolder->SetWizardButtonsMiddle(!szTemp.IsEmpty());
  2177. }
  2178. else
  2179. {
  2180. pHolder->SetWizardButtonsMiddle(FALSE);
  2181. }
  2182. }
  2183. void CDNSZoneWiz_ADReplicationPropertyPage::GetUIState()
  2184. {
  2185. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  2186. if (SendDlgItemMessage(IDC_FOREST_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  2187. {
  2188. pHolder->m_pZoneInfo->m_replType = forest;
  2189. }
  2190. else if (SendDlgItemMessage(IDC_DOMAIN_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  2191. {
  2192. pHolder->m_pZoneInfo->m_replType = domain;
  2193. }
  2194. else if (SendDlgItemMessage(IDC_DOMAIN_DC_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  2195. {
  2196. pHolder->m_pZoneInfo->m_replType = w2k;
  2197. }
  2198. else if (SendDlgItemMessage(IDC_CUSTOM_RADIO, BM_GETCHECK, 0, 0) == BST_CHECKED)
  2199. {
  2200. pHolder->m_pZoneInfo->m_replType = custom;
  2201. }
  2202. else
  2203. {
  2204. // at least one radio button must be checked
  2205. ASSERT(FALSE);
  2206. }
  2207. SyncRadioButtons();
  2208. CComboBox* pCustomCombo = reinterpret_cast<CComboBox*>(GetDlgItem(IDC_CUSTOM_COMBO));
  2209. ASSERT(pCustomCombo);
  2210. int iSel = pCustomCombo->GetCurSel();
  2211. if (iSel != CB_ERR)
  2212. {
  2213. pCustomCombo->GetLBText(iSel, pHolder->m_pZoneInfo->m_szCustomReplName);
  2214. }
  2215. else
  2216. {
  2217. pCustomCombo->GetWindowText(pHolder->m_pZoneInfo->m_szCustomReplName);
  2218. }
  2219. }
  2220. #endif // USE_NDNC
  2221. //////////////////////////////////////////////////////////////////////////
  2222. // CDNSZoneWiz_FinishPropertyPage
  2223. CDNSZoneWiz_FinishPropertyPage::CDNSZoneWiz_FinishPropertyPage()
  2224. : CPropertyPageBase(CDNSZoneWiz_FinishPropertyPage::IDD),
  2225. m_typeText(N_ZONEWIZ_TYPES)
  2226. {
  2227. InitWiz97(TRUE,0,0);
  2228. }
  2229. BOOL CDNSZoneWiz_FinishPropertyPage::OnInitDialog()
  2230. {
  2231. CPropertyPageBase::OnInitDialog();
  2232. SetBigBoldFont(m_hWnd, IDC_STATIC_COMPLETE);
  2233. VERIFY(m_typeText.Init(this,IDC_TYPE_STATIC));
  2234. VERIFY(m_lookupText.Init(this,IDC_LOOKUP_STATIC));
  2235. return TRUE;
  2236. }
  2237. LRESULT CDNSZoneWiz_FinishPropertyPage::OnWizardBack()
  2238. {
  2239. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  2240. if (pHolder->m_pZoneInfo->m_bPrimary)
  2241. {
  2242. return (LRESULT)CDNSZoneWiz_DynamicPropertyPage::IDD;
  2243. }
  2244. // This was an else but the sundown build did not like having a control path not return a value
  2245. return (LRESULT)CDNSZoneWiz_MastersPropertyPage::IDD; // secondary
  2246. }
  2247. BOOL CDNSZoneWiz_FinishPropertyPage::OnWizardFinish()
  2248. {
  2249. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  2250. return pHolder->CreateZone();
  2251. }
  2252. BOOL CDNSZoneWiz_FinishPropertyPage::OnSetActive()
  2253. {
  2254. GetHolder()->SetWizardButtonsLast(TRUE);
  2255. DisplaySummaryInfo();
  2256. return CPropertyPageBase::OnSetActive();
  2257. }
  2258. void CDNSZoneWiz_FinishPropertyPage::DisplaySummaryInfo()
  2259. {
  2260. CDNSZoneWizardHolder* pHolder = (CDNSZoneWizardHolder*)GetHolder();
  2261. GetDlgItem(IDC_NAME_STATIC)->SetWindowText(pHolder->m_pZoneInfo->m_szZoneName);
  2262. BOOL bUseADS = pHolder->m_pZoneInfo->m_storageType == CDNSCreateZoneInfo::useADS;
  2263. int nType;
  2264. if (pHolder->m_pZoneInfo->m_bPrimary)
  2265. {
  2266. nType = bUseADS ? N_ZONEWIZ_TYPES_DS_PRIMARY : N_ZONEWIZ_TYPES_PRIMARY;
  2267. }
  2268. else
  2269. {
  2270. if (pHolder->m_pZoneInfo->m_bIsStub)
  2271. {
  2272. nType = N_ZONEWIZ_TYPES_STUB;
  2273. }
  2274. else
  2275. {
  2276. nType = N_ZONEWIZ_TYPES_SECONDARY;
  2277. }
  2278. }
  2279. m_typeText.SetStateX(nType);
  2280. m_lookupText.SetToggleState(pHolder->m_pZoneInfo->m_bForward);
  2281. GetDlgItem(IDC_STORAGE_TYPE_STATIC)->ShowWindow(!bUseADS);
  2282. CStatic* pStorageNameStatic = (CStatic*)GetDlgItem(IDC_STORAGE_NAME_STATIC);
  2283. pStorageNameStatic->ShowWindow(!bUseADS);
  2284. LPCTSTR lpszText = bUseADS ? NULL : (LPCTSTR)(pHolder->m_pZoneInfo->m_szZoneStorage);
  2285. pStorageNameStatic->SetWindowText(lpszText);
  2286. }