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.

3037 lines
86 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: serverui.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 "serverUI.h"
  18. #include "servwiz.h" // CRootHintsQueryThread
  19. #include "domain.h"
  20. #include "zone.h"
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // CDNSServer_InterfacesPropertyPage
  23. BEGIN_MESSAGE_MAP(CDNSServer_InterfacesPropertyPage, CPropertyPageBase)
  24. ON_BN_CLICKED(IDC_LISTEN_ON_ALL_RADIO, OnListenOnAllAddresses)
  25. ON_BN_CLICKED(IDC_LISTEN_ON_SPECIFIED_RADIO, OnListenOnSpecifiedAddresses)
  26. END_MESSAGE_MAP()
  27. void CDNSServer_InterfacesPropertyPage::CListenAddressesIPEditor::OnChangeData()
  28. {
  29. CDNSServer_InterfacesPropertyPage* pPage =
  30. (CDNSServer_InterfacesPropertyPage*)GetParentWnd();
  31. pPage->SetDirty(TRUE);
  32. if (GetCount() == 0)
  33. {
  34. CButton* pListenAllButton = pPage->GetListenOnAllRadio();
  35. pListenAllButton->SetCheck(TRUE);
  36. pPage->GetListenOnSpecifiedRadio()->SetCheck(FALSE);
  37. pPage->SelectionHelper(TRUE);
  38. pListenAllButton->SetFocus();
  39. }
  40. }
  41. CDNSServer_InterfacesPropertyPage::CDNSServer_InterfacesPropertyPage()
  42. : m_bAllWasPreviousSelection(FALSE),
  43. CPropertyPageBase(IDD_SERVER_INTERFACES_PAGE)
  44. {
  45. }
  46. BOOL CDNSServer_InterfacesPropertyPage::OnInitDialog()
  47. {
  48. CPropertyPageBase::OnInitDialog();
  49. CDNSServerPropertyPageHolder* pHolder =
  50. (CDNSServerPropertyPageHolder*)GetHolder();
  51. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  52. VERIFY(m_listenAddressesEditor.Initialize(this,
  53. GetParent(),
  54. IDC_BUTTON_UP,
  55. IDC_BUTTON_DOWN,
  56. IDC_BUTTON_ADD,
  57. IDC_BUTTON_REMOVE,
  58. IDC_IPEDIT,
  59. IDC_LIST));
  60. if (!pServerNode->HasServerInfo())
  61. {
  62. EnableWindow(FALSE);
  63. return TRUE;
  64. }
  65. BOOL bListenAll = FALSE;
  66. DWORD cAddrCount;
  67. PIP_ADDRESS pipAddrs;
  68. pServerNode->GetListenAddressesInfo(&cAddrCount, &pipAddrs);
  69. if (cAddrCount == 0)
  70. {
  71. // listening on all addresses
  72. pServerNode->GetServerAddressesInfo(&cAddrCount, &pipAddrs);
  73. bListenAll = TRUE;
  74. m_bAllWasPreviousSelection = TRUE;
  75. }
  76. GetListenOnAllRadio()->SetCheck(bListenAll);
  77. GetListenOnSpecifiedRadio()->SetCheck(!bListenAll);
  78. if (cAddrCount > 0)
  79. {
  80. m_listenAddressesEditor.AddAddresses(pipAddrs, cAddrCount);
  81. m_bAllWasPreviousSelection = FALSE;
  82. }
  83. m_listenAddressesEditor.EnableUI(!bListenAll, TRUE);
  84. SetDirty(FALSE);
  85. return TRUE; // return TRUE unless you set the focus to a control
  86. // EXCEPTION: OCX Property Pages should return FALSE
  87. }
  88. void CDNSServer_InterfacesPropertyPage::SelectionHelper(BOOL bListenAll)
  89. {
  90. CDNSServerPropertyPageHolder* pHolder =
  91. (CDNSServerPropertyPageHolder*)GetHolder();
  92. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  93. if ((m_bAllWasPreviousSelection && !bListenAll) || bListenAll)
  94. {
  95. m_listenAddressesEditor.Clear();
  96. }
  97. DWORD cAddrCount;
  98. PIP_ADDRESS pipAddrs;
  99. pServerNode->GetServerAddressesInfo(&cAddrCount, &pipAddrs);
  100. if (cAddrCount > 0)
  101. {
  102. m_listenAddressesEditor.AddAddresses(pipAddrs, cAddrCount);
  103. }
  104. m_listenAddressesEditor.EnableUI(!bListenAll, TRUE);
  105. m_bAllWasPreviousSelection = bListenAll;
  106. SetDirty(TRUE);
  107. }
  108. void CDNSServer_InterfacesPropertyPage::OnListenOnSpecifiedAddresses()
  109. {
  110. //ASSERT(!GetListenOnAllRadio()->GetCheck());
  111. //ASSERT(GetListenOnSpecifiedRadio()->GetCheck());
  112. SelectionHelper(FALSE);
  113. }
  114. void CDNSServer_InterfacesPropertyPage::OnListenOnAllAddresses()
  115. {
  116. //ASSERT(GetListenOnAllRadio()->GetCheck());
  117. //ASSERT(!GetListenOnSpecifiedRadio()->GetCheck());
  118. SelectionHelper(TRUE);
  119. }
  120. BOOL CDNSServer_InterfacesPropertyPage::OnApply()
  121. {
  122. CDNSServerPropertyPageHolder* pHolder =
  123. (CDNSServerPropertyPageHolder*)GetHolder();
  124. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  125. if (!IsDirty())
  126. return TRUE;
  127. int cAddrCount = 0;
  128. if (GetListenOnSpecifiedRadio()->GetCheck())
  129. {
  130. // get the data from the IP editor
  131. cAddrCount = m_listenAddressesEditor.GetCount();
  132. }
  133. BOOL bRet = TRUE;
  134. DWORD* pArr = (cAddrCount > 0) ? (DWORD*) malloc(sizeof(DWORD)*cAddrCount) : NULL;
  135. if (pArr != NULL && cAddrCount > 0)
  136. {
  137. int nFilled = 0;
  138. m_listenAddressesEditor.GetAddresses(pArr, cAddrCount, &nFilled);
  139. ASSERT(nFilled == cAddrCount);
  140. }
  141. // write to server
  142. DNS_STATUS err = pServerNode->ResetListenAddresses(cAddrCount, pArr);
  143. if (err != 0)
  144. {
  145. DNSErrorDialog(err, IDS_MSG_SERVER_INTERFACE_UPDATE_FAILED);
  146. bRet = FALSE;
  147. }
  148. if (pArr)
  149. {
  150. free(pArr);
  151. pArr = 0;
  152. }
  153. return bRet;
  154. }
  155. ////////////////////////////////////////////////////////////////////////////////////
  156. // CDomainForwardersEditInfo
  157. CDomainForwardersEditInfo::CDomainForwardersEditInfo(
  158. CDNSZoneNode* pZoneNode,
  159. BOOL bADIntegrated,
  160. BOOL bAllOthers)
  161. : m_bADIntegrated(bADIntegrated),
  162. m_pZoneNode(pZoneNode)
  163. {
  164. m_bAllOthersDomain = bAllOthers;
  165. m_actionItem = nochange;
  166. if (pZoneNode != NULL)
  167. {
  168. m_bRPCData = TRUE;
  169. pZoneNode->GetMastersInfo(&m_cAddrCount, &m_pIPList);
  170. m_szDomainName = pZoneNode->GetDisplayName();
  171. m_szDomainName.TrimLeft(L' ');
  172. m_szDomainName.TrimRight(L' ');
  173. m_bSlave = pZoneNode->IsForwarderSlave();
  174. m_dwTimeout = pZoneNode->ForwarderTimeout();
  175. }
  176. else
  177. {
  178. m_bRPCData = FALSE;
  179. m_cAddrCount = 0;
  180. m_pIPList = NULL;
  181. m_szDomainName = L"";
  182. m_bSlave = DNS_DEFAULT_SLAVE;
  183. m_dwTimeout = DNS_DEFAULT_FORWARD_TIMEOUT;
  184. }
  185. }
  186. CDomainForwardersEditInfo::~CDomainForwardersEditInfo()
  187. {
  188. if (m_bAllOthersDomain && m_pAllOthers != NULL)
  189. {
  190. delete m_pAllOthers;
  191. }
  192. if (m_pIPList != NULL &&
  193. m_actionItem != nochange &&
  194. !m_bRPCData)
  195. {
  196. free(m_pIPList);
  197. m_pIPList = NULL;
  198. }
  199. }
  200. PIP_ADDRESS CopyIPAddresses(PIP_ADDRESS pipAddrs, DWORD AddrCount)
  201. {
  202. if (!pipAddrs ||
  203. AddrCount < 1)
  204. {
  205. return 0;
  206. }
  207. int sizeofArray = AddrCount * sizeof(IP_ADDRESS);
  208. PIP_ADDRESS result = (PIP_ADDRESS)malloc(sizeofArray);
  209. if (!result)
  210. {
  211. return result;
  212. }
  213. memcpy(result, pipAddrs, sizeofArray);
  214. return result;
  215. }
  216. void CDomainForwardersEditInfo::SetAllOthersDomain(CAllOthersDomainInfo* pAllOthers)
  217. {
  218. if (pAllOthers != NULL)
  219. {
  220. m_bAllOthersDomain = TRUE;
  221. m_pAllOthers = pAllOthers;
  222. m_cAddrCount = m_pAllOthers->m_cAddrCount;
  223. m_pIPList = CopyIPAddresses(m_pAllOthers->m_pipAddrs, m_pAllOthers->m_cAddrCount);
  224. m_bSlave = m_pAllOthers->m_fSlave;
  225. m_dwTimeout = m_pAllOthers->m_dwForwardTimeout;
  226. }
  227. }
  228. void CDomainForwardersEditInfo::SetAction(ACTION_ITEM action)
  229. {
  230. m_actionItem = action;
  231. }
  232. BOOL CDomainForwardersEditInfo::Update(BOOL bSlave, DWORD dwTimeout, DWORD dwCount, PIP_ADDRESS pipArray)
  233. {
  234. BOOL bUpdate = FALSE;
  235. if (bSlave != m_bSlave ||
  236. dwTimeout != m_dwTimeout)
  237. {
  238. bUpdate = TRUE;
  239. m_bSlave = bSlave;
  240. m_dwTimeout = dwTimeout;
  241. }
  242. if (dwCount != m_cAddrCount)
  243. {
  244. if (m_pIPList != NULL)
  245. {
  246. if (!m_bRPCData)
  247. {
  248. //
  249. // Free the memory if it isn't part of the RPC structure
  250. //
  251. free(m_pIPList);
  252. m_pIPList = NULL;
  253. }
  254. }
  255. m_bRPCData = FALSE;
  256. m_pIPList = pipArray;
  257. m_cAddrCount = dwCount;
  258. bUpdate = TRUE;
  259. }
  260. else
  261. {
  262. if (m_pIPList != NULL)
  263. {
  264. for (UINT nIndex = 0; nIndex < dwCount; nIndex++)
  265. {
  266. if (nIndex <= m_cAddrCount)
  267. {
  268. if (pipArray[nIndex] != m_pIPList[nIndex])
  269. {
  270. bUpdate = TRUE;
  271. if (!m_bRPCData)
  272. {
  273. free(m_pIPList);
  274. m_pIPList = NULL;
  275. }
  276. m_bRPCData = FALSE;
  277. m_pIPList = pipArray;
  278. m_cAddrCount = dwCount;
  279. break;
  280. }
  281. }
  282. else
  283. {
  284. bUpdate = TRUE;
  285. if (m_actionItem != nochange)
  286. {
  287. free(m_pIPList);
  288. m_pIPList = NULL;
  289. }
  290. m_pIPList = pipArray;
  291. m_cAddrCount = dwCount;
  292. break;
  293. }
  294. }
  295. }
  296. else if (m_pIPList != NULL && dwCount > 0)
  297. {
  298. bUpdate = TRUE;
  299. m_pIPList = pipArray;
  300. m_cAddrCount = dwCount;
  301. }
  302. }
  303. if (bUpdate)
  304. {
  305. switch (GetAction())
  306. {
  307. case nochange:
  308. case update:
  309. SetAction(update);
  310. break;
  311. case remove:
  312. case add:
  313. default:
  314. break;
  315. }
  316. }
  317. return bUpdate;
  318. }
  319. ///////////////////////////////////////////////////////////////////////////////
  320. // CDNSServer_AddDomainForwarderDialog
  321. class CDNSServer_AddDomainForwarderDialog : public CHelpDialog
  322. {
  323. public:
  324. CDNSServer_AddDomainForwarderDialog(CDNSServerNode* pServerNode,
  325. CComponentDataObject* pComponentData)
  326. : CHelpDialog(IDD_SERVER_NEW_DOMAIN_FORWARDER, pComponentData),
  327. m_pComponentData(pComponentData),
  328. m_pServerNode(pServerNode)
  329. {
  330. m_bOkable = FALSE;
  331. m_szDomainName = L"";
  332. }
  333. ~CDNSServer_AddDomainForwarderDialog() {}
  334. //
  335. // Public data
  336. //
  337. CString m_szDomainName;
  338. DECLARE_MESSAGE_MAP()
  339. virtual BOOL OnInitDialog();
  340. virtual void OnOK();
  341. afx_msg void OnDomainEdit();
  342. private:
  343. BOOL m_bOkable;
  344. CDNSServerNode* m_pServerNode;
  345. CComponentDataObject* m_pComponentData;
  346. };
  347. BEGIN_MESSAGE_MAP(CDNSServer_AddDomainForwarderDialog, CHelpDialog)
  348. ON_EN_CHANGE(IDC_DOMAIN_NAME_EDIT, OnDomainEdit)
  349. END_MESSAGE_MAP()
  350. BOOL CDNSServer_AddDomainForwarderDialog::OnInitDialog()
  351. {
  352. CHelpDialog::OnInitDialog();
  353. GetDlgItem(IDOK)->EnableWindow(m_bOkable);
  354. SendDlgItemMessage(IDC_DOMAIN_NAME_EDIT, EM_SETLIMITTEXT, (WPARAM)254, 0);
  355. return TRUE;
  356. }
  357. void CDNSServer_AddDomainForwarderDialog::OnDomainEdit()
  358. {
  359. GetDlgItemText(IDC_DOMAIN_NAME_EDIT, m_szDomainName);
  360. m_szDomainName.TrimLeft(L' ');
  361. m_szDomainName.TrimRight(L' ');
  362. m_bOkable = !m_szDomainName.IsEmpty();
  363. GetDlgItem(IDOK)->EnableWindow(m_bOkable);
  364. }
  365. void CDNSServer_AddDomainForwarderDialog::OnOK()
  366. {
  367. DNS_STATUS err = ::ValidateDnsNameAgainstServerFlags(m_szDomainName,
  368. DnsNameDomain,
  369. m_pServerNode->GetNameCheckFlag());
  370. if (err != 0)
  371. {
  372. CString szFormatMsg;
  373. VERIFY(szFormatMsg.LoadString(IDS_MSG_DOMAIN_FORWARDER_ILLEGAL_NAME));
  374. CString szMessage;
  375. szMessage.Format(szFormatMsg, m_szDomainName);
  376. DNSErrorDialog(err, szMessage);
  377. return;
  378. }
  379. CHelpDialog::OnOK();
  380. }
  381. ///////////////////////////////////////////////////////////////////////////////
  382. // CDNSServer_DomainForwardersPropertyPage
  383. void CDNSServer_DomainForwardersPropertyPage::CForwarderAddressesIPEditor::OnChangeData()
  384. {
  385. CDNSServer_DomainForwardersPropertyPage* pPage =
  386. (CDNSServer_DomainForwardersPropertyPage*)GetParentWnd();
  387. pPage->SetDirty(TRUE);
  388. }
  389. BEGIN_MESSAGE_MAP(CDNSServer_DomainForwardersPropertyPage, CPropertyPageBase)
  390. ON_LBN_SELCHANGE(IDC_DOMAIN_LIST, OnDomainSelChange)
  391. ON_BN_CLICKED(IDC_DOMAIN_ADD_BUTTON, OnAddDomain)
  392. ON_BN_CLICKED(IDC_DOMAIN_REMOVE_BUTTON, OnRemoveDomain)
  393. ON_BN_CLICKED(IDC_SLAVE_CHECK, OnSlaveCheckChange)
  394. ON_EN_CHANGE(IDC_FWD_TIMEOUT_EDIT, OnForwarderTimeoutChange)
  395. END_MESSAGE_MAP()
  396. CDNSServer_DomainForwardersPropertyPage::CDNSServer_DomainForwardersPropertyPage()
  397. : m_pCurrentInfo(NULL),
  398. m_bPostApply(FALSE),
  399. m_bPageReadOnly(FALSE),
  400. m_bChangingSelection(FALSE),
  401. CPropertyPageBase(IDD_SERVER_DOMAIN_FORWARDERS_PAGE)
  402. {
  403. }
  404. void CDNSServer_DomainForwardersPropertyPage::OnDomainSelChange()
  405. {
  406. CDNSServerPropertyPageHolder* pHolder =
  407. (CDNSServerPropertyPageHolder*)GetHolder();
  408. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  409. // Set a flag so that we don't mark the page dirty when we are just
  410. // changing the selection
  411. m_bChangingSelection = TRUE;
  412. CListBox* pDomainList = (CListBox*)GetDlgItem(IDC_DOMAIN_LIST);
  413. if (pDomainList != NULL)
  414. {
  415. int iSel = pDomainList->GetCurSel();
  416. if (iSel != LB_ERR)
  417. {
  418. LRESULT lRes = pDomainList->GetItemData(iSel);
  419. if (lRes != LB_ERR)
  420. {
  421. //
  422. // Retrieve the edit info from the list box item
  423. //
  424. CDomainForwardersEditInfo* pInfo = reinterpret_cast<CDomainForwardersEditInfo*>(lRes);
  425. if (pInfo != NULL)
  426. {
  427. //
  428. // Store the previous selection's data before changing the UI.
  429. // This may be NULL during OnInitDialog so check before trying
  430. // to store the info.
  431. //
  432. if (m_pCurrentInfo != NULL)
  433. {
  434. BOOL bSlave = GetSlaveCheck()->GetCheck();
  435. DWORD dwTimeout = m_forwardTimeoutEdit.GetVal();
  436. DWORD cAddrCount = m_forwarderAddressesEditor.GetCount();
  437. DWORD* pArr = (cAddrCount > 0) ? (DWORD*) malloc(sizeof(DWORD)*cAddrCount) : NULL;
  438. if (pArr != NULL)
  439. {
  440. if (cAddrCount > 0)
  441. {
  442. int nFilled = 0;
  443. m_forwarderAddressesEditor.GetAddresses(pArr, cAddrCount, &nFilled);
  444. ASSERT(nFilled == (int)cAddrCount);
  445. }
  446. }
  447. m_pCurrentInfo->Update(bSlave, dwTimeout, cAddrCount, pArr);
  448. }
  449. m_pCurrentInfo = pInfo;
  450. //
  451. // Enable the remove button according to the selection
  452. //
  453. if (pInfo->IsAllOthers())
  454. {
  455. GetDlgItem(IDC_DOMAIN_REMOVE_BUTTON)->EnableWindow(FALSE);
  456. }
  457. else
  458. {
  459. if (!m_bPageReadOnly)
  460. {
  461. GetDlgItem(IDC_DOMAIN_REMOVE_BUTTON)->EnableWindow(TRUE);
  462. }
  463. }
  464. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  465. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  466. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER))
  467. {
  468. //
  469. // Domain forwarding not available on pre-Whistler servers
  470. //
  471. GetDlgItem(IDC_DOMAIN_ADD_BUTTON)->EnableWindow(FALSE);
  472. GetDlgItem(IDC_DOMAIN_REMOVE_BUTTON)->EnableWindow(FALSE);
  473. }
  474. //
  475. // load data into the controls
  476. //
  477. GetSlaveCheck()->SetCheck(pInfo->IsSlave());
  478. m_forwardTimeoutEdit.SetVal(pInfo->GetTimeout());
  479. //
  480. // Display the text of the forwarder is AD integrated
  481. //
  482. GetDlgItem(IDC_FORWARDER_ADINT_STATIC)->ShowWindow(pInfo->IsADIntegrated());
  483. //
  484. // Clear the IP Editor controls
  485. //
  486. m_forwarderAddressesEditor.Clear();
  487. DWORD cAddrCount = 0;
  488. PIP_ADDRESS pipAddrs = pInfo->GetIPList(&cAddrCount);
  489. if (cAddrCount > 0 && pipAddrs != NULL)
  490. {
  491. BOOL bDirtyState = IsDirty();
  492. m_forwarderAddressesEditor.AddAddresses(pipAddrs, cAddrCount);
  493. SetDirty(bDirtyState);
  494. }
  495. }
  496. }
  497. }
  498. // Set the horizontal extent of the listbox so that the horizontal scroll
  499. // bar will scroll to the longest string
  500. CString str;
  501. int dx = 0;
  502. CDC* pDC = pDomainList->GetDC();
  503. TEXTMETRIC tm;
  504. VERIFY(pDC->GetTextMetrics(&tm));
  505. for (int i = 0; i < pDomainList->GetCount(); ++i)
  506. {
  507. pDomainList->GetText(i, str);
  508. CSize sz = pDC->GetTextExtent(str);
  509. dx = max(sz.cx, dx);
  510. }
  511. pDomainList->ReleaseDC(pDC);
  512. pDomainList->SetHorizontalExtent(dx);
  513. }
  514. m_bChangingSelection = FALSE;
  515. }
  516. void CDNSServer_DomainForwardersPropertyPage::OnAddDomain()
  517. {
  518. CThemeContextActivator activator;
  519. CDNSServerPropertyPageHolder* pHolder =
  520. (CDNSServerPropertyPageHolder*)GetHolder();
  521. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  522. CDNSServer_AddDomainForwarderDialog dlg(pServerNode, pHolder->GetComponentData());
  523. if (dlg.DoModal() == IDOK)
  524. {
  525. CListBox* pDomainList = (CListBox*)GetDlgItem(IDC_DOMAIN_LIST);
  526. //
  527. // Check to see if the name already exists
  528. //
  529. int iIndex = LB_ERR;
  530. int iFindIdx = pDomainList->FindStringExact(-1, dlg.m_szDomainName);
  531. if (iFindIdx == LB_ERR)
  532. {
  533. //
  534. // Add the name if it isn't already there
  535. //
  536. iIndex = pDomainList->InsertString(1, dlg.m_szDomainName);
  537. }
  538. else
  539. {
  540. //
  541. // If its there just point to it
  542. //
  543. iIndex = iFindIdx;
  544. }
  545. if (iIndex != LB_ERR)
  546. {
  547. CDomainForwardersEditInfo* pSearchInfo = m_EditList.DoesExist(dlg.m_szDomainName);
  548. if (pSearchInfo != NULL)
  549. {
  550. switch (pSearchInfo->GetAction())
  551. {
  552. case CDomainForwardersEditInfo::nochange:
  553. case CDomainForwardersEditInfo::update:
  554. case CDomainForwardersEditInfo::remove:
  555. pSearchInfo->SetAction(CDomainForwardersEditInfo::update);
  556. break;
  557. case CDomainForwardersEditInfo::add:
  558. default:
  559. break;
  560. }
  561. int iIdx = pDomainList->FindStringExact(-1, dlg.m_szDomainName);
  562. if (iIdx != LB_ERR)
  563. {
  564. pDomainList->SetCurSel(iIdx);
  565. pDomainList->SetItemData(iIdx, (LPARAM)pSearchInfo);
  566. OnDomainSelChange();
  567. }
  568. }
  569. else
  570. {
  571. //
  572. // Attach some data to keep track of whats being added or changed
  573. //
  574. CDomainForwardersEditInfo* pNewEditInfo = new CDomainForwardersEditInfo(NULL, FALSE);
  575. if (pNewEditInfo != NULL)
  576. {
  577. pNewEditInfo->SetDomainName(dlg.m_szDomainName);
  578. m_EditList.AddTail(pNewEditInfo);
  579. pDomainList->SetItemData(iIndex, (LPARAM)pNewEditInfo);
  580. switch (pNewEditInfo->GetAction())
  581. {
  582. case CDomainForwardersEditInfo::nochange:
  583. pNewEditInfo->SetAction(CDomainForwardersEditInfo::add);
  584. break;
  585. case CDomainForwardersEditInfo::update:
  586. case CDomainForwardersEditInfo::remove:
  587. case CDomainForwardersEditInfo::add:
  588. default:
  589. ASSERT(FALSE);
  590. break;
  591. }
  592. pDomainList->SetCurSel(iIndex);
  593. OnDomainSelChange();
  594. }
  595. }
  596. }
  597. }
  598. SetDirty(TRUE);
  599. }
  600. void CDNSServer_DomainForwardersPropertyPage::OnRemoveDomain()
  601. {
  602. CListBox* pDomainList = (CListBox*)GetDlgItem(IDC_DOMAIN_LIST);
  603. if (pDomainList != NULL)
  604. {
  605. int iSel = pDomainList->GetCurSel();
  606. if (iSel != LB_ERR)
  607. {
  608. CDomainForwardersEditInfo* pEditInfo = reinterpret_cast<CDomainForwardersEditInfo*>(pDomainList->GetItemData(iSel));
  609. if (pEditInfo != NULL)
  610. {
  611. ASSERT(pEditInfo == m_pCurrentInfo);
  612. switch (pEditInfo->GetAction())
  613. {
  614. case CDomainForwardersEditInfo::nochange:
  615. case CDomainForwardersEditInfo::update:
  616. case CDomainForwardersEditInfo::remove:
  617. pEditInfo->SetAction(CDomainForwardersEditInfo::remove);
  618. break;
  619. case CDomainForwardersEditInfo::add:
  620. m_EditList.Remove(pEditInfo);
  621. delete pEditInfo;
  622. break;
  623. default:
  624. ASSERT(FALSE);
  625. break;
  626. }
  627. }
  628. pDomainList->DeleteString(iSel);
  629. m_pCurrentInfo = NULL;
  630. //
  631. // Set the selection to the previous entry or 0
  632. //
  633. int nextSel = iSel - 1;
  634. if (nextSel < 0)
  635. {
  636. nextSel = 0;
  637. }
  638. pDomainList->SetCurSel(nextSel);
  639. OnDomainSelChange();
  640. }
  641. }
  642. SetDirty(TRUE);
  643. }
  644. void CDNSServer_DomainForwardersPropertyPage::OnSlaveCheckChange()
  645. {
  646. if (!m_bChangingSelection)
  647. {
  648. SetDirty(TRUE);
  649. }
  650. }
  651. void CDNSServer_DomainForwardersPropertyPage::OnForwarderTimeoutChange()
  652. {
  653. if (!m_bChangingSelection)
  654. {
  655. SetDirty(TRUE);
  656. }
  657. }
  658. BOOL CDNSServer_DomainForwardersPropertyPage::OnInitDialog()
  659. {
  660. CPropertyPageBase::OnInitDialog();
  661. CDNSServerPropertyPageHolder* pHolder =
  662. (CDNSServerPropertyPageHolder*)GetHolder();
  663. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  664. //
  665. // initialize controls
  666. //
  667. VERIFY(m_forwarderAddressesEditor.Initialize(this,
  668. GetParent(),
  669. IDC_BUTTON_UP,
  670. IDC_BUTTON_DOWN,
  671. IDC_BUTTON_ADD,
  672. IDC_BUTTON_REMOVE,
  673. IDC_IPEDIT,
  674. IDC_LIST));
  675. VERIFY(m_forwardTimeoutEdit.SubclassDlgItem(IDC_FWD_TIMEOUT_EDIT, this));
  676. m_forwardTimeoutEdit.SetRange(1,0xffff ); // DWORD
  677. m_forwardTimeoutEdit.SetLimitText(5); // 0 to 65535
  678. //
  679. // Disable IME support on the controls
  680. //
  681. ImmAssociateContext(m_forwardTimeoutEdit.GetSafeHwnd(), NULL);
  682. if (!pServerNode->HasServerInfo())
  683. {
  684. //
  685. // clear the root hints message text
  686. //
  687. SetDlgItemText(IDC_STATIC_MESSAGE, NULL);
  688. EnableWindow(FALSE);
  689. return TRUE;
  690. }
  691. //
  692. // Don't show the AD Integrated text unless the forwarder is
  693. // AD integrated (rare)
  694. //
  695. GetDlgItem(IDC_FORWARDER_ADINT_STATIC)->ShowWindow(FALSE);
  696. GetForwarderData();
  697. LoadUIData();
  698. SetDirty(FALSE);
  699. return TRUE; // return TRUE unless you set the focus to a control
  700. // EXCEPTION: OCX Property Pages should return FALSE
  701. }
  702. void CDNSServer_DomainForwardersPropertyPage::GetForwarderData()
  703. {
  704. CDNSServerPropertyPageHolder* pHolder =
  705. (CDNSServerPropertyPageHolder*)GetHolder();
  706. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  707. //
  708. // Get the domain forwarders info from hidden Category node
  709. //
  710. CDNSDomainForwardersNode* pDomainForwardersNode = pServerNode->GetDomainForwardersNode();
  711. if (pDomainForwardersNode)
  712. {
  713. CNodeList* pNodeList = pDomainForwardersNode->GetContainerChildList();
  714. POSITION pos = pNodeList->GetHeadPosition();
  715. while (pos != NULL)
  716. {
  717. CDNSZoneNode* pZoneNode = dynamic_cast<CDNSZoneNode*>(pNodeList->GetNext(pos));
  718. if (pZoneNode != NULL && pZoneNode->GetZoneType() == DNS_ZONE_TYPE_FORWARDER)
  719. {
  720. //
  721. // Create a temporary list that will last through the duration of the page for all
  722. // the forwarders
  723. //
  724. BOOL bADIntegrated = pZoneNode->IsDSIntegrated();
  725. CDomainForwardersEditInfo* pForwardersInfo = new CDomainForwardersEditInfo(
  726. pZoneNode,
  727. bADIntegrated,
  728. FALSE);
  729. if (pForwardersInfo != NULL)
  730. {
  731. m_EditList.AddTail(pForwardersInfo);
  732. }
  733. }
  734. }
  735. (void)CreateAllOthersDomainInfo(pServerNode);
  736. }
  737. }
  738. CDomainForwardersEditInfo* CDNSServer_DomainForwardersPropertyPage::CreateAllOthersDomainInfo(CDNSServerNode* pServerNode)
  739. {
  740. CDomainForwardersEditInfo* pForwardersInfo = 0;
  741. if (!pServerNode)
  742. {
  743. return pForwardersInfo;
  744. }
  745. //
  746. // get data from server
  747. //
  748. DWORD cAddrCount;
  749. PIP_ADDRESS pipAddrs;
  750. DWORD dwForwardTimeout;
  751. DWORD fSlave;
  752. pServerNode->GetForwardersInfo(&cAddrCount, &pipAddrs, &dwForwardTimeout, &fSlave);
  753. //
  754. // Create an edit list for the "All other domains" item
  755. //
  756. CAllOthersDomainInfo* pAllOthers = new CAllOthersDomainInfo(cAddrCount,
  757. pipAddrs,
  758. dwForwardTimeout,
  759. fSlave);
  760. if (pAllOthers != NULL)
  761. {
  762. pForwardersInfo = new CDomainForwardersEditInfo(NULL, FALSE);
  763. if (pForwardersInfo != NULL)
  764. {
  765. pForwardersInfo->SetAllOthersDomain(pAllOthers);
  766. pForwardersInfo->SetDataFromRPC(TRUE);
  767. m_EditList.AddTail(pForwardersInfo);
  768. }
  769. else
  770. {
  771. delete pAllOthers;
  772. pAllOthers = 0;
  773. }
  774. }
  775. return pForwardersInfo;
  776. }
  777. void CDNSServer_DomainForwardersPropertyPage::LoadUIData()
  778. {
  779. POSITION pos = m_EditList.GetHeadPosition();
  780. while (pos)
  781. {
  782. CDomainForwardersEditInfo* pForwarder = m_EditList.GetNext(pos);
  783. if (!pForwarder)
  784. {
  785. continue;
  786. }
  787. if (pForwarder->IsAllOthers())
  788. {
  789. //
  790. // Load the "All other domains" string and add it at the beginning
  791. //
  792. CString szAllOthers;
  793. VERIFY(szAllOthers.LoadString(IDS_OTHER_DOMAINS));
  794. LRESULT lRes = 0;
  795. lRes = SendDlgItemMessage(IDC_DOMAIN_LIST, LB_INSERTSTRING, 0, (LPARAM)(LPCWSTR)szAllOthers);
  796. if (lRes != LB_ERR)
  797. {
  798. SendDlgItemMessage(IDC_DOMAIN_LIST, LB_SETITEMDATA, lRes, (LPARAM)pForwarder);
  799. }
  800. }
  801. else
  802. {
  803. //
  804. // Add the forwarder to the UI
  805. //
  806. CString domainName;
  807. pForwarder->GetDomainName(domainName);
  808. LRESULT lIndex = SendDlgItemMessage(IDC_DOMAIN_LIST,
  809. LB_ADDSTRING,
  810. 0,
  811. (LPARAM)(LPCWSTR)domainName);
  812. if (lIndex != LB_ERR)
  813. {
  814. SendDlgItemMessage(IDC_DOMAIN_LIST, LB_SETITEMDATA, lIndex, (LPARAM)pForwarder);
  815. }
  816. }
  817. }
  818. }
  819. void CDNSServer_DomainForwardersPropertyPage::SetPageReadOnly(BOOL bServerHasRoot,
  820. BOOL bDoesRecursion)
  821. {
  822. m_bPageReadOnly = TRUE;
  823. //
  824. // the server is a root server or doesn't do recursion
  825. //
  826. EnableDialogControls(m_hWnd, FALSE);
  827. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_ADD_FORWARDERS);
  828. if (pStatic != NULL)
  829. {
  830. pStatic->ShowWindow(FALSE);
  831. }
  832. pStatic = (CStatic*)GetDlgItem(IDC_STATIC_MESSAGE);
  833. if (pStatic != NULL)
  834. {
  835. if (bServerHasRoot)
  836. {
  837. pStatic->ShowWindow(TRUE);
  838. }
  839. else
  840. {
  841. pStatic->ShowWindow(FALSE);
  842. }
  843. }
  844. if (!bDoesRecursion)
  845. {
  846. CString szNoRecursionText;
  847. VERIFY(szNoRecursionText.LoadString(IDS_DISABLED_FWDS_NO_RECURSION));
  848. SetDlgItemText(IDC_STATIC_CAPTION, szNoRecursionText);
  849. }
  850. GetDlgItem(IDC_DOMAIN_LIST)->EnableWindow(FALSE);
  851. GetDlgItem(IDC_LIST)->EnableWindow(FALSE);
  852. GetDlgItem(IDC_DOMAIN_REMOVE_BUTTON)->EnableWindow(FALSE);
  853. m_forwarderAddressesEditor.EnableUI(FALSE);
  854. }
  855. BOOL CDNSServer_DomainForwardersPropertyPage::OnSetActive()
  856. {
  857. CDNSServerPropertyPageHolder* pHolder =
  858. (CDNSServerPropertyPageHolder*)GetHolder();
  859. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  860. BOOL bWasDirty = IsDirty();
  861. BOOL bServerHasRoot = FALSE;
  862. DNS_STATUS err = ServerHasRootZone(pServerNode->GetRPCName(), &bServerHasRoot);
  863. if (err == ERROR_SUCCESS && (bServerHasRoot || !pServerNode->DoesRecursion()))
  864. {
  865. SetPageReadOnly(bServerHasRoot, pServerNode->DoesRecursion());
  866. }
  867. else
  868. {
  869. m_bPageReadOnly = FALSE;
  870. //
  871. // clear the root hints message text
  872. //
  873. SetDlgItemText(IDC_STATIC_MESSAGE, NULL);
  874. //
  875. // Enable all the controls
  876. //
  877. EnableWindow(TRUE);
  878. EnableDialogControls(m_hWnd, TRUE);
  879. //
  880. // Get the domain forwarders info from hidden Category node
  881. //
  882. CDNSDomainForwardersNode* pDomainForwardersNode = pServerNode->GetDomainForwardersNode();
  883. if (pDomainForwardersNode == NULL)
  884. {
  885. ASSERT(FALSE);
  886. //
  887. // Disable all controls
  888. //
  889. SetDlgItemText(IDC_STATIC_MESSAGE, NULL);
  890. EnableWindow(FALSE);
  891. EnableDialogControls(m_hWnd, FALSE);
  892. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_ADD_FORWARDERS);
  893. if (pStatic != NULL)
  894. {
  895. pStatic->ShowWindow(FALSE);
  896. }
  897. pStatic = (CStatic*)GetDlgItem(IDC_STATIC_MESSAGE);
  898. if (pStatic != NULL)
  899. {
  900. if (bServerHasRoot)
  901. {
  902. pStatic->ShowWindow(TRUE);
  903. }
  904. else
  905. {
  906. pStatic->ShowWindow(FALSE);
  907. }
  908. }
  909. return TRUE;
  910. }
  911. CStatic* pStatic = (CStatic*)GetDlgItem(IDC_STATIC_MESSAGE);
  912. if (pStatic != NULL)
  913. {
  914. pStatic->EnableWindow(FALSE);
  915. pStatic->ShowWindow(FALSE);
  916. }
  917. pStatic = (CStatic*)GetDlgItem(IDC_STATIC_ADD_FORWARDERS);
  918. if (pStatic != NULL)
  919. {
  920. pStatic->EnableWindow(TRUE);
  921. pStatic->ShowWindow(TRUE);
  922. }
  923. if (!m_bPostApply)
  924. {
  925. LRESULT lSelection = SendDlgItemMessage(IDC_DOMAIN_LIST, LB_GETCURSEL, 0, 0);
  926. if (lSelection == LB_ERR)
  927. {
  928. //
  929. // Select the first item in the domain list
  930. //
  931. SendDlgItemMessage(IDC_DOMAIN_LIST, LB_SETCURSEL, 0, 0);
  932. OnDomainSelChange();
  933. }
  934. }
  935. m_forwarderAddressesEditor.EnableUI(TRUE);
  936. }
  937. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  938. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  939. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER))
  940. {
  941. //
  942. // Domain forwarding not available on pre-Whistler servers
  943. //
  944. if (!bServerHasRoot && pServerNode->DoesRecursion())
  945. {
  946. CString szDownlevelServer;
  947. VERIFY(szDownlevelServer.LoadString(IDS_DISABLED_FWDS_DOWNLEVEL));
  948. SetDlgItemText(IDC_STATIC_CAPTION, szDownlevelServer);
  949. }
  950. GetDlgItem(IDC_DOMAIN_ADD_BUTTON)->EnableWindow(FALSE);
  951. GetDlgItem(IDC_DOMAIN_REMOVE_BUTTON)->EnableWindow(FALSE);
  952. }
  953. OnDomainSelChange();
  954. SetDirty(bWasDirty);
  955. return TRUE;
  956. }
  957. BOOL CDNSServer_DomainForwardersPropertyPage::OnKillActive()
  958. {
  959. OnDomainSelChange();
  960. return TRUE;
  961. }
  962. BOOL CDNSServer_DomainForwardersPropertyPage::OnApply()
  963. {
  964. USES_CONVERSION;
  965. CDNSServerPropertyPageHolder* pHolder =
  966. (CDNSServerPropertyPageHolder*)GetHolder();
  967. CComponentDataObject* pComponentData = pHolder->GetComponentData();
  968. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  969. if (!IsDirty())
  970. {
  971. return TRUE;
  972. }
  973. //
  974. // Retrieve the current UI info
  975. //
  976. CListBox* pDomainList = (CListBox*)GetDlgItem(IDC_DOMAIN_LIST);
  977. if (pDomainList != NULL)
  978. {
  979. int iSel = pDomainList->GetCurSel();
  980. if (iSel != LB_ERR)
  981. {
  982. LRESULT lRes = pDomainList->GetItemData(iSel);
  983. if (lRes != LB_ERR)
  984. {
  985. //
  986. // Retrieve the edit info from the list box item
  987. //
  988. CDomainForwardersEditInfo* pInfo = reinterpret_cast<CDomainForwardersEditInfo*>(lRes);
  989. if (pInfo != NULL)
  990. {
  991. //
  992. // Store the previous selection's data before changing the UI.
  993. // This may be NULL during OnInitDialog so check before trying
  994. // to store the info.
  995. //
  996. if (m_pCurrentInfo != NULL)
  997. {
  998. BOOL bSlave = GetSlaveCheck()->GetCheck();
  999. DWORD dwTimeout = m_forwardTimeoutEdit.GetVal();
  1000. DWORD cAddrCount = m_forwarderAddressesEditor.GetCount();
  1001. DWORD* pArr = (cAddrCount > 0) ? (DWORD*) malloc(sizeof(DWORD)*cAddrCount) : NULL;
  1002. if (cAddrCount > 0 && pArr != NULL)
  1003. {
  1004. int nFilled = 0;
  1005. m_forwarderAddressesEditor.GetAddresses(pArr, cAddrCount, &nFilled);
  1006. ASSERT(nFilled == (int)cAddrCount);
  1007. }
  1008. m_pCurrentInfo->Update(bSlave, dwTimeout, cAddrCount, pArr);
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. POSITION pos = m_EditList.GetHeadPosition();
  1015. while (pos != NULL)
  1016. {
  1017. CDomainForwardersEditInfo* pInfo = m_EditList.GetNext(pos);
  1018. if (pInfo != NULL)
  1019. {
  1020. DNS_STATUS err = 0;
  1021. CString szName;
  1022. pInfo->GetDomainName(szName);
  1023. DWORD cAddrCount = 0;
  1024. PIP_ADDRESS pipAddrs = pInfo->GetIPList(&cAddrCount);
  1025. DWORD dwTimeout = pInfo->GetTimeout();
  1026. BOOL bSlave = pInfo->IsSlave();
  1027. switch (pInfo->GetAction())
  1028. {
  1029. case CDomainForwardersEditInfo::add:
  1030. {
  1031. //
  1032. // Add the new domain forwarder as a zone
  1033. //
  1034. ASSERT(!pInfo->IsAllOthers());
  1035. if (!pInfo->IsAllOthers())
  1036. {
  1037. // Every domain that is entered must contain at least
  1038. // one IP address of a server to forward to
  1039. if (cAddrCount < 1)
  1040. {
  1041. CString err;
  1042. err.Format(IDS_ERRMSG_SERVER_FORWARDER_NO_SERVER, szName);
  1043. DNSMessageBox(err, MB_OK);
  1044. return FALSE;
  1045. }
  1046. else
  1047. {
  1048. err = pServerNode->CreateForwarderZone(szName,
  1049. pipAddrs,
  1050. cAddrCount,
  1051. dwTimeout,
  1052. bSlave,
  1053. pComponentData);
  1054. }
  1055. }
  1056. }
  1057. break;
  1058. case CDomainForwardersEditInfo::remove:
  1059. {
  1060. //
  1061. // Delete the zone representing the domain forwarder
  1062. //
  1063. ASSERT(!pInfo->IsAllOthers());
  1064. if (!pInfo->IsAllOthers())
  1065. {
  1066. BOOL bDeleteFromDS = FALSE;
  1067. if (pInfo->GetZoneNode())
  1068. {
  1069. if (pInfo->GetZoneNode()->GetZoneType() == DNS_ZONE_TYPE_FORWARDER &&
  1070. pInfo->IsADIntegrated())
  1071. {
  1072. if (pServerNode->GetBootMethod() == BOOT_METHOD_DIRECTORY)
  1073. {
  1074. // ask confirmation on delete from DS
  1075. int nRetVal = DNSMessageBox(IDS_MSG_FORWARDER_DELETE_FROM_DS_BOOT3,
  1076. MB_YESNO | MB_DEFBUTTON2);
  1077. if (nRetVal == IDNO)
  1078. {
  1079. break;
  1080. }
  1081. bDeleteFromDS = TRUE;
  1082. }
  1083. else
  1084. {
  1085. // ask confirmation on delete from DS
  1086. int nRetVal = DNSMessageBox(IDS_MSG_FORWARDER_DELETE_FROM_DS,
  1087. MB_YESNOCANCEL | MB_DEFBUTTON3);
  1088. if (nRetVal == IDCANCEL)
  1089. {
  1090. break;
  1091. }
  1092. bDeleteFromDS = (nRetVal == IDYES);
  1093. }
  1094. }
  1095. err = pInfo->GetZoneNode()->Delete(bDeleteFromDS);
  1096. }
  1097. else
  1098. {
  1099. // We don't have to worry about AD integrated forwarders
  1100. // here because we cannot create them in the UI. Any
  1101. // forwarders that are AD integrated will have the zone
  1102. // node pointer set
  1103. err = ::DnssrvDeleteZone(pServerNode->GetRPCName(),
  1104. W_TO_UTF8(szName));
  1105. }
  1106. }
  1107. }
  1108. break;
  1109. case CDomainForwardersEditInfo::update:
  1110. {
  1111. //
  1112. // Update the zone representing the domain forwarder
  1113. //
  1114. if (pInfo->IsAllOthers())
  1115. {
  1116. //
  1117. // write the default forwarder to the server
  1118. //
  1119. err = pServerNode->ResetForwarders(cAddrCount, pipAddrs, dwTimeout, bSlave);
  1120. // NTRAID#NTBUG9-726992-2002/10/22-JeffJon
  1121. // The ResetForwarders call will update the ServerInfo which means that the existing
  1122. // pInfo is no longer valid so recreate it from the server info.
  1123. m_EditList.Remove(pInfo);
  1124. if (m_pCurrentInfo == pInfo)
  1125. {
  1126. m_pCurrentInfo = NULL;
  1127. }
  1128. delete pInfo;
  1129. pInfo = 0;
  1130. m_pCurrentInfo = CreateAllOthersDomainInfo(pServerNode);
  1131. // Now update the domain list data with the new AllOthersDomain
  1132. LRESULT currentSelection = pDomainList->GetCurSel();
  1133. pDomainList->SetItemData(currentSelection, (LPARAM)m_pCurrentInfo);
  1134. }
  1135. else
  1136. {
  1137. err = ::DnssrvResetZoneMastersEx(pServerNode->GetRPCName(), // server name
  1138. W_TO_UTF8(szName), // forwarder as zone name
  1139. cAddrCount,
  1140. pipAddrs,
  1141. 0); // global masters only
  1142. DNS_STATUS err2 = ::DnssrvResetDwordProperty(pServerNode->GetRPCName(),
  1143. W_TO_UTF8(szName),
  1144. DNS_REGKEY_ZONE_FWD_TIMEOUT,
  1145. dwTimeout);
  1146. DNS_STATUS err3 = ::DnssrvResetDwordProperty(pServerNode->GetRPCName(),
  1147. W_TO_UTF8(szName),
  1148. DNS_REGKEY_ZONE_FWD_SLAVE,
  1149. bSlave);
  1150. if (!err && err2)
  1151. {
  1152. err = err2;
  1153. }
  1154. if (!err && err3)
  1155. {
  1156. err = err3;
  1157. }
  1158. }
  1159. }
  1160. break;
  1161. case CDomainForwardersEditInfo::nochange:
  1162. default:
  1163. break;
  1164. }
  1165. if (err != 0)
  1166. {
  1167. if (err == DNS_ERROR_INVALID_ZONE_TYPE)
  1168. {
  1169. CString szFwdFailed;
  1170. CString szFwdFailedFormat;
  1171. VERIFY(szFwdFailedFormat.LoadString(IDS_MSG_FAIL_CREATE_DOMAIN_FORWARDER));
  1172. szFwdFailed.Format(szFwdFailedFormat, szName);
  1173. DNSMessageBox(szFwdFailed);
  1174. }
  1175. else
  1176. {
  1177. DNSErrorDialog(err, IDS_MSG_SERVER_FORWARDER_UPDATE_FAILED);
  1178. }
  1179. return FALSE;
  1180. }
  1181. if (pInfo)
  1182. {
  1183. pInfo->SetAction(CDomainForwardersEditInfo::nochange);
  1184. }
  1185. }
  1186. } // while
  1187. m_bPostApply = TRUE;
  1188. SetDirty(FALSE);
  1189. return TRUE;
  1190. }
  1191. ///////////////////////////////////////////////////////////////////////////////
  1192. // CDNSServer_AdvancedPropertyPage
  1193. BEGIN_MESSAGE_MAP(CDNSServer_AdvancedPropertyPage, CPropertyPageBase)
  1194. ON_CLBN_CHKCHANGE(IDC_ADVANCED_OPTIONS_LIST, OnAdvancedOptionsListChange)
  1195. ON_CBN_SELCHANGE(IDC_NAME_CHECKING_COMBO, OnComboSelChange)
  1196. ON_CBN_SELCHANGE(IDC_BOOT_METHOD_COMBO, OnComboSelChange)
  1197. ON_BN_CLICKED(IDC_RESET_BUTTON, OnResetButton)
  1198. ON_BN_CLICKED(IDC_CHECK_ENABLE_SCAVENGING, OnEnableScavenging)
  1199. END_MESSAGE_MAP()
  1200. #define ADVANCED_OPTIONS_LISTBOX_ENTRIES (SERVER_REGKEY_ARR_SIZE)
  1201. // boot method constants
  1202. #define BOOT_METHOD_COMBO_ITEM_COUNT 3 // # of options in the combo box
  1203. #define BOOT_METHOD_COMBO_FROM_REGISTRY 0
  1204. #define BOOT_METHOD_COMBO_FROM_FILE 1
  1205. #define BOOT_METHOD_COMBO_FROM_DIRECTORY 2
  1206. #define CHECK_NAMES_COMBO_ITEM_COUNT 4
  1207. CDNSServer_AdvancedPropertyPage::CDNSServer_AdvancedPropertyPage()
  1208. : CPropertyPageBase(IDD_SERVER_ADVANCED_PAGE),
  1209. m_advancedOptionsListBox(ADVANCED_OPTIONS_LISTBOX_ENTRIES)
  1210. {
  1211. }
  1212. void CDNSServer_AdvancedPropertyPage::SetAdvancedOptionsListbox(BOOL* bRegKeyOptionsArr)
  1213. {
  1214. m_advancedOptionsListBox.SetArrValue((DWORD*)bRegKeyOptionsArr,
  1215. ADVANCED_OPTIONS_LISTBOX_ENTRIES);
  1216. }
  1217. void CDNSServer_AdvancedPropertyPage::GetAdvancedOptionsListbox(BOOL* bRegKeyOptionsArr)
  1218. {
  1219. m_advancedOptionsListBox.GetArrValue((DWORD*)bRegKeyOptionsArr,
  1220. ADVANCED_OPTIONS_LISTBOX_ENTRIES);
  1221. }
  1222. void CDNSServer_AdvancedPropertyPage::SetBootMethodComboVal(UCHAR fBootMethod)
  1223. {
  1224. int nIndex = BOOT_METHOD_COMBO_FROM_DIRECTORY; // sensible default
  1225. switch (fBootMethod)
  1226. {
  1227. case BOOT_METHOD_FILE:
  1228. nIndex = BOOT_METHOD_COMBO_FROM_FILE;
  1229. break;
  1230. case BOOT_METHOD_REGISTRY:
  1231. nIndex = BOOT_METHOD_COMBO_FROM_REGISTRY;
  1232. break;
  1233. case BOOT_METHOD_DIRECTORY:
  1234. nIndex = BOOT_METHOD_COMBO_FROM_DIRECTORY;
  1235. break;
  1236. default:
  1237. nIndex = BOOT_METHOD_COMBO_FROM_DIRECTORY;
  1238. break;
  1239. };
  1240. VERIFY(CB_ERR != GetBootMethodCombo()->SetCurSel(nIndex));
  1241. }
  1242. UCHAR CDNSServer_AdvancedPropertyPage::GetBootMethodComboVal()
  1243. {
  1244. int nIndex = BOOT_METHOD_COMBO_FROM_DIRECTORY;
  1245. nIndex = GetBootMethodCombo()->GetCurSel();
  1246. ASSERT(nIndex != CB_ERR);
  1247. UCHAR fBootMethod = BOOT_METHOD_DIRECTORY; // sensible default
  1248. switch (nIndex)
  1249. {
  1250. case BOOT_METHOD_COMBO_FROM_FILE:
  1251. fBootMethod = BOOT_METHOD_FILE;
  1252. break;
  1253. case BOOT_METHOD_COMBO_FROM_REGISTRY:
  1254. fBootMethod = BOOT_METHOD_REGISTRY;
  1255. break;
  1256. case BOOT_METHOD_COMBO_FROM_DIRECTORY:
  1257. fBootMethod = BOOT_METHOD_DIRECTORY;
  1258. break;
  1259. default:
  1260. ASSERT(FALSE);
  1261. };
  1262. return fBootMethod;
  1263. }
  1264. void CDNSServer_AdvancedPropertyPage::SetNameCheckingComboVal(DWORD dwNameChecking)
  1265. {
  1266. int nIndex = DNS_DEFAULT_NAME_CHECK_FLAG;
  1267. switch (dwNameChecking)
  1268. {
  1269. case DNS_ALLOW_RFC_NAMES_ONLY:
  1270. nIndex = 0;
  1271. break;
  1272. case DNS_ALLOW_NONRFC_NAMES:
  1273. nIndex = 1;
  1274. break;
  1275. case DNS_ALLOW_MULTIBYTE_NAMES:
  1276. nIndex = 2;
  1277. break;
  1278. case DNS_ALLOW_ALL_NAMES:
  1279. nIndex = 3;
  1280. break;
  1281. default:
  1282. ASSERT(FALSE);
  1283. }
  1284. VERIFY(CB_ERR != GetNameCheckingCombo()->SetCurSel(nIndex));
  1285. }
  1286. DWORD CDNSServer_AdvancedPropertyPage::GetNameCheckingComboVal()
  1287. {
  1288. int nIndex = 0;
  1289. nIndex = GetNameCheckingCombo()->GetCurSel();
  1290. ASSERT(nIndex != CB_ERR);
  1291. DWORD dw = 0;
  1292. switch (nIndex)
  1293. {
  1294. case 0:
  1295. dw = DNS_ALLOW_RFC_NAMES_ONLY;
  1296. break;
  1297. case 1:
  1298. dw = DNS_ALLOW_NONRFC_NAMES;
  1299. break;
  1300. case 2:
  1301. dw = DNS_ALLOW_MULTIBYTE_NAMES;
  1302. break;
  1303. case 3:
  1304. dw = DNS_ALLOW_ALL_NAMES;
  1305. break;
  1306. default:
  1307. ASSERT(FALSE);
  1308. }
  1309. return dw;
  1310. }
  1311. void CDNSServer_AdvancedPropertyPage::OnEnableScavenging()
  1312. {
  1313. GetDlgItem(IDC_STATIC_SCAVENGE)->EnableWindow(((CButton*)GetDlgItem(IDC_CHECK_ENABLE_SCAVENGING))->GetCheck());
  1314. GetDlgItem(IDC_REFR_INT_EDIT)->EnableWindow(((CButton*)GetDlgItem(IDC_CHECK_ENABLE_SCAVENGING))->GetCheck());
  1315. GetDlgItem(IDC_REFR_INT_COMBO)->EnableWindow(((CButton*)GetDlgItem(IDC_CHECK_ENABLE_SCAVENGING))->GetCheck());
  1316. if (m_scavengingIntervalEditGroup.GetVal() == 0)
  1317. {
  1318. m_scavengingIntervalEditGroup.SetVal(DNS_DEFAULT_SCAVENGING_INTERVAL_ON);
  1319. }
  1320. SetDirty(TRUE);
  1321. }
  1322. void CDNSServer_AdvancedPropertyPage::SetUIData()
  1323. {
  1324. CDNSServerPropertyPageHolder* pHolder =
  1325. (CDNSServerPropertyPageHolder*)GetHolder();
  1326. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  1327. // set server version
  1328. CEdit* pVersionEdit = (CEdit*)GetDlgItem(IDC_SERVER_VERSION_EDIT);
  1329. WCHAR szBuffer[128];
  1330. WORD wBuildNumber = pServerNode->GetBuildNumber();
  1331. if (wBuildNumber == 0)
  1332. wsprintf(szBuffer, _T("%d.%d"), pServerNode->GetMajorVersion(),
  1333. pServerNode->GetMinorVersion());
  1334. else
  1335. wsprintf(szBuffer, _T("%d.%d %d (0x%x)"), pServerNode->GetMajorVersion(),
  1336. pServerNode->GetMinorVersion(),
  1337. wBuildNumber, wBuildNumber);
  1338. pVersionEdit->SetWindowText(szBuffer);
  1339. // NOTICE: Assume ordering in the list is the same
  1340. // as in the array. "Name check Flag" and "Boot method" are the last ones
  1341. // in the array and are ignored (separate controls).
  1342. BOOL bRegKeyOptionsArr[SERVER_REGKEY_ARR_SIZE];
  1343. pServerNode->GetAdvancedOptions(bRegKeyOptionsArr);
  1344. SetAdvancedOptionsListbox(bRegKeyOptionsArr);
  1345. SetBootMethodComboVal(pServerNode->GetBootMethod());
  1346. SetNameCheckingComboVal(pServerNode->GetNameCheckFlag());
  1347. ((CButton*)GetDlgItem(IDC_CHECK_ENABLE_SCAVENGING))->SetCheck(pServerNode->GetScavengingState());
  1348. GetDlgItem(IDC_STATIC_SCAVENGE)->EnableWindow(pServerNode->GetScavengingState());
  1349. GetDlgItem(IDC_REFR_INT_EDIT)->EnableWindow(pServerNode->GetScavengingState());
  1350. GetDlgItem(IDC_REFR_INT_COMBO)->EnableWindow(pServerNode->GetScavengingState());
  1351. m_scavengingIntervalEditGroup.SetVal(pServerNode->GetScavengingInterval());
  1352. }
  1353. BOOL CDNSServer_AdvancedPropertyPage::OnInitDialog()
  1354. {
  1355. CPropertyPageBase::OnInitDialog();
  1356. CDNSServerPropertyPageHolder* pHolder =
  1357. (CDNSServerPropertyPageHolder*)GetHolder();
  1358. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  1359. VERIFY(m_advancedOptionsListBox.Initialize(IDC_ADVANCED_OPTIONS_LIST,
  1360. IDS_SERVER_ADV_PP_OPTIONS,
  1361. this));
  1362. VERIFY(LoadStringsToComboBox(_Module.GetModuleInstance(),
  1363. GetNameCheckingCombo(),
  1364. IDS_SERVER_NAME_CHECKING_OPTIONS,
  1365. 256,
  1366. CHECK_NAMES_COMBO_ITEM_COUNT));
  1367. VERIFY(LoadStringsToComboBox(_Module.GetModuleInstance(),
  1368. GetBootMethodCombo(),
  1369. IDS_SERVER_BOOT_METHOD_OPTIONS,
  1370. 256,
  1371. BOOT_METHOD_COMBO_ITEM_COUNT));
  1372. if (!pServerNode->HasServerInfo())
  1373. {
  1374. EnableWindow(FALSE);
  1375. return TRUE;
  1376. }
  1377. m_scavengingIntervalEditGroup.m_pPage2 = this;
  1378. VERIFY(m_scavengingIntervalEditGroup.Initialize(this,
  1379. IDC_REFR_INT_EDIT, IDC_REFR_INT_COMBO,IDS_TIME_AGING_INTERVAL_UNITS));
  1380. SetUIData();
  1381. return TRUE; // return TRUE unless you set the focus to a control
  1382. // EXCEPTION: OCX Property Pages should return FALSE
  1383. }
  1384. BOOL _HandleAvancedOptionsErrors(DNS_STATUS* dwRegKeyOptionsErrorArr)
  1385. {
  1386. BOOL bAllFine = TRUE;
  1387. // check for errors in the array
  1388. for (UINT iKey=0; iKey < SERVER_REGKEY_ARR_SIZE; iKey++)
  1389. {
  1390. if (dwRegKeyOptionsErrorArr[iKey] != 0)
  1391. {
  1392. bAllFine = FALSE;
  1393. break;
  1394. }
  1395. }
  1396. if (bAllFine)
  1397. return TRUE; // no error condition
  1398. // load the string array to get the option key name
  1399. CString szBuf;
  1400. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1401. VERIFY(szBuf.LoadString(IDS_SERVER_ADV_PP_OPTIONS));
  1402. LPWSTR* lpszArr = (LPWSTR*)malloc(sizeof(LPWSTR*)*SERVER_REGKEY_ARR_SIZE);
  1403. if (!lpszArr)
  1404. {
  1405. return FALSE;
  1406. }
  1407. UINT nArrEntries;
  1408. ParseNewLineSeparatedString(szBuf.GetBuffer(1),lpszArr, &nArrEntries);
  1409. szBuf.ReleaseBuffer();
  1410. ASSERT(nArrEntries == SERVER_REGKEY_ARR_SIZE);
  1411. CString szFmt;
  1412. szFmt.LoadString(IDS_MSG_SERVER_FAIL_ADV_PROP_FMT);
  1413. CString szMsg;
  1414. for (iKey=0; iKey < SERVER_REGKEY_ARR_SIZE; iKey++)
  1415. {
  1416. if (dwRegKeyOptionsErrorArr[iKey] != 0)
  1417. {
  1418. szMsg.Format((LPCWSTR)szFmt, lpszArr[iKey]);
  1419. DNSErrorDialog(dwRegKeyOptionsErrorArr[iKey], szMsg);
  1420. }
  1421. }
  1422. if (lpszArr)
  1423. {
  1424. free(lpszArr);
  1425. lpszArr = 0;
  1426. }
  1427. return FALSE; // we had an error condition
  1428. }
  1429. BOOL CDNSServer_AdvancedPropertyPage::OnApply()
  1430. {
  1431. if (!IsDirty())
  1432. return TRUE;
  1433. CDNSServerPropertyPageHolder* pHolder =
  1434. (CDNSServerPropertyPageHolder*)GetHolder();
  1435. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  1436. // get data from the UI
  1437. BOOL bRegKeyOptionsArr[SERVER_REGKEY_ARR_SIZE];
  1438. ZeroMemory(bRegKeyOptionsArr, sizeof(bRegKeyOptionsArr));
  1439. GetAdvancedOptionsListbox(bRegKeyOptionsArr);
  1440. UCHAR fBootMethod = GetBootMethodComboVal();
  1441. DWORD dwNameCheckFlag = GetNameCheckingComboVal();
  1442. BOOL bScavengingState = ((CButton*)GetDlgItem(IDC_CHECK_ENABLE_SCAVENGING))->GetCheck();
  1443. DWORD dwScavengingInterval = m_scavengingIntervalEditGroup.GetVal();
  1444. // write data to the server
  1445. DNS_STATUS dwRegKeyOptionsErrorArr[SERVER_REGKEY_ARR_SIZE];
  1446. ZeroMemory(dwRegKeyOptionsErrorArr, sizeof(dwRegKeyOptionsErrorArr));
  1447. DNS_STATUS dwErr = pServerNode->ResetAdvancedOptions(bRegKeyOptionsArr, dwRegKeyOptionsErrorArr);
  1448. if (dwErr != 0)
  1449. {
  1450. DNSErrorDialog(dwErr, IDS_MSG_SERVER_NO_ADVANCED_OPTIONS);
  1451. return FALSE;
  1452. }
  1453. if (!_HandleAvancedOptionsErrors(dwRegKeyOptionsErrorArr))
  1454. return FALSE;
  1455. dwErr = pServerNode->ResetBootMethod(fBootMethod);
  1456. if (dwErr != 0)
  1457. {
  1458. DNSErrorDialog(dwErr, IDS_MSG_SERVER_NO_BOOT_METHOD);
  1459. return FALSE;
  1460. }
  1461. dwErr = pServerNode->ResetNameCheckFlag(dwNameCheckFlag);
  1462. if (dwErr != 0)
  1463. {
  1464. DNSErrorDialog(dwErr, IDS_MSG_SERVER_NO_NAME_CHECKING);
  1465. return FALSE;
  1466. }
  1467. /*
  1468. dwErr = pServerNode->ResetScavengingState(bScavengingState);
  1469. if (dwErr != 0)
  1470. {
  1471. DNSErrorDialog(dwErr, IDS_MSG_SERVER_SCAVENGING_STATE);
  1472. return FALSE;
  1473. }
  1474. */
  1475. if (bScavengingState)
  1476. {
  1477. dwErr = pServerNode->ResetScavengingInterval(dwScavengingInterval);
  1478. }
  1479. else
  1480. {
  1481. dwErr = pServerNode->ResetScavengingInterval(0);
  1482. }
  1483. if (dwErr != 0)
  1484. {
  1485. DNSErrorDialog(dwErr, IDS_MSG_SERVER_SCAVENGING_INTERVAL);
  1486. return FALSE;
  1487. }
  1488. // all is fine
  1489. SetDirty(FALSE);
  1490. return TRUE;
  1491. }
  1492. void CDNSServer_AdvancedPropertyPage::OnResetButton()
  1493. {
  1494. BOOL bRegKeyOptArrDef[SERVER_REGKEY_ARR_SIZE];
  1495. bRegKeyOptArrDef[SERVER_REGKEY_ARR_INDEX_NO_RECURSION] = DNS_DEFAULT_NO_RECURSION;
  1496. bRegKeyOptArrDef[SERVER_REGKEY_ARR_INDEX_BIND_SECONDARIES] = DNS_DEFAULT_BIND_SECONDARIES;
  1497. bRegKeyOptArrDef[SERVER_REGKEY_ARR_INDEX_STRICT_FILE_PARSING] = DNS_DEFAULT_STRICT_FILE_PARSING;
  1498. bRegKeyOptArrDef[SERVER_REGKEY_ARR_INDEX_ROUND_ROBIN] = DNS_DEFAULT_ROUND_ROBIN;
  1499. bRegKeyOptArrDef[SERVER_REGKEY_ARR_LOCAL_NET_PRIORITY] = DNS_DEFAULT_LOCAL_NET_PRIORITY;
  1500. bRegKeyOptArrDef[SERVER_REGKEY_ARR_CACHE_POLLUTION] = DNS_DEFAULT_SECURE_RESPONSES;
  1501. UCHAR fBootMethod = BOOT_METHOD_DIRECTORY;
  1502. SetAdvancedOptionsListbox(bRegKeyOptArrDef);
  1503. SetBootMethodComboVal(fBootMethod);
  1504. SetNameCheckingComboVal(DNS_DEFAULT_NAME_CHECK_FLAG);
  1505. BOOL bDefaultScavengingState = DNS_DEFAULT_SCAVENGING_INTERVAL > 0;
  1506. ((CButton*)GetDlgItem(IDC_CHECK_ENABLE_SCAVENGING))->SetCheck(bDefaultScavengingState);
  1507. GetDlgItem(IDC_STATIC_SCAVENGE)->EnableWindow(bDefaultScavengingState);
  1508. GetDlgItem(IDC_REFR_INT_EDIT)->EnableWindow(bDefaultScavengingState);
  1509. GetDlgItem(IDC_REFR_INT_COMBO)->EnableWindow(bDefaultScavengingState);
  1510. m_scavengingIntervalEditGroup.SetVal(DNS_DEFAULT_SCAVENGING_INTERVAL);
  1511. SetDirty(TRUE);
  1512. }
  1513. ///////////////////////////////////////////////////////////////////////////////
  1514. // CIPFilterDialog
  1515. class CIPFilterDialog : public CHelpDialog
  1516. {
  1517. public:
  1518. CIPFilterDialog(PIP_ARRAY pIpArray, CComponentDataObject* pComponentData)
  1519. : CHelpDialog(IDD_IP_FILTER_DIALOG, pComponentData),
  1520. m_pIPFilterList(pIpArray),
  1521. m_pComponentData(pComponentData)
  1522. {}
  1523. ~CIPFilterDialog() {}
  1524. virtual BOOL OnInitDialog();
  1525. virtual void OnOK();
  1526. PIP_ARRAY GetIPFilter() { return m_pIPFilterList; }
  1527. virtual void SetDirty(BOOL bDirty = TRUE);
  1528. private:
  1529. class CFilterAddressesIPEditor : public CIPEditor
  1530. {
  1531. public:
  1532. CFilterAddressesIPEditor() : CIPEditor(TRUE) {}
  1533. virtual void OnChangeData();
  1534. };
  1535. CFilterAddressesIPEditor m_filterAddressesEditor;
  1536. PIP_ARRAY m_pIPFilterList;
  1537. CComponentDataObject* m_pComponentData;
  1538. DECLARE_MESSAGE_MAP()
  1539. };
  1540. void CIPFilterDialog::CFilterAddressesIPEditor::OnChangeData()
  1541. {
  1542. //
  1543. // Set the dialog dirty
  1544. //
  1545. CIPFilterDialog* pDialog = (CIPFilterDialog*)GetParentWnd();
  1546. pDialog->SetDirty(TRUE);
  1547. }
  1548. BEGIN_MESSAGE_MAP(CIPFilterDialog, CHelpDialog)
  1549. END_MESSAGE_MAP()
  1550. BOOL CIPFilterDialog::OnInitDialog()
  1551. {
  1552. CHelpDialog::OnInitDialog();
  1553. //
  1554. // initialize controls
  1555. //
  1556. VERIFY(m_filterAddressesEditor.Initialize(this,
  1557. this,
  1558. IDC_BUTTON_UP,
  1559. IDC_BUTTON_DOWN,
  1560. IDC_BUTTON_ADD,
  1561. IDC_BUTTON_REMOVE,
  1562. IDC_IPEDIT,
  1563. IDC_LIST));
  1564. if (m_pIPFilterList != NULL)
  1565. {
  1566. m_filterAddressesEditor.AddAddresses(m_pIPFilterList->AddrArray, m_pIPFilterList->AddrCount);
  1567. }
  1568. SetDirty(FALSE);
  1569. return TRUE;
  1570. }
  1571. void CIPFilterDialog::SetDirty(BOOL bDirty)
  1572. {
  1573. GetDlgItem(IDOK)->EnableWindow(bDirty);
  1574. if (!bDirty)
  1575. {
  1576. // Set the default button to be the Cancel button
  1577. SendMessage(DM_SETDEFID, (WPARAM)IDCANCEL, 0);
  1578. SendDlgItemMessage(IDOK, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE, 0));
  1579. SendDlgItemMessage(IDCANCEL, BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0));
  1580. }
  1581. }
  1582. void CIPFilterDialog::OnOK()
  1583. {
  1584. ULONG cAddress = m_filterAddressesEditor.GetCount();
  1585. PIP_ARRAY aipAddresses = (cAddress > 0) ? (PIP_ARRAY) malloc(sizeof(DWORD)*(cAddress + 1)) : NULL;
  1586. if (aipAddresses != NULL && cAddress > 0)
  1587. {
  1588. int nFilled = 0;
  1589. aipAddresses->AddrCount = cAddress;
  1590. m_filterAddressesEditor.GetAddresses(aipAddresses->AddrArray, cAddress, &nFilled);
  1591. ASSERT(nFilled == (int)cAddress);
  1592. }
  1593. m_pIPFilterList = aipAddresses;
  1594. CHelpDialog::OnOK();
  1595. }
  1596. ///////////////////////////////////////////////////////////////////////////////
  1597. // CDNSServer_DebugLoggingPropertyPage
  1598. BEGIN_MESSAGE_MAP(CDNSServer_DebugLoggingPropertyPage, CPropertyPageBase)
  1599. ON_BN_CLICKED(IDC_DEBUG_LOGGING_CHECK, OnLoggingCheck)
  1600. ON_BN_CLICKED(IDC_SEND_CHECK, OnSendCheck)
  1601. ON_BN_CLICKED(IDC_RECEIVE_CHECK, OnReceiveCheck)
  1602. ON_BN_CLICKED(IDC_QUERIES_CHECK, OnQueriesCheck)
  1603. ON_BN_CLICKED(IDC_NOTIFIES_CHECK, OnNotifiesCheck)
  1604. ON_BN_CLICKED(IDC_UPDATES_CHECK, OnUpdatesCheck)
  1605. ON_BN_CLICKED(IDC_REQUEST_CHECK, OnRequestCheck)
  1606. ON_BN_CLICKED(IDC_RESPONSE_CHECK, OnResponseCheck)
  1607. ON_BN_CLICKED(IDC_UDP_CHECK, OnUDPCheck)
  1608. ON_BN_CLICKED(IDC_TCP_CHECK, OnTCPCheck)
  1609. ON_BN_CLICKED(IDC_DETAIL_CHECK, OnDetailCheck)
  1610. ON_BN_CLICKED(IDC_FILTERING_CHECK, OnFilterCheck)
  1611. ON_BN_CLICKED(IDC_FILTER_BUTTON, OnFilterButton)
  1612. ON_EN_CHANGE(IDC_LOGFILE_EDIT, OnLogFileChange)
  1613. ON_EN_CHANGE(IDC_MAX_SIZE_EDIT, OnMaxSizeChange)
  1614. END_MESSAGE_MAP()
  1615. CDNSServer_DebugLoggingPropertyPage::CDNSServer_DebugLoggingPropertyPage()
  1616. : CPropertyPageBase(IDD_SERVER_DEBUG_LOGGING_PAGE),
  1617. m_dwLogLevel(0),
  1618. m_pIPFilterList(NULL),
  1619. m_dwMaxSize(0),
  1620. m_bOnSetUIData(FALSE),
  1621. m_bMaxSizeDirty(FALSE),
  1622. m_bLogFileDirty(FALSE),
  1623. m_bFilterDirty(FALSE),
  1624. m_bOwnIPListMemory(FALSE),
  1625. m_bNotWhistler(FALSE),
  1626. m_bOptionsDirty(FALSE)
  1627. {
  1628. m_szLogFileName = L"";
  1629. }
  1630. CDNSServer_DebugLoggingPropertyPage::~CDNSServer_DebugLoggingPropertyPage()
  1631. {
  1632. if (m_bOwnIPListMemory && m_pIPFilterList != NULL)
  1633. {
  1634. free(m_pIPFilterList);
  1635. m_pIPFilterList = NULL;
  1636. }
  1637. }
  1638. typedef struct _LoggingOption
  1639. {
  1640. DWORD dwOption;
  1641. UINT nControlID;
  1642. } LOGGING_OPTION, *PLOGGING_OPTION;
  1643. //
  1644. // NOTE: if the resource IDs of the checkboxes are changed,
  1645. // then the IDs in the table below need to be changed too.
  1646. //
  1647. LOGGING_OPTION g_loggingOptions[] =
  1648. {
  1649. { DNS_LOG_LEVEL_QUERY, IDC_QUERIES_CHECK },
  1650. { DNS_LOG_LEVEL_NOTIFY, IDC_NOTIFIES_CHECK },
  1651. { DNS_LOG_LEVEL_UPDATE, IDC_UPDATES_CHECK },
  1652. { DNS_LOG_LEVEL_QUESTIONS, IDC_REQUEST_CHECK },
  1653. { DNS_LOG_LEVEL_ANSWERS, IDC_RESPONSE_CHECK },
  1654. { DNS_LOG_LEVEL_SEND, IDC_SEND_CHECK },
  1655. { DNS_LOG_LEVEL_RECV, IDC_RECEIVE_CHECK },
  1656. { DNS_LOG_LEVEL_UDP, IDC_UDP_CHECK },
  1657. { DNS_LOG_LEVEL_TCP, IDC_TCP_CHECK },
  1658. { DNS_LOG_LEVEL_FULL_PACKETS, IDC_DETAIL_CHECK }
  1659. };
  1660. #define DEFAULT_LOGGING_OPTIONS (DNS_LOG_LEVEL_SEND | \
  1661. DNS_LOG_LEVEL_RECV | \
  1662. DNS_LOG_LEVEL_UDP | \
  1663. DNS_LOG_LEVEL_TCP | \
  1664. DNS_LOG_LEVEL_QUERY | \
  1665. DNS_LOG_LEVEL_UPDATE | \
  1666. DNS_LOG_LEVEL_QUESTIONS | \
  1667. DNS_LOG_LEVEL_ANSWERS )
  1668. void CDNSServer_DebugLoggingPropertyPage::OnLoggingCheck()
  1669. {
  1670. BOOL bLogging = SendDlgItemMessage(IDC_DEBUG_LOGGING_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1671. EnableLogging(bLogging);
  1672. if (bLogging &&
  1673. m_dwLogLevel == 0 &&
  1674. !AreOptionsDirty())
  1675. {
  1676. ResetToDefaults();
  1677. }
  1678. SetDirty(TRUE);
  1679. }
  1680. void CDNSServer_DebugLoggingPropertyPage::OnSendCheck()
  1681. {
  1682. BOOL bOutgoing = SendDlgItemMessage(IDC_SEND_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1683. BOOL bIncoming = SendDlgItemMessage(IDC_RECEIVE_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1684. if (!bOutgoing && !bIncoming)
  1685. {
  1686. SendDlgItemMessage(IDC_RECEIVE_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1687. GetDlgItem(IDC_RECEIVE_CHECK)->SetFocus();
  1688. }
  1689. SetOptionsDirty();
  1690. SetDirty(TRUE);
  1691. }
  1692. void CDNSServer_DebugLoggingPropertyPage::OnReceiveCheck()
  1693. {
  1694. BOOL bOutgoing = SendDlgItemMessage(IDC_SEND_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1695. BOOL bIncoming = SendDlgItemMessage(IDC_RECEIVE_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1696. if (!bOutgoing && !bIncoming)
  1697. {
  1698. SendDlgItemMessage(IDC_SEND_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1699. GetDlgItem(IDC_SEND_CHECK)->SetFocus();
  1700. }
  1701. SetOptionsDirty();
  1702. SetDirty(TRUE);
  1703. }
  1704. void CDNSServer_DebugLoggingPropertyPage::OnQueriesCheck()
  1705. {
  1706. BOOL bQueries = SendDlgItemMessage(IDC_QUERIES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1707. BOOL bNotifies = SendDlgItemMessage(IDC_NOTIFIES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1708. BOOL bUpdates = SendDlgItemMessage(IDC_UPDATES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1709. if (!bQueries && !bNotifies && !bUpdates)
  1710. {
  1711. SendDlgItemMessage(IDC_UPDATES_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1712. GetDlgItem(IDC_UPDATES_CHECK)->SetFocus();
  1713. }
  1714. SetOptionsDirty();
  1715. SetDirty(TRUE);
  1716. }
  1717. void CDNSServer_DebugLoggingPropertyPage::OnUpdatesCheck()
  1718. {
  1719. BOOL bQueries = SendDlgItemMessage(IDC_QUERIES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1720. BOOL bNotifies = SendDlgItemMessage(IDC_NOTIFIES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1721. BOOL bUpdates = SendDlgItemMessage(IDC_UPDATES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1722. if (!bQueries && !bNotifies && !bUpdates)
  1723. {
  1724. SendDlgItemMessage(IDC_NOTIFIES_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1725. GetDlgItem(IDC_NOTIFIES_CHECK)->SetFocus();
  1726. }
  1727. SetOptionsDirty();
  1728. SetDirty(TRUE);
  1729. }
  1730. void CDNSServer_DebugLoggingPropertyPage::OnNotifiesCheck()
  1731. {
  1732. BOOL bQueries = SendDlgItemMessage(IDC_QUERIES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1733. BOOL bNotifies = SendDlgItemMessage(IDC_NOTIFIES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1734. BOOL bUpdates = SendDlgItemMessage(IDC_UPDATES_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1735. if (!bQueries && !bNotifies && !bUpdates)
  1736. {
  1737. SendDlgItemMessage(IDC_QUERIES_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1738. GetDlgItem(IDC_QUERIES_CHECK)->SetFocus();
  1739. }
  1740. SetOptionsDirty();
  1741. SetDirty(TRUE);
  1742. }
  1743. void CDNSServer_DebugLoggingPropertyPage::OnRequestCheck()
  1744. {
  1745. BOOL bRequest = SendDlgItemMessage(IDC_REQUEST_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1746. BOOL bResponse = SendDlgItemMessage(IDC_RESPONSE_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1747. if (!bRequest && !bResponse)
  1748. {
  1749. SendDlgItemMessage(IDC_RESPONSE_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1750. GetDlgItem(IDC_RESPONSE_CHECK)->SetFocus();
  1751. }
  1752. SetOptionsDirty();
  1753. SetDirty(TRUE);
  1754. }
  1755. void CDNSServer_DebugLoggingPropertyPage::OnResponseCheck()
  1756. {
  1757. BOOL bRequest = SendDlgItemMessage(IDC_REQUEST_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1758. BOOL bResponse = SendDlgItemMessage(IDC_RESPONSE_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1759. if (!bRequest && !bResponse)
  1760. {
  1761. SendDlgItemMessage(IDC_REQUEST_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1762. GetDlgItem(IDC_REQUEST_CHECK)->SetFocus();
  1763. }
  1764. SetOptionsDirty();
  1765. SetDirty(TRUE);
  1766. }
  1767. void CDNSServer_DebugLoggingPropertyPage::OnUDPCheck()
  1768. {
  1769. BOOL bUDP = SendDlgItemMessage(IDC_UDP_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1770. BOOL bTCP = SendDlgItemMessage(IDC_TCP_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1771. if (!bUDP && !bTCP)
  1772. {
  1773. SendDlgItemMessage(IDC_TCP_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1774. GetDlgItem(IDC_TCP_CHECK)->SetFocus();
  1775. }
  1776. SetOptionsDirty();
  1777. SetDirty(TRUE);
  1778. }
  1779. void CDNSServer_DebugLoggingPropertyPage::OnTCPCheck()
  1780. {
  1781. BOOL bUDP = SendDlgItemMessage(IDC_UDP_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1782. BOOL bTCP = SendDlgItemMessage(IDC_TCP_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED;
  1783. if (!bUDP && !bTCP)
  1784. {
  1785. SendDlgItemMessage(IDC_UDP_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1786. GetDlgItem(IDC_UDP_CHECK)->SetFocus();
  1787. }
  1788. SetOptionsDirty();
  1789. SetDirty(TRUE);
  1790. }
  1791. void CDNSServer_DebugLoggingPropertyPage::OnDetailCheck()
  1792. {
  1793. SetOptionsDirty();
  1794. SetDirty(TRUE);
  1795. }
  1796. void CDNSServer_DebugLoggingPropertyPage::SetOptionsDirty(BOOL bDirty)
  1797. {
  1798. m_bOptionsDirty = bDirty;
  1799. }
  1800. BOOL CDNSServer_DebugLoggingPropertyPage::AreOptionsDirty()
  1801. {
  1802. return m_bOptionsDirty;
  1803. }
  1804. void CDNSServer_DebugLoggingPropertyPage::EnableLogging(BOOL bEnable)
  1805. {
  1806. //
  1807. // NOTE: the curly brace icons must be enabled before
  1808. // the other controls so that they get painted first
  1809. // and the other controls can paint over top of them
  1810. // If not, the text of the controls gets cut off
  1811. //
  1812. GetDlgItem(IDC_BRACE1_STATIC)->EnableWindow(bEnable);
  1813. GetDlgItem(IDC_SELECT1_STATIC)->EnableWindow(bEnable);
  1814. GetDlgItem(IDC_BRACE2_STATIC)->EnableWindow(bEnable);
  1815. GetDlgItem(IDC_SELECT2_STATIC)->EnableWindow(bEnable);
  1816. GetDlgItem(IDC_BRACE3_STATIC)->EnableWindow(bEnable);
  1817. GetDlgItem(IDC_SELECT3_STATIC)->EnableWindow(bEnable);
  1818. GetDlgItem(IDC_BRACE4_STATIC)->EnableWindow(bEnable);
  1819. GetDlgItem(IDC_SELECT4_STATIC)->EnableWindow(bEnable);
  1820. GetDlgItem(IDC_DIRECTION_STATIC)->EnableWindow(bEnable);
  1821. GetDlgItem(IDC_SEND_CHECK)->EnableWindow(bEnable);
  1822. GetDlgItem(IDC_RECEIVE_CHECK)->EnableWindow(bEnable);
  1823. GetDlgItem(IDC_CONTENTS_STATIC)->EnableWindow(bEnable);
  1824. GetDlgItem(IDC_QUERIES_CHECK)->EnableWindow(bEnable);
  1825. GetDlgItem(IDC_NOTIFIES_CHECK)->EnableWindow(bEnable);
  1826. GetDlgItem(IDC_UPDATES_CHECK)->EnableWindow(bEnable);
  1827. GetDlgItem(IDC_TRANSPORT_STATIC)->EnableWindow(bEnable);
  1828. GetDlgItem(IDC_UDP_CHECK)->EnableWindow(bEnable);
  1829. GetDlgItem(IDC_TCP_CHECK)->EnableWindow(bEnable);
  1830. GetDlgItem(IDC_TYPE_STATIC)->EnableWindow(bEnable);
  1831. GetDlgItem(IDC_REQUEST_CHECK)->EnableWindow(bEnable);
  1832. GetDlgItem(IDC_RESPONSE_CHECK)->EnableWindow(bEnable);
  1833. GetDlgItem(IDC_OPTIONS_STATIC)->EnableWindow(bEnable);
  1834. GetDlgItem(IDC_DETAIL_CHECK)->EnableWindow(bEnable);
  1835. //
  1836. // All controls after this point will be disabled no matter
  1837. // what the input if we are not targetting a Whistler or greater
  1838. // server
  1839. //
  1840. if (m_bNotWhistler)
  1841. {
  1842. bEnable = FALSE;
  1843. }
  1844. GetDlgItem(IDC_FILTERING_CHECK)->EnableWindow(bEnable);
  1845. GetDlgItem(IDC_FILTER_BUTTON)->EnableWindow(
  1846. SendDlgItemMessage(IDC_FILTERING_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED
  1847. && bEnable);
  1848. GetDlgItem(IDC_LOG_STATIC)->EnableWindow(bEnable);
  1849. GetDlgItem(IDC_FILENAME_STATIC)->EnableWindow(bEnable);
  1850. GetDlgItem(IDC_LOGFILE_EDIT)->EnableWindow(bEnable);
  1851. GetDlgItem(IDC_MAXSIZE_STATIC)->EnableWindow(bEnable);
  1852. GetDlgItem(IDC_MAX_SIZE_EDIT)->EnableWindow(bEnable);
  1853. }
  1854. void CDNSServer_DebugLoggingPropertyPage::ResetToDefaults()
  1855. {
  1856. SetUIFromOptions(DEFAULT_LOGGING_OPTIONS);
  1857. }
  1858. void CDNSServer_DebugLoggingPropertyPage::OnFilterCheck()
  1859. {
  1860. LRESULT lRes = SendDlgItemMessage(IDC_FILTERING_CHECK, BM_GETCHECK, 0, 0);
  1861. GetDlgItem(IDC_FILTER_BUTTON)->EnableWindow(lRes == BST_CHECKED);
  1862. if (!m_bOnSetUIData)
  1863. {
  1864. m_bFilterDirty = TRUE;
  1865. SetDirty(TRUE);
  1866. }
  1867. }
  1868. void CDNSServer_DebugLoggingPropertyPage::OnFilterButton()
  1869. {
  1870. CThemeContextActivator activator;
  1871. CIPFilterDialog filterDialog(m_pIPFilterList, GetHolder()->GetComponentData());
  1872. if (filterDialog.DoModal() == IDOK)
  1873. {
  1874. if (m_bOwnIPListMemory && m_pIPFilterList != NULL)
  1875. {
  1876. free(m_pIPFilterList);
  1877. m_pIPFilterList = NULL;
  1878. }
  1879. m_pIPFilterList = filterDialog.GetIPFilter();
  1880. m_bOwnIPListMemory = TRUE;
  1881. m_bFilterDirty = TRUE;
  1882. SetDirty(TRUE);
  1883. }
  1884. }
  1885. void CDNSServer_DebugLoggingPropertyPage::OnLogFileChange()
  1886. {
  1887. if (!m_bOnSetUIData)
  1888. {
  1889. m_bLogFileDirty = TRUE;
  1890. SetDirty(TRUE);
  1891. }
  1892. }
  1893. void CDNSServer_DebugLoggingPropertyPage::OnMaxSizeChange()
  1894. {
  1895. if (!m_bOnSetUIData)
  1896. {
  1897. m_bMaxSizeDirty = TRUE;
  1898. SetDirty(TRUE);
  1899. }
  1900. }
  1901. void CDNSServer_DebugLoggingPropertyPage::SetUIData()
  1902. {
  1903. m_bOnSetUIData = TRUE;
  1904. CPropertyPageBase::OnInitDialog();
  1905. CDNSServerPropertyPageHolder* pHolder =
  1906. (CDNSServerPropertyPageHolder*)GetHolder();
  1907. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  1908. m_dwLogLevel = pServerNode->GetLogLevelFlag();
  1909. m_dwMaxSize = pServerNode->GetDebugLogFileMaxSize();
  1910. if (m_bOwnIPListMemory && m_pIPFilterList)
  1911. {
  1912. free(m_pIPFilterList);
  1913. m_pIPFilterList = NULL;
  1914. m_bOwnIPListMemory = FALSE;
  1915. }
  1916. m_pIPFilterList = pServerNode->GetDebugLogFilterList();
  1917. m_szLogFileName = pServerNode->GetDebugLogFileName();
  1918. if (m_dwLogLevel)
  1919. {
  1920. SendDlgItemMessage(IDC_DEBUG_LOGGING_CHECK, BM_SETCHECK, BST_CHECKED, 0);
  1921. SetUIFromOptions(m_dwLogLevel);
  1922. }
  1923. else
  1924. {
  1925. SendDlgItemMessage(IDC_DEBUG_LOGGING_CHECK, BM_SETCHECK, BST_UNCHECKED, 0);
  1926. ResetToDefaults();
  1927. }
  1928. //
  1929. // Set log file name
  1930. //
  1931. SetDlgItemText(IDC_LOGFILE_EDIT, m_szLogFileName);
  1932. //
  1933. // Set max file size
  1934. //
  1935. SetDlgItemInt(IDC_MAX_SIZE_EDIT, m_dwMaxSize);
  1936. //
  1937. // Set filter check
  1938. //
  1939. if (m_pIPFilterList != NULL)
  1940. {
  1941. SendDlgItemMessage(IDC_FILTERING_CHECK, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  1942. GetDlgItem(IDC_FILTER_BUTTON)->EnableWindow(TRUE);
  1943. }
  1944. else
  1945. {
  1946. SendDlgItemMessage(IDC_FILTERING_CHECK, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  1947. GetDlgItem(IDC_FILTER_BUTTON)->EnableWindow(FALSE);
  1948. }
  1949. //
  1950. // Now enable/disable the controls based on the options
  1951. //
  1952. EnableLogging(m_dwLogLevel > 0);
  1953. m_bOnSetUIData = FALSE;
  1954. }
  1955. void CDNSServer_DebugLoggingPropertyPage::SetUIFromOptions(DWORD dwOptions)
  1956. {
  1957. //
  1958. // Set logging options
  1959. //
  1960. for (UINT idx = 0; idx < ARRAYLENGTH(g_loggingOptions); idx++)
  1961. {
  1962. if (g_loggingOptions[idx].dwOption & dwOptions)
  1963. {
  1964. SendDlgItemMessage(g_loggingOptions[idx].nControlID, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  1965. }
  1966. else
  1967. {
  1968. SendDlgItemMessage(g_loggingOptions[idx].nControlID, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0);
  1969. }
  1970. }
  1971. }
  1972. void CDNSServer_DebugLoggingPropertyPage::GetUIData(BOOL)
  1973. {
  1974. if (SendDlgItemMessage(IDC_DEBUG_LOGGING_CHECK, BM_GETCHECK, 0, 0) == BST_CHECKED)
  1975. {
  1976. //
  1977. // Get logging options
  1978. //
  1979. for (UINT idx = 0; idx < ARRAYLENGTH(g_loggingOptions); idx++)
  1980. {
  1981. LRESULT lCheck = SendDlgItemMessage(g_loggingOptions[idx].nControlID, BM_GETCHECK, 0, 0);
  1982. if (lCheck == BST_CHECKED)
  1983. {
  1984. m_dwLogLevel |= g_loggingOptions[idx].dwOption;
  1985. }
  1986. else
  1987. {
  1988. m_dwLogLevel &= ~(g_loggingOptions[idx].dwOption);
  1989. }
  1990. }
  1991. //
  1992. // Get log file name
  1993. //
  1994. GetDlgItemText(IDC_LOGFILE_EDIT, m_szLogFileName);
  1995. //
  1996. // Get max file size
  1997. //
  1998. BOOL bTrans = FALSE;
  1999. m_dwMaxSize = GetDlgItemInt(IDC_MAX_SIZE_EDIT, &bTrans, FALSE);
  2000. //
  2001. // Note: the filter IP addresses will be set when returning from the filter dialog
  2002. //
  2003. }
  2004. else
  2005. {
  2006. m_dwLogLevel = 0;
  2007. }
  2008. }
  2009. BOOL CDNSServer_DebugLoggingPropertyPage::OnInitDialog()
  2010. {
  2011. CPropertyPageBase::OnInitDialog();
  2012. CDNSServerPropertyPageHolder* pHolder =
  2013. (CDNSServerPropertyPageHolder*)GetHolder();
  2014. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  2015. //
  2016. // Retrieve necessary data from server
  2017. //
  2018. if (!pServerNode->HasServerInfo())
  2019. {
  2020. EnableWindow(FALSE);
  2021. return TRUE;
  2022. }
  2023. //
  2024. // Limit the file size to 9 characters (MAX_INT is 9 characters)
  2025. //
  2026. SendDlgItemMessage(IDC_MAX_SIZE_EDIT, EM_SETLIMITTEXT, (WPARAM)9, 0);
  2027. SetUIData();
  2028. m_bMaxSizeDirty = FALSE;
  2029. m_bLogFileDirty = FALSE;
  2030. m_bFilterDirty = FALSE;
  2031. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  2032. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  2033. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER))
  2034. {
  2035. //
  2036. // These debug options are not available on pre-Whistler servers
  2037. //
  2038. m_bNotWhistler = TRUE;
  2039. GetDlgItem(IDC_FILTERING_CHECK)->EnableWindow(FALSE);
  2040. GetDlgItem(IDC_MAX_SIZE_EDIT)->EnableWindow(FALSE);
  2041. GetDlgItem(IDC_LOGFILE_EDIT)->EnableWindow(FALSE);
  2042. GetDlgItem(IDC_FILENAME_STATIC)->EnableWindow(FALSE);
  2043. GetDlgItem(IDC_MAXSIZE_STATIC)->EnableWindow(FALSE);
  2044. }
  2045. SetDirty(FALSE);
  2046. return TRUE; // return TRUE unless you set the focus to a control
  2047. // EXCEPTION: OCX Property Pages should return FALSE
  2048. }
  2049. BOOL CDNSServer_DebugLoggingPropertyPage::OnApply()
  2050. {
  2051. if (!IsDirty())
  2052. return TRUE;
  2053. CDNSServerPropertyPageHolder* pHolder =
  2054. (CDNSServerPropertyPageHolder*)GetHolder();
  2055. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  2056. GetUIData(FALSE);
  2057. DNS_STATUS dwErr = pServerNode->ResetLogLevelFlag(m_dwLogLevel);
  2058. if (dwErr != 0)
  2059. {
  2060. DNSErrorDialog(dwErr, IDS_MSG_SERVER_LOG_LEVEL_OPTIONS_FAILED);
  2061. return FALSE;
  2062. }
  2063. if (m_bMaxSizeDirty && !m_bNotWhistler)
  2064. {
  2065. dwErr = pServerNode->ResetDebugLogFileMaxSize(m_dwMaxSize);
  2066. if (dwErr != 0)
  2067. {
  2068. DNSErrorDialog(dwErr, IDS_MSG_SERVER_LOG_MAX_SIZE_FAILED);
  2069. return FALSE;
  2070. }
  2071. }
  2072. if (m_bLogFileDirty && !m_bNotWhistler)
  2073. {
  2074. dwErr = pServerNode->ResetDebugLogFileName(m_szLogFileName);
  2075. if (dwErr != 0)
  2076. {
  2077. DNSErrorDialog(dwErr, IDS_MSG_SERVER_LOG_FILE_NAME_FAILED);
  2078. return FALSE;
  2079. }
  2080. }
  2081. if (m_bFilterDirty && !m_bNotWhistler)
  2082. {
  2083. LRESULT lCheck = SendDlgItemMessage(IDC_FILTERING_CHECK, BM_GETCHECK, 0, 0);
  2084. if (lCheck == BST_CHECKED)
  2085. {
  2086. dwErr = pServerNode->ResetDebugLogFilterList(m_pIPFilterList);
  2087. }
  2088. else
  2089. {
  2090. dwErr = pServerNode->ResetDebugLogFilterList(NULL);
  2091. }
  2092. if (dwErr != 0)
  2093. {
  2094. DNSErrorDialog(dwErr, IDS_MSG_SERVER_LOG_FILTER_LIST_FAILED);
  2095. return FALSE;
  2096. }
  2097. m_bFilterDirty = FALSE;
  2098. }
  2099. //
  2100. // all is fine
  2101. //
  2102. SetUIData();
  2103. SetDirty(FALSE);
  2104. return TRUE;
  2105. }
  2106. ///////////////////////////////////////////////////////////////////////////////
  2107. // CDNSServer_EventLoggingPropertyPage
  2108. BEGIN_MESSAGE_MAP(CDNSServer_EventLoggingPropertyPage, CPropertyPageBase)
  2109. ON_BN_CLICKED(IDC_NO_EVENTS_RADIO, OnSetDirty)
  2110. ON_BN_CLICKED(IDC_ERRORS_RADIO, OnSetDirty)
  2111. ON_BN_CLICKED(IDC_ERRORS_WARNINGS_RADIO, OnSetDirty)
  2112. ON_BN_CLICKED(IDC_ALL_RADIO, OnSetDirty)
  2113. END_MESSAGE_MAP()
  2114. CDNSServer_EventLoggingPropertyPage::CDNSServer_EventLoggingPropertyPage()
  2115. : CPropertyPageBase(IDD_SERVER_EVENT_LOGGING_PAGE),
  2116. m_dwEventLogLevel(EVENTLOG_INFORMATION_TYPE)
  2117. {
  2118. }
  2119. void CDNSServer_EventLoggingPropertyPage::SetUIData()
  2120. {
  2121. if (m_dwEventLogLevel == 0)
  2122. {
  2123. SendDlgItemMessage(IDC_NO_EVENTS_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2124. }
  2125. else if (m_dwEventLogLevel == EVENTLOG_ERROR_TYPE)
  2126. {
  2127. SendDlgItemMessage(IDC_ERRORS_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2128. }
  2129. else if (m_dwEventLogLevel == EVENTLOG_WARNING_TYPE)
  2130. {
  2131. SendDlgItemMessage(IDC_ERRORS_WARNINGS_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2132. }
  2133. else
  2134. {
  2135. SendDlgItemMessage(IDC_ALL_RADIO, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
  2136. }
  2137. }
  2138. void CDNSServer_EventLoggingPropertyPage::OnSetDirty()
  2139. {
  2140. SetDirty(TRUE);
  2141. }
  2142. BOOL CDNSServer_EventLoggingPropertyPage::OnInitDialog()
  2143. {
  2144. CPropertyPageBase::OnInitDialog();
  2145. CDNSServerPropertyPageHolder* pHolder =
  2146. (CDNSServerPropertyPageHolder*)GetHolder();
  2147. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  2148. if (!pServerNode->HasServerInfo())
  2149. {
  2150. EnableWindow(FALSE);
  2151. return TRUE;
  2152. }
  2153. m_dwEventLogLevel = pServerNode->GetEventLogLevelFlag();
  2154. SetUIData();
  2155. return TRUE; // return TRUE unless you set the focus to a control
  2156. // EXCEPTION: OCX Property Pages should return FALSE
  2157. }
  2158. BOOL CDNSServer_EventLoggingPropertyPage::OnApply()
  2159. {
  2160. if (!IsDirty())
  2161. return TRUE;
  2162. CDNSServerPropertyPageHolder* pHolder =
  2163. (CDNSServerPropertyPageHolder*)GetHolder();
  2164. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  2165. //
  2166. // Retrieve UI data
  2167. //
  2168. LRESULT lNoEventsCheck = SendDlgItemMessage(IDC_NO_EVENTS_RADIO, BM_GETCHECK, 0, 0);
  2169. LRESULT lErrorsCheck = SendDlgItemMessage(IDC_ERRORS_RADIO, BM_GETCHECK, 0, 0);
  2170. LRESULT lWarningsCheck = SendDlgItemMessage(IDC_ERRORS_WARNINGS_RADIO, BM_GETCHECK, 0, 0);
  2171. LRESULT lAllCheck = SendDlgItemMessage(IDC_ALL_RADIO, BM_GETCHECK, 0, 0);
  2172. DWORD dwEventLogLevel = 0;
  2173. if (lNoEventsCheck == BST_CHECKED)
  2174. {
  2175. dwEventLogLevel = 0;
  2176. }
  2177. if (lErrorsCheck == BST_CHECKED)
  2178. {
  2179. dwEventLogLevel = EVENTLOG_ERROR_TYPE;
  2180. }
  2181. if (lWarningsCheck == BST_CHECKED)
  2182. {
  2183. dwEventLogLevel = EVENTLOG_WARNING_TYPE;
  2184. }
  2185. if (lAllCheck == BST_CHECKED)
  2186. {
  2187. dwEventLogLevel = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
  2188. }
  2189. //
  2190. // Set new event log level on server
  2191. //
  2192. DNS_STATUS err = 0;
  2193. err = pServerNode->ResetEventLogLevelFlag(dwEventLogLevel);
  2194. if (err != 0)
  2195. {
  2196. ::DNSErrorDialog(err, IDS_MSG_SERVER_FAILED_SET_EVENTLOGLEVEL);
  2197. return FALSE;
  2198. }
  2199. //
  2200. // all is fine
  2201. //
  2202. SetDirty(FALSE);
  2203. return TRUE;
  2204. }
  2205. ///////////////////////////////////////////////////////////////////////////////
  2206. // CDNSServer_CopyRootHintsFromDialog
  2207. BEGIN_MESSAGE_MAP(CDNSServer_CopyRootHintsFromDialog, CHelpDialog)
  2208. ON_EN_CHANGE(IDC_IPEDIT, OnIPv4CtrlChange)
  2209. END_MESSAGE_MAP()
  2210. CDNSServer_CopyRootHintsFromDialog::CDNSServer_CopyRootHintsFromDialog(CComponentDataObject* pComponentData)
  2211. : CHelpDialog(IDD_COPY_ROOTHINTS_DIALOG, pComponentData),
  2212. m_pComponentData(pComponentData)
  2213. {
  2214. m_dwIPVal = 0;
  2215. }
  2216. void CDNSServer_CopyRootHintsFromDialog::OnIPv4CtrlChange()
  2217. {
  2218. GetDlgItem(IDOK)->EnableWindow(!GetIPv4Ctrl()->IsEmpty());
  2219. }
  2220. void CDNSServer_CopyRootHintsFromDialog::OnOK()
  2221. {
  2222. GetIPv4Ctrl()->GetIPv4Val(&m_dwIPVal);
  2223. CDialog::OnOK();
  2224. }
  2225. ///////////////////////////////////////////////////////////////////////////////
  2226. // CDNSServer_RootHintsPropertyPage
  2227. BEGIN_MESSAGE_MAP(CDNSServer_RootHintsPropertyPage, CDNSNameServersPropertyPage)
  2228. ON_BN_CLICKED(IDC_COPY_FROM_BUTTON, OnCopyFrom)
  2229. END_MESSAGE_MAP()
  2230. CDNSServer_RootHintsPropertyPage::CDNSServer_RootHintsPropertyPage()
  2231. : CDNSNameServersPropertyPage(IDD_NAME_SERVERS_PAGE, IDS_NSPAGE_ROOT_HINTS)
  2232. {
  2233. m_bMeaningfulTTL = FALSE; // TTL for root hinst means nothing
  2234. }
  2235. BOOL CDNSServer_RootHintsPropertyPage::OnInitDialog()
  2236. {
  2237. CDNSNameServersPropertyPage::OnInitDialog();
  2238. if (m_bReadOnly)
  2239. {
  2240. GetDlgItem(IDC_COPY_FROM_BUTTON)->ShowWindow(TRUE);
  2241. GetDlgItem(IDC_COPY_FROM_BUTTON)->EnableWindow(FALSE);
  2242. }
  2243. else
  2244. {
  2245. GetDlgItem(IDC_COPY_FROM_BUTTON)->ShowWindow(TRUE);
  2246. GetDlgItem(IDC_COPY_FROM_BUTTON)->EnableWindow(TRUE);
  2247. }
  2248. GetDlgItem(IDC_DNSQUERY_STATIC)->ShowWindow(FALSE);
  2249. GetDlgItem(IDC_DNSQUERY_STATIC)->EnableWindow(FALSE);
  2250. return TRUE;
  2251. }
  2252. void CDNSServer_RootHintsPropertyPage::OnCopyFrom()
  2253. {
  2254. CThemeContextActivator activator;
  2255. BOOL bSuccess = FALSE;
  2256. while (!bSuccess)
  2257. {
  2258. CDNSServer_CopyRootHintsFromDialog copydlg(GetHolder()->GetComponentData());
  2259. if (copydlg.DoModal() == IDCANCEL)
  2260. {
  2261. return;
  2262. }
  2263. //
  2264. // create a thread object and set the name of servers to query
  2265. //
  2266. CRootHintsQueryThread* pThreadObj = new CRootHintsQueryThread;
  2267. if (pThreadObj == NULL)
  2268. {
  2269. ASSERT(FALSE);
  2270. return;
  2271. }
  2272. //
  2273. // if IP address given, try it
  2274. //
  2275. pThreadObj->LoadIPAddresses(1, &(copydlg.m_dwIPVal));
  2276. //
  2277. // create a dialog and attach the thread to it
  2278. //
  2279. CWnd* pParentWnd = CWnd::FromHandle(GetSafeHwnd());
  2280. if (pParentWnd == NULL)
  2281. {
  2282. ASSERT(FALSE);
  2283. return;
  2284. }
  2285. CLongOperationDialog dlg(pThreadObj, pParentWnd, IDR_SEARCH_AVI);
  2286. VERIFY(dlg.LoadTitleString(IDS_MSG_SERVWIZ_COLLECTINFO));
  2287. dlg.m_bExecuteNoUI = FALSE;
  2288. dlg.DoModal();
  2289. if (!dlg.m_bAbandoned)
  2290. {
  2291. if (pThreadObj->GetError() != 0)
  2292. {
  2293. DNSMessageBox(IDS_MSG_SERVWIZ_FAIL_ROOT_HINTS);
  2294. }
  2295. else
  2296. {
  2297. //
  2298. // success, get the root hints info to the UI
  2299. //
  2300. PDNS_RECORD pRootHintsRecordList = pThreadObj->GetHintsRecordList();
  2301. AddCopiedRootHintsToList(pRootHintsRecordList);
  2302. }
  2303. bSuccess = pThreadObj->GetError() == 0;
  2304. }
  2305. }
  2306. }
  2307. void CDNSServer_RootHintsPropertyPage::AddCopiedRootHintsToList(PDNS_RECORD pRootHintsRecordList)
  2308. {
  2309. CDNSRecordNodeEditInfoList NSRecordList;
  2310. CDNSRecordNodeEditInfoList ARecordList;
  2311. //
  2312. // walk through the list of root hints,
  2313. // convert to C++ format,
  2314. // write to server and add to the folder list (no UI, folder hidden)
  2315. //
  2316. PDNS_RECORD pCurrDnsQueryRecord = pRootHintsRecordList;
  2317. while (pCurrDnsQueryRecord != NULL)
  2318. {
  2319. ASSERT( (pCurrDnsQueryRecord->wType == DNS_TYPE_A) ||
  2320. (pCurrDnsQueryRecord->wType == DNS_TYPE_NS) );
  2321. //
  2322. // create a record node and read data from DnsQuery format
  2323. //
  2324. CDNSRecordNodeBase* pRecordNode =
  2325. CDNSRecordInfo::CreateRecordNode(pCurrDnsQueryRecord->wType);
  2326. pRecordNode->CreateFromDnsQueryRecord(pCurrDnsQueryRecord, DNS_RPC_RECORD_FLAG_ZONE_ROOT);
  2327. //
  2328. // create new data
  2329. //
  2330. CDNSRecordNodeEditInfo* pNewInfo = new CDNSRecordNodeEditInfo;
  2331. if (!pNewInfo)
  2332. {
  2333. break;
  2334. }
  2335. pNewInfo->m_action = CDNSRecordNodeEditInfo::add;
  2336. CDNSRootData* pRootData = (CDNSRootData*)(GetHolder()->GetComponentData()->GetRootData());
  2337. ASSERT(pRootData != NULL);
  2338. //
  2339. // create entry into the record info list
  2340. //
  2341. if (pCurrDnsQueryRecord->wType == DNS_TYPE_NS)
  2342. {
  2343. CDNS_NS_RecordNode* pNSRecord = new CDNS_NS_RecordNode;
  2344. if (pNSRecord)
  2345. {
  2346. pNewInfo->CreateFromNewRecord(new CDNS_NS_RecordNode);
  2347. //
  2348. // set the record node name
  2349. //
  2350. BOOL bAtTheNode = (pCurrDnsQueryRecord->wType == DNS_TYPE_NS);
  2351. pNewInfo->m_pRecordNode->SetRecordName(pCurrDnsQueryRecord->pName, bAtTheNode);
  2352. //
  2353. // Set the record
  2354. //
  2355. pNewInfo->m_pRecord->ReadDnsQueryData(pCurrDnsQueryRecord);
  2356. //
  2357. // Add to the NS record list
  2358. //
  2359. NSRecordList.AddTail(pNewInfo);
  2360. }
  2361. }
  2362. else // DNS_TYPE_A
  2363. {
  2364. CDNS_A_RecordNode* pARecord = new CDNS_A_RecordNode;
  2365. if (pARecord)
  2366. {
  2367. pNewInfo->CreateFromNewRecord(new CDNS_A_RecordNode);
  2368. //
  2369. // set the record node name
  2370. //
  2371. pNewInfo->m_pRecordNode->SetRecordName(pCurrDnsQueryRecord->pName, FALSE);
  2372. //
  2373. // Set the record
  2374. //
  2375. pNewInfo->m_pRecord->ReadDnsQueryData(pCurrDnsQueryRecord);
  2376. ARecordList.AddTail(pNewInfo);
  2377. }
  2378. }
  2379. pCurrDnsQueryRecord = pCurrDnsQueryRecord->pNext;
  2380. }
  2381. //
  2382. // Match the A records to the NS records
  2383. //
  2384. POSITION Apos = ARecordList.GetHeadPosition();
  2385. while (Apos != NULL)
  2386. {
  2387. CDNSRecordNodeEditInfo* pAInfo = ARecordList.GetNext(Apos);
  2388. ASSERT(pAInfo != NULL);
  2389. if (pAInfo == NULL)
  2390. {
  2391. continue;
  2392. }
  2393. CDNS_A_RecordNode* pARecordNode = reinterpret_cast<CDNS_A_RecordNode*>(pAInfo->m_pRecordNode);
  2394. ASSERT(pARecordNode != NULL);
  2395. if (pARecordNode == NULL)
  2396. {
  2397. continue;
  2398. }
  2399. POSITION NSpos = NSRecordList.GetHeadPosition();
  2400. while (NSpos != NULL)
  2401. {
  2402. CDNSRecordNodeEditInfo* pNSInfo = NSRecordList.GetNext(NSpos);
  2403. ASSERT(pNSInfo != NULL);
  2404. if (pNSInfo == NULL)
  2405. {
  2406. continue;
  2407. }
  2408. CDNS_NS_Record* pNSRecord = reinterpret_cast<CDNS_NS_Record*>(pNSInfo->m_pRecord);
  2409. ASSERT(pNSRecord != NULL);
  2410. if (pNSRecord == NULL)
  2411. {
  2412. continue;
  2413. }
  2414. if (_match(pNSRecord->m_szNameNode, pARecordNode))
  2415. {
  2416. pNSInfo->m_pEditInfoList->AddTail(pAInfo);
  2417. }
  2418. }
  2419. }
  2420. //
  2421. // Detach and add the NS records info to the UI
  2422. //
  2423. while (!NSRecordList.IsEmpty())
  2424. {
  2425. CDNSRecordNodeEditInfo* pNewInfo = reinterpret_cast<CDNSRecordNodeEditInfo*>(NSRecordList.RemoveTail());
  2426. ASSERT(pNewInfo != NULL);
  2427. if (pNewInfo == NULL)
  2428. {
  2429. continue;
  2430. }
  2431. //
  2432. // add to the list view (at the end)
  2433. //
  2434. int nCount = m_listCtrl.GetItemCount();
  2435. if (m_listCtrl.InsertNSRecordEntry(pNewInfo, nCount))
  2436. {
  2437. //
  2438. // Add to the clone info list so that changes will be applied
  2439. //
  2440. m_pCloneInfoList->AddTail(pNewInfo);
  2441. //
  2442. // set selection and button state on the last inserted
  2443. //
  2444. m_listCtrl.SetSelection(nCount);
  2445. EnableEditorButtons(nCount);
  2446. //
  2447. // notify count change
  2448. //
  2449. OnCountChange(nCount+1); // added one
  2450. }
  2451. //
  2452. // set dirty flag, it is a new record
  2453. //
  2454. SetDirty(TRUE);
  2455. }
  2456. while (!ARecordList.IsEmpty())
  2457. {
  2458. ARecordList.RemoveTail();
  2459. }
  2460. }
  2461. void CDNSServer_RootHintsPropertyPage::ReadRecordNodesList()
  2462. {
  2463. ASSERT(m_pCloneInfoList != NULL);
  2464. CDNSServerPropertyPageHolder* pHolder = (CDNSServerPropertyPageHolder*)GetHolder();
  2465. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  2466. CString szBuffer;
  2467. szBuffer.LoadString(IDS_ROOT_HINTS_DESCR);
  2468. GetDescription()->EnableWindow(TRUE);
  2469. GetDescription()->ShowWindow(TRUE);
  2470. SetDescription(szBuffer);
  2471. if (!pServerNode->HasServerInfo())
  2472. {
  2473. SetReadOnly();
  2474. return;
  2475. }
  2476. BOOL bRoot = FALSE;
  2477. DNS_STATUS err = ::ServerHasRootZone(pServerNode->GetRPCName(), &bRoot);
  2478. if (err == 0 && bRoot)
  2479. {
  2480. //
  2481. // it is a root server
  2482. //
  2483. szBuffer.LoadString(IDS_ROOT_HINTS_NO);
  2484. SetMessage(szBuffer);
  2485. SetReadOnly();
  2486. EnableDialogControls(m_hWnd, FALSE);
  2487. }
  2488. else
  2489. {
  2490. if (pServerNode->HasRootHints())
  2491. {
  2492. CDNSRootHintsNode* pRootHints = pServerNode->GetRootHints();
  2493. ASSERT(pRootHints != NULL);
  2494. SetDomainNode(pRootHints);
  2495. pRootHints->GetNSRecordNodesInfo(m_pCloneInfoList);
  2496. }
  2497. else
  2498. {
  2499. CDNSRootHintsNode* pRootHints = pServerNode->GetRootHints();
  2500. if (pRootHints != NULL)
  2501. {
  2502. SetDomainNode(pRootHints);
  2503. pRootHints->GetNSRecordNodesInfo(m_pCloneInfoList);
  2504. }
  2505. }
  2506. }
  2507. }
  2508. BOOL CDNSServer_RootHintsPropertyPage::WriteNSRecordNodesList()
  2509. {
  2510. // call base class
  2511. BOOL bRetVal = CDNSNameServersPropertyPage::WriteNSRecordNodesList();
  2512. CDNSServerPropertyPageHolder* pHolder = (CDNSServerPropertyPageHolder*)GetHolder();
  2513. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  2514. if (bRetVal && pServerNode->HasServerInfo())
  2515. {
  2516. DNS_STATUS err = CDNSZoneNode::WriteToDatabase(pServerNode->GetRPCName(), DNS_ZONE_ROOT_HINTS);
  2517. if (err != 0)
  2518. {
  2519. //DNSErrorDialog(err, L"CDNSZoneNode::WriteToDatabase() failed");
  2520. bRetVal = FALSE;
  2521. }
  2522. }
  2523. return bRetVal;
  2524. }
  2525. BOOL CDNSServer_RootHintsPropertyPage::OnApply()
  2526. {
  2527. BOOL bRet = TRUE;
  2528. CDNSServerPropertyPageHolder* pHolder = (CDNSServerPropertyPageHolder*)GetHolder();
  2529. CDNSServerNode* pServerNode = pHolder->GetServerNode();
  2530. if (m_listCtrl.GetItemCount() == 0 && pServerNode->HasRootHints())
  2531. {
  2532. //
  2533. // If there are no forwarders and no root zone then show an error message
  2534. //
  2535. BOOL bServerHasForwarders = FALSE;
  2536. CDNSDomainForwardersNode* pDomainForwardersNode = pServerNode->GetDomainForwardersNode();
  2537. if (pDomainForwardersNode)
  2538. {
  2539. CNodeList* pChildList = pDomainForwardersNode->GetContainerChildList();
  2540. if (pChildList)
  2541. {
  2542. bServerHasForwarders = (pChildList->GetHeadPosition() != NULL);
  2543. }
  2544. }
  2545. DWORD cAddrCount = 0;
  2546. PIP_ADDRESS pipAddrs = 0;
  2547. DWORD dwForwardTimeout = 0;
  2548. DWORD fSlave = 0;
  2549. pServerNode->GetForwardersInfo(&cAddrCount, &pipAddrs, &dwForwardTimeout, &fSlave);
  2550. if (cAddrCount > 0)
  2551. {
  2552. bServerHasForwarders = TRUE;
  2553. }
  2554. BOOL bServerHasRoot = FALSE;
  2555. DNS_STATUS err = ServerHasRootZone(pServerNode->GetRPCName(), &bServerHasRoot);
  2556. if (err == 0 && !bServerHasRoot && !bServerHasForwarders)
  2557. {
  2558. if (IDNO == DNSMessageBox(IDS_NO_ROOTHINTS, MB_YESNO | MB_DEFBUTTON2))
  2559. {
  2560. return FALSE;
  2561. }
  2562. }
  2563. }
  2564. if (bRet)
  2565. {
  2566. bRet = CDNSNameServersPropertyPage::OnApply();
  2567. }
  2568. return bRet;
  2569. }
  2570. ///////////////////////////////////////////////////////////////////////////////
  2571. // CDNSServerPropertyPageHolder
  2572. CDNSServerPropertyPageHolder::CDNSServerPropertyPageHolder(CDNSRootData* pRootDataNode,
  2573. CDNSServerNode* pServerNode, CComponentDataObject* pComponentData)
  2574. : CPropertyPageHolderBase(pRootDataNode, pServerNode, pComponentData)
  2575. {
  2576. ASSERT(pRootDataNode == GetContainerNode());
  2577. m_pAclEditorPage = NULL;
  2578. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  2579. if (pServerNode->HasServerInfo())
  2580. {
  2581. AddPageToList((CPropertyPageBase*)&m_interfacesPage);
  2582. AddPageToList((CPropertyPageBase*)&m_newForwardersPage);
  2583. AddPageToList((CPropertyPageBase*)&m_advancedPage);
  2584. AddPageToList((CPropertyPageBase*)&m_rootHintsPage);
  2585. AddPageToList((CPropertyPageBase*)&m_debugLoggingPage);
  2586. AddPageToList((CPropertyPageBase*)&m_eventLoggingPage);
  2587. // security page added only if needed
  2588. {
  2589. CString szPath;
  2590. pServerNode->CreateDsServerLdapPath(szPath);
  2591. if (!szPath.IsEmpty())
  2592. m_pAclEditorPage = CAclEditorPage::CreateInstance(szPath, this);
  2593. }
  2594. }
  2595. AddPageToList((CPropertyPageBase*)&m_testPage);
  2596. }
  2597. CDNSServerPropertyPageHolder::~CDNSServerPropertyPageHolder()
  2598. {
  2599. if (m_pAclEditorPage != NULL)
  2600. delete m_pAclEditorPage;
  2601. }
  2602. void CDNSServerPropertyPageHolder::OnSheetMessage(WPARAM wParam, LPARAM lParam)
  2603. {
  2604. if (wParam == SHEET_MSG_SERVER_TEST_DATA)
  2605. {
  2606. m_testPage.OnHaveTestData(lParam);
  2607. }
  2608. }
  2609. HRESULT CDNSServerPropertyPageHolder::OnAddPage(int nPage, CPropertyPageBase*)
  2610. {
  2611. // add the ACL editor page after the last, if present
  2612. if ( (nPage != -1) || (m_pAclEditorPage == NULL) )
  2613. return S_OK;
  2614. // add the ACLU page
  2615. HPROPSHEETPAGE hPage = m_pAclEditorPage->CreatePage();
  2616. if (hPage == NULL)
  2617. return E_FAIL;
  2618. // add the raw HPROPSHEETPAGE to sheet, not in the list
  2619. return AddPageToSheetRaw(hPage);
  2620. }