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.

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