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.

2769 lines
74 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: recpag2.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. #ifdef DEBUG_ALLOCATOR
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. #endif
  27. ////////////////////////////////////////////////////////////////////////////
  28. // CDNS_A_RecordPropertyPage
  29. BEGIN_MESSAGE_MAP(CDNS_A_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  30. ON_EN_CHANGE(IDC_IPEDIT, OnIPv4CtrlChange)
  31. ON_BN_CLICKED(IDC_UPDATE_PRT_CHECK, OnCreatePointerClicked)
  32. END_MESSAGE_MAP()
  33. CDNS_A_RecordPropertyPage::CDNS_A_RecordPropertyPage()
  34. : CDNSRecordStandardPropertyPage(IDD_RR_A)
  35. {
  36. }
  37. BOOL CDNS_A_RecordPropertyPage::OnInitDialog()
  38. {
  39. CDNSRecordStandardPropertyPage::OnInitDialog();
  40. STANDARD_REC_PP_PTRS(CDNS_A_Record);
  41. CDNSZoneNode* pZoneNode = pHolder->GetDomainNode()->GetZoneNode();
  42. CDNSServerNode* pServerNode = pZoneNode->GetServerNode();
  43. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER_NEW_SECURITY_SETTINGS ||
  44. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  45. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER) ||
  46. !pHolder->IsWizardMode() ||
  47. !pZoneNode->IsDSIntegrated())
  48. {
  49. GetSecurityCheckCtrl()->ShowWindow(FALSE);
  50. GetSecurityCheckCtrl()->EnableWindow(FALSE);
  51. }
  52. return FALSE;
  53. }
  54. void CDNS_A_RecordPropertyPage::OnIPv4CtrlChange()
  55. {
  56. STANDARD_REC_PP_PTRS(CDNS_A_Record)
  57. SetDirty(TRUE);
  58. }
  59. void CDNS_A_RecordPropertyPage::OnCreatePointerClicked()
  60. {
  61. STANDARD_REC_PP_PTRS(CDNS_A_Record)
  62. SetDirty(TRUE);
  63. }
  64. void CDNS_A_RecordPropertyPage::SetUIData()
  65. {
  66. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_A_Record);
  67. GetIPv4Ctrl()->SetIPv4Val(pRecord->m_ipAddress);
  68. CDNSRootData* pRootData = dynamic_cast<CDNSRootData*>(GetHolder()->GetComponentData()->GetRootData());
  69. if (pRootData != NULL)
  70. {
  71. GetPTRCheckCtrl()->SetCheck(pRootData->GetCreatePTRWithHost());
  72. }
  73. }
  74. DNS_STATUS CDNS_A_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  75. {
  76. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_A_Record);
  77. GetIPv4Ctrl()->GetIPv4Val(&(pRecord->m_ipAddress));
  78. if (GetPTRCheckCtrl()->GetCheck())
  79. {
  80. pRecord->m_dwFlags |= DNS_RPC_RECORD_FLAG_CREATE_PTR;
  81. }
  82. if (pHolder->IsWizardMode() &&
  83. GetSecurityCheckCtrl()->GetCheck())
  84. {
  85. pRecord->m_dwFlags |= DNS_RPC_FLAG_OPEN_ACL;
  86. }
  87. CDNSRootData* pRootData = dynamic_cast<CDNSRootData*>(GetHolder()->GetComponentData()->GetRootData());
  88. if (pRootData != NULL)
  89. {
  90. pRootData->SetCreatePTRWithHost(GetPTRCheckCtrl()->GetCheck());
  91. }
  92. return dwErr;
  93. }
  94. ////////////////////////////////////////////////////////////////////////////
  95. // CDNS_ATMA_RecordPropertyPage
  96. BEGIN_MESSAGE_MAP(CDNS_ATMA_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  97. ON_EN_CHANGE(IDC_EDIT_ATMA_ADDRESS, OnAddressChange)
  98. ON_BN_CLICKED(IDC_RADIO_E164, OnFormatRadioChange)
  99. ON_BN_CLICKED(IDC_RADIO_NSAP, OnFormatRadioChange)
  100. END_MESSAGE_MAP()
  101. CDNS_ATMA_RecordPropertyPage::CDNS_ATMA_RecordPropertyPage()
  102. : CDNSRecordStandardPropertyPage(IDD_RR_ATMA)
  103. {
  104. }
  105. UCHAR CDNS_ATMA_RecordPropertyPage::GetFormat()
  106. {
  107. if (GetRadioNSAP()->GetCheck())
  108. return DNS_ATMA_FORMAT_AESA;
  109. ASSERT(GetRadioE164()->GetCheck());
  110. return DNS_ATMA_FORMAT_E164;
  111. }
  112. void CDNS_ATMA_RecordPropertyPage::SetFormat(UCHAR chFormat)
  113. {
  114. GetRadioNSAP()->SetCheck(chFormat == DNS_ATMA_FORMAT_AESA);
  115. GetRadioE164()->SetCheck(chFormat == DNS_ATMA_FORMAT_E164);
  116. }
  117. void _StripDots(CString& s)
  118. {
  119. int nLen = s.GetLength();
  120. if (nLen == 0)
  121. return;
  122. WCHAR* pBuf = (WCHAR*)malloc((nLen+1)*sizeof(WCHAR));
  123. if (!pBuf)
  124. {
  125. return;
  126. }
  127. ZeroMemory(pBuf, (nLen+1)*sizeof(WCHAR));
  128. int k=0;
  129. for (int i=0; i<nLen; i++)
  130. {
  131. if (s[i] != L'.')
  132. {
  133. pBuf[k++] = s[i];
  134. }
  135. }
  136. s = pBuf;
  137. if (pBuf)
  138. {
  139. free(pBuf);
  140. pBuf = 0;
  141. }
  142. }
  143. void CDNS_ATMA_RecordPropertyPage::OnAddressChange()
  144. {
  145. BOOL bValid = TRUE;
  146. UCHAR chFormat = GetFormat();
  147. CString s;
  148. GetAddressCtrl()->GetWindowText(s);
  149. _StripDots(s);
  150. int nLen = s.GetLength();
  151. if (chFormat == DNS_ATMA_FORMAT_E164)
  152. {
  153. //it is a string
  154. bValid = (nLen <= DNS_ATMA_MAX_ADDR_LENGTH);
  155. if (bValid)
  156. {
  157. // check only numeric digits
  158. for (int i=0; i<nLen; i++)
  159. {
  160. if (iswdigit(s[i]) == 0)
  161. {
  162. bValid = FALSE;
  163. break;
  164. }
  165. }
  166. }
  167. }
  168. else
  169. {
  170. // must be of fixed length
  171. bValid = (nLen == 2*DNS_ATMA_MAX_ADDR_LENGTH);
  172. if (bValid)
  173. {
  174. // check only hex digits
  175. for (int i=0; i<nLen; i++)
  176. {
  177. if (HexCharToByte(s[i]) == 0xFF)
  178. {
  179. bValid = FALSE;
  180. break;
  181. }
  182. }
  183. }
  184. }
  185. SetValidState(bValid);
  186. }
  187. void CDNS_ATMA_RecordPropertyPage::OnFormatRadioChange()
  188. {
  189. // reset the address, we changed format
  190. GetAddressCtrl()->SetWindowText(NULL);
  191. // it is OK th have E164 with empty field, but not NSAP
  192. SetValidState(GetFormat() == DNS_ATMA_FORMAT_E164);
  193. }
  194. void CDNS_ATMA_RecordPropertyPage::SetUIData()
  195. {
  196. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_ATMA_Record);
  197. SetFormat(pRecord->m_chFormat);
  198. GetAddressCtrl()->SetWindowText(pRecord->m_szAddress);
  199. }
  200. DNS_STATUS CDNS_ATMA_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  201. {
  202. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_ATMA_Record);
  203. pRecord->m_chFormat = GetFormat();
  204. GetAddressCtrl()->GetWindowText(pRecord->m_szAddress);
  205. _StripDots(pRecord->m_szAddress);
  206. return dwErr;
  207. }
  208. ////////////////////////////////////////////////////////////////////////////
  209. // CDNS_AAAA_RecordPropertyPage
  210. BEGIN_MESSAGE_MAP(CDNS_AAAA_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  211. ON_EN_CHANGE(IDC_IPV6EDIT, OnIPv6CtrlChange)
  212. END_MESSAGE_MAP()
  213. CDNS_AAAA_RecordPropertyPage::CDNS_AAAA_RecordPropertyPage()
  214. : CDNSRecordStandardPropertyPage(IDD_RR_AAAA)
  215. {
  216. }
  217. void CDNS_AAAA_RecordPropertyPage::OnIPv6CtrlChange()
  218. {
  219. SetDirty(TRUE);
  220. }
  221. BOOL
  222. CDNS_AAAA_RecordPropertyPage::OnInitDialog()
  223. {
  224. CDNSRecordStandardPropertyPage::OnInitDialog();
  225. GetRRNameEdit()->SetLimitText(IP6_ADDRESS_STRING_BUFFER_LENGTH);
  226. return TRUE;
  227. }
  228. void CDNS_AAAA_RecordPropertyPage::SetUIData()
  229. {
  230. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_AAAA_Record);
  231. // convert the address into it's string represenation
  232. WCHAR buf[IP6_ADDRESS_STRING_BUFFER_LENGTH + 1];
  233. ::ZeroMemory(buf, sizeof buf);
  234. Dns_Ip6AddressToString_W(buf, &pRecord->m_ipv6Address);
  235. GetIPv6Edit()->SetWindowText(buf);
  236. }
  237. DNS_STATUS CDNS_AAAA_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  238. {
  239. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_AAAA_Record);
  240. // convert the string representation to the address
  241. ::ZeroMemory(&pRecord->m_ipv6Address, sizeof pRecord->m_ipv6Address);
  242. CString text;
  243. GetIPv6Edit()->GetWindowText(text);
  244. BOOL successful =
  245. Dns_Ip6StringToAddress_W(
  246. &pRecord->m_ipv6Address,
  247. (PWSTR) (PCWSTR) text);
  248. if (!successful)
  249. {
  250. // the string is not valid. Complain to the user. Setting dwErr
  251. // will cause CreateRecord to silently skip the attempt to create
  252. // the record.
  253. dwErr = DNS_ERROR_INVALID_IP_ADDRESS;
  254. if (!bSilent)
  255. {
  256. ::DNSMessageBox(IDS_ERRMSG_BAD_IPV6_TEXT);
  257. }
  258. }
  259. return dwErr;
  260. }
  261. BOOL
  262. CDNS_AAAA_RecordPropertyPage::CreateRecord()
  263. {
  264. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  265. ASSERT(pHolder->IsWizardMode());
  266. //
  267. // Get the data from the UI
  268. //
  269. DNS_STATUS err = GetUIDataEx(FALSE);
  270. if (err != 0)
  271. {
  272. // the error message was already raised by GetUIDataEx
  273. return FALSE;
  274. }
  275. //
  276. // Create the new record
  277. //
  278. err = pHolder->CreateNewRecord(CanCreateDuplicateRecords());
  279. if (err != 0)
  280. {
  281. DNSErrorDialog(err,IDS_MSG_RECORD_CREATE_FAILED);
  282. return FALSE;
  283. }
  284. return TRUE;
  285. }
  286. BOOL
  287. CDNS_AAAA_RecordPropertyPage::OnApply()
  288. {
  289. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  290. if(pHolder->IsWizardMode())
  291. {
  292. //
  293. // this is the case of record creation,
  294. // the user hit OK and we want to create the record
  295. //
  296. return CreateRecord();
  297. }
  298. //
  299. // we are in the case of modeless sheet on existing record
  300. //
  301. CDNSRecordNodeBase* pRecordNode = pHolder->GetRecordNode();
  302. ASSERT(pRecordNode != NULL);
  303. DWORD dwZoneType = pRecordNode->GetDomainNode()->GetZoneNode()->GetZoneType();
  304. if ((dwZoneType == DNS_ZONE_TYPE_SECONDARY) ||
  305. (dwZoneType == DNS_ZONE_TYPE_STUB) ||
  306. (dwZoneType == DNS_ZONE_TYPE_CACHE))
  307. {
  308. // read only case
  309. return TRUE;
  310. }
  311. DNS_STATUS err = GetUIDataEx(FALSE);
  312. if (err != 0)
  313. {
  314. // the error message was already raised by GetUIDataEx
  315. return FALSE;
  316. }
  317. if (!IsDirty())
  318. {
  319. return TRUE;
  320. }
  321. err = pHolder->NotifyConsole(this);
  322. if (err == DNS_WARNING_PTR_CREATE_FAILED)
  323. {
  324. DNSMessageBox(IDS_MSG_RECORD_WARNING_CREATE_PTR);
  325. err = 0; // was just a warning
  326. }
  327. if (err != 0)
  328. {
  329. DNSErrorDialog(err,IDS_MSG_RECORD_UPDATE_FAILED);
  330. return FALSE;
  331. }
  332. else
  333. {
  334. SetDirty(FALSE);
  335. }
  336. return TRUE; // all is cool
  337. }
  338. ////////////////////////////////////////////////////////////////////////////
  339. // CDNS_HINFO_RecordPropertyPage
  340. BEGIN_MESSAGE_MAP(CDNS_HINFO_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  341. ON_EN_CHANGE(IDC_CPU_TYPE_EDIT, OnCPUTypeChange)
  342. ON_EN_CHANGE(IDC_OPERATING_SYSTEM_EDIT, OnOperatingSystemChange)
  343. END_MESSAGE_MAP()
  344. CDNS_HINFO_RecordPropertyPage::CDNS_HINFO_RecordPropertyPage()
  345. : CDNSRecordStandardPropertyPage(IDD_RR_HINFO)
  346. {
  347. }
  348. BOOL CDNS_HINFO_RecordPropertyPage::OnInitDialog()
  349. {
  350. CDNSRecordStandardPropertyPage::OnInitDialog();
  351. //
  352. // The RDATA size field is a byte so we have to limit the size of the string
  353. // to 253 characters (add one for the trailing NULL character)
  354. //
  355. GetCPUTypeCtrl()->SetLimitText(253);
  356. GetOperatingSystemCtrl()->SetLimitText(253);
  357. return TRUE;
  358. }
  359. void CDNS_HINFO_RecordPropertyPage::OnCPUTypeChange()
  360. {
  361. SetDirty((GetCPUTypeCtrl()->GetWindowTextLength() > 0) &&
  362. (GetOperatingSystemCtrl()->GetWindowTextLength() > 0));
  363. }
  364. void CDNS_HINFO_RecordPropertyPage::OnOperatingSystemChange()
  365. {
  366. SetDirty((GetCPUTypeCtrl()->GetWindowTextLength() > 0) &&
  367. (GetOperatingSystemCtrl()->GetWindowTextLength() > 0));
  368. }
  369. void CDNS_HINFO_RecordPropertyPage::SetUIData()
  370. {
  371. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_HINFO_Record);
  372. GetCPUTypeCtrl()->SetWindowText(pRecord->m_szCPUType);
  373. GetOperatingSystemCtrl()->SetWindowText(pRecord->m_szOperatingSystem);
  374. }
  375. DNS_STATUS CDNS_HINFO_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  376. {
  377. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_HINFO_Record);
  378. GetCPUTypeCtrl()->GetWindowText(pRecord->m_szCPUType);
  379. GetOperatingSystemCtrl()->GetWindowText(pRecord->m_szOperatingSystem);
  380. return dwErr;
  381. }
  382. ////////////////////////////////////////////////////////////////////////////
  383. // CDNS_ISDN_RecordPropertyPage
  384. BEGIN_MESSAGE_MAP(CDNS_ISDN_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  385. ON_EN_CHANGE(IDC_PHONE_NUM_AND_DDI_EDIT, OnPhoneNumberAndDDIChange)
  386. ON_EN_CHANGE(IDC_SUBADDRESS_EDIT, OnSubAddressChange)
  387. END_MESSAGE_MAP()
  388. CDNS_ISDN_RecordPropertyPage::CDNS_ISDN_RecordPropertyPage()
  389. : CDNSRecordStandardPropertyPage(IDD_RR_ISDN)
  390. {
  391. }
  392. void CDNS_ISDN_RecordPropertyPage::OnPhoneNumberAndDDIChange()
  393. {
  394. SetDirty(TRUE);
  395. }
  396. void CDNS_ISDN_RecordPropertyPage::OnSubAddressChange()
  397. {
  398. SetDirty(TRUE);
  399. }
  400. void CDNS_ISDN_RecordPropertyPage::SetUIData()
  401. {
  402. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_ISDN_Record);
  403. // NTRAID#NTBUG9-503827-2001/12/06-JeffJon
  404. // This is some arbitrary limit set by the server
  405. GetPhoneNumberAndDDICtrl()->SetLimitText(255);
  406. GetPhoneNumberAndDDICtrl()->SetWindowText(pRecord->m_szPhoneNumberAndDDI);
  407. // NTRAID#NTBUG9-503827-2001/12/06-JeffJon
  408. // This is some arbitrary limit set by the server
  409. GetSubAddressCtrl()->SetLimitText(255);
  410. GetSubAddressCtrl()->SetWindowText(pRecord->m_szSubAddress);
  411. }
  412. DNS_STATUS CDNS_ISDN_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  413. {
  414. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_ISDN_Record);
  415. GetPhoneNumberAndDDICtrl()->GetWindowText(pRecord->m_szPhoneNumberAndDDI);
  416. GetSubAddressCtrl()->GetWindowText(pRecord->m_szSubAddress);
  417. return dwErr;
  418. }
  419. ////////////////////////////////////////////////////////////////////////////
  420. // CDNS_X25_RecordPropertyPage
  421. BEGIN_MESSAGE_MAP(CDNS_X25_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  422. ON_EN_CHANGE(IDC_X121_ADDRESS_EDIT, OnX121PSDNAddressChange)
  423. END_MESSAGE_MAP()
  424. CDNS_X25_RecordPropertyPage::CDNS_X25_RecordPropertyPage()
  425. : CDNSRecordStandardPropertyPage(IDD_RR_X25)
  426. {
  427. }
  428. BOOL CDNS_X25_RecordPropertyPage::OnInitDialog()
  429. {
  430. CDNSRecordStandardPropertyPage::OnInitDialog();
  431. GetX121Edit()->SetLimitText(MAX_DNS_NAME_LEN);
  432. return TRUE;
  433. }
  434. void CDNS_X25_RecordPropertyPage::OnX121PSDNAddressChange()
  435. {
  436. SetDirty(TRUE);
  437. }
  438. void CDNS_X25_RecordPropertyPage::SetUIData()
  439. {
  440. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_X25_Record);
  441. GetX121Edit()->SetWindowText(pRecord->m_szX121PSDNAddress);
  442. }
  443. DNS_STATUS CDNS_X25_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  444. {
  445. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_X25_Record);
  446. //
  447. // Retrieve the text
  448. //
  449. CString szName;
  450. GetX121Edit()->GetWindowText(szName);
  451. CDNSZoneNode* pZone = pHolder->GetDomainNode()->GetZoneNode();
  452. ASSERT(pZone != NULL);
  453. //
  454. // Any values are allowed for the data in advanced view
  455. //
  456. if (!(((CDNSRootData*)pZone->GetRootContainer()))->IsAdvancedView())
  457. {
  458. //
  459. // Validate the record name using the server flags as a guideline
  460. //
  461. CString szFullName;
  462. szFullName.Format(L"%s.%s", szName, pHolder->GetDomainNode()->GetFullName());
  463. DWORD dwNameChecking = pZone->GetServerNode()->GetNameCheckFlag();
  464. dwErr = ValidateRecordName(szFullName, dwNameChecking);
  465. }
  466. // Set the valid text
  467. pRecord->m_szX121PSDNAddress = szName;
  468. return dwErr;
  469. }
  470. ////////////////////////////////////////////////////////////////////////////
  471. // CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage
  472. BEGIN_MESSAGE_MAP(CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  473. ON_EN_CHANGE(IDC_NAME_NODE_EDIT, OnNameNodeChange)
  474. ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowse)
  475. END_MESSAGE_MAP()
  476. CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::
  477. CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(UINT nIDTemplate) :
  478. CDNSRecordStandardPropertyPage(nIDTemplate)
  479. {
  480. }
  481. BOOL CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::OnInitDialog()
  482. {
  483. CDNSRecordStandardPropertyPage::OnInitDialog();
  484. STANDARD_REC_PP_PTRS(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record);
  485. GetNameNodeEdit()->SetLimitText(MAX_DNS_NAME_LEN);
  486. return TRUE;
  487. }
  488. void CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::OnNameNodeChange()
  489. {
  490. STANDARD_REC_PP_PTRS(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record);
  491. CString szNewName;
  492. GetNameNodeEdit()->GetWindowText(szNewName);
  493. CDNSServerNode* pServerNode = pHolder->GetDomainNode()->GetServerNode();
  494. BOOL bIsValidName = TRUE;
  495. // Only validate the name if it is not advanced view
  496. if (!(((CDNSRootData*)pServerNode->GetRootContainer()))->IsAdvancedView())
  497. {
  498. DWORD dwNameChecking = pServerNode->GetNameCheckFlag();
  499. bIsValidName = (0 == ValidateDnsNameAgainstServerFlags(szNewName,
  500. DnsNameDomain,
  501. dwNameChecking));
  502. }
  503. SetValidState(bIsValidName);
  504. }
  505. void CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::OnBrowse()
  506. {
  507. STANDARD_REC_PP_PTRS(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record);
  508. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  509. FIX_THREAD_STATE_MFC_BUG();
  510. CThemeContextActivator activator;
  511. CDNSBrowserDlg dlg(GetHolder()->GetComponentData(), GetHolder(),
  512. (pRecord->GetType() == DNS_TYPE_CNAME) ? RECORD_A_AND_CNAME : RECORD_A);
  513. if (IDOK == dlg.DoModal())
  514. {
  515. GetNameNodeEdit()->SetWindowText(dlg.GetSelectionString());
  516. }
  517. }
  518. void CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::SetUIData()
  519. {
  520. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record);
  521. GetNameNodeEdit()->SetWindowText(pRecord->m_szNameNode);
  522. }
  523. DNS_STATUS CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  524. {
  525. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record);
  526. //
  527. // Retrieve the text
  528. //
  529. CString szName;
  530. GetNameNodeEdit()->GetWindowText(szName);
  531. CDNSZoneNode* pZone = pHolder->GetDomainNode()->GetZoneNode();
  532. ASSERT(pZone != NULL);
  533. //
  534. // Set the valid text, no need to validate the data field
  535. //
  536. pRecord->m_szNameNode = szName;
  537. return dwErr;
  538. }
  539. ////////////////////////////////////////////////////////////////////////////
  540. // CDNS_CNAME_RecordPropertyPage
  541. CDNS_CNAME_RecordPropertyPage::CDNS_CNAME_RecordPropertyPage()
  542. : CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(IDD_RR_CNAME)
  543. {
  544. }
  545. BOOL CDNS_CNAME_RecordPropertyPage::OnInitDialog()
  546. {
  547. CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::OnInitDialog();
  548. STANDARD_REC_PP_PTRS(CDNS_CNAME_Record);
  549. CDNSZoneNode* pZoneNode = pHolder->GetDomainNode()->GetZoneNode();
  550. CDNSServerNode* pServerNode = pZoneNode->GetServerNode();
  551. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER_NEW_SECURITY_SETTINGS ||
  552. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  553. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER) ||
  554. !pHolder->IsWizardMode() ||
  555. !pZoneNode->IsDSIntegrated())
  556. {
  557. GetSecurityCheckCtrl()->ShowWindow(FALSE);
  558. GetSecurityCheckCtrl()->EnableWindow(FALSE);
  559. }
  560. return FALSE;
  561. }
  562. DNS_STATUS CDNS_CNAME_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  563. {
  564. DNS_STATUS dwErr = CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::GetUIDataEx(bSilent);
  565. STANDARD_REC_PP_PTRS(CDNS_CNAME_Record);
  566. if (pHolder->IsWizardMode() &&
  567. GetSecurityCheckCtrl()->GetCheck())
  568. {
  569. pRecord->m_dwFlags |= DNS_RPC_FLAG_OPEN_ACL;
  570. }
  571. return dwErr;
  572. }
  573. ////////////////////////////////////////////////////////////////////////////
  574. // CDNS_MB_RecordPropertyPage
  575. CDNS_MB_RecordPropertyPage::CDNS_MB_RecordPropertyPage()
  576. : CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(IDD_RR_MB)
  577. {
  578. }
  579. ////////////////////////////////////////////////////////////////////////////
  580. // CDNS_MD_RecordPropertyPage
  581. CDNS_MD_RecordPropertyPage::CDNS_MD_RecordPropertyPage()
  582. : CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(IDD_RR_MD)
  583. {
  584. }
  585. ////////////////////////////////////////////////////////////////////////////
  586. // CDNS_MF_RecordPropertyPage
  587. CDNS_MF_RecordPropertyPage::CDNS_MF_RecordPropertyPage()
  588. : CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(IDD_RR_MF)
  589. {
  590. }
  591. ////////////////////////////////////////////////////////////////////////////
  592. // CDNS_MG_RecordPropertyPage
  593. CDNS_MG_RecordPropertyPage::CDNS_MG_RecordPropertyPage()
  594. : CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(IDD_RR_MG)
  595. {
  596. }
  597. BEGIN_MESSAGE_MAP(CDNS_MG_RecordPropertyPage, CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage)
  598. ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowse)
  599. END_MESSAGE_MAP()
  600. void CDNS_MG_RecordPropertyPage::OnBrowse()
  601. {
  602. STANDARD_REC_PP_PTRS(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record);
  603. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  604. FIX_THREAD_STATE_MFC_BUG();
  605. CThemeContextActivator activator;
  606. CDNSBrowserDlg dlg(GetHolder()->GetComponentData(), GetHolder(), RECORD_MB);
  607. if (IDOK == dlg.DoModal())
  608. {
  609. GetNameNodeEdit()->SetWindowText(dlg.GetSelectionString());
  610. }
  611. }
  612. ////////////////////////////////////////////////////////////////////////////
  613. // CDNS_MR_RecordPropertyPage
  614. BEGIN_MESSAGE_MAP(CDNS_MR_RecordPropertyPage, CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage)
  615. ON_EN_CHANGE(IDC_NAME_NODE_EDIT, OnNameNodeChange)
  616. ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowse)
  617. END_MESSAGE_MAP()
  618. CDNS_MR_RecordPropertyPage::CDNS_MR_RecordPropertyPage()
  619. : CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(IDD_RR_MR)
  620. {
  621. }
  622. void CDNS_MR_RecordPropertyPage::OnNameNodeChange()
  623. {
  624. //
  625. // Get the name from the data
  626. //
  627. CString szNameNode;
  628. GetNameNodeEdit()->GetWindowText(szNameNode);
  629. //
  630. // Get the new name of the record
  631. //
  632. CString szRecordName;
  633. GetEditBoxText(szRecordName);
  634. SetValidState(GetNameNodeEdit()->GetWindowTextLength() > 0 &&
  635. _wcsicmp(szNameNode, szRecordName) != 0);
  636. }
  637. void CDNS_MR_RecordPropertyPage::OnBrowse()
  638. {
  639. STANDARD_REC_PP_PTRS(CDNS_PTR_NS_CNAME_MB_MD_MF_MG_MR_Record);
  640. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  641. FIX_THREAD_STATE_MFC_BUG();
  642. CThemeContextActivator activator;
  643. CDNSBrowserDlg dlg(GetHolder()->GetComponentData(), GetHolder(), RECORD_MB);
  644. if (IDOK == dlg.DoModal())
  645. {
  646. GetNameNodeEdit()->SetWindowText(dlg.GetSelectionString());
  647. }
  648. }
  649. ////////////////////////////////////////////////////////////////////////////
  650. // CDNS_NSCache_RecordPropertyPage
  651. CDNS_NSCache_RecordPropertyPage::CDNS_NSCache_RecordPropertyPage()
  652. : CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(IDD_RR_NS_CACHE)
  653. {
  654. }
  655. ////////////////////////////////////////////////////////////////////////////
  656. // CDNS_PTR_RecordPropertyPage
  657. CDNS_PTR_RecordPropertyPage::CDNS_PTR_RecordPropertyPage()
  658. : CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage(IDD_RR_PTR)
  659. {
  660. m_bAdvancedView = TRUE;
  661. m_nOctets = -1; // invalid if advanced view
  662. }
  663. BEGIN_MESSAGE_MAP(CDNS_PTR_RecordPropertyPage,
  664. CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage)
  665. ON_EN_CHANGE(IDC_RR_NAME_IPEDIT, OnIPv4CtrlChange)
  666. END_MESSAGE_MAP()
  667. BOOL CDNS_PTR_RecordPropertyPage::OnInitDialog()
  668. {
  669. //
  670. // we call three levels up in the deriviation chain to enable/disable TTL control
  671. // we do not call the base class
  672. // CDNSRecordPropertyPage::OnInitDialog();
  673. //
  674. CDNSRecordStandardPropertyPage::OnInitDialog();
  675. //
  676. // move the edit box in place of the IP control
  677. //
  678. CDNSIPv4Control* pNameIPCtrl = GetIPv4Ctrl();
  679. CRect r;
  680. pNameIPCtrl->GetWindowRect(r);
  681. ScreenToClient(r);
  682. GetRRNameEdit()->MoveWindow(&r);
  683. //
  684. // set limit on node name length
  685. //
  686. GetNameNodeEdit()->SetLimitText(MAX_DNS_NAME_LEN);
  687. STANDARD_REC_PP_PTRS(CDNS_PTR_Record);
  688. CDNSZoneNode* pZoneNode = pHolder->GetDomainNode()->GetZoneNode();
  689. CDNSServerNode* pServerNode = pZoneNode->GetServerNode();
  690. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER_NEW_SECURITY_SETTINGS ||
  691. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  692. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER) ||
  693. !pHolder->IsWizardMode() ||
  694. !pZoneNode->IsDSIntegrated())
  695. {
  696. GetSecurityCheckCtrl()->ShowWindow(FALSE);
  697. GetSecurityCheckCtrl()->EnableWindow(FALSE);
  698. }
  699. return TRUE;
  700. }
  701. void CDNS_PTR_RecordPropertyPage::OnIPv4CtrlChange()
  702. {
  703. STANDARD_REC_PP_PTRS(CDNS_PTR_Record);
  704. CString s;
  705. CDNSDomainNode* pDomainNode = pHolder->GetDomainNode();
  706. CDNSIPv4Control* pNameIPCtrl = GetIPv4Ctrl();
  707. DWORD dwArr[4];
  708. pNameIPCtrl->GetArray(dwArr, IP_OCTET_COUNT);
  709. ASSERT(dwArr[m_nOctets] <= 255);
  710. if (dwArr[m_nOctets] != FIELD_EMPTY)
  711. {
  712. s.Format(_T("%d"), dwArr[m_nOctets]);
  713. for (int idx = m_nOctets + 1; idx < IP_OCTET_COUNT; idx++)
  714. {
  715. if (dwArr[idx] != FIELD_EMPTY)
  716. {
  717. CString szTemp;
  718. szTemp.Format(_T("%d."), dwArr[idx]);
  719. s = szTemp + s;
  720. }
  721. }
  722. s += CString(L".") + pDomainNode->GetFullName();
  723. }
  724. else
  725. {
  726. s = pDomainNode->GetFullName();
  727. }
  728. SetDlgItemText(IDC_RR_DOMAIN_EDIT, s);
  729. SetDirty(TRUE);
  730. }
  731. void CDNS_PTR_RecordPropertyPage::SetUIData()
  732. {
  733. STANDARD_REC_PP_PTRS(CDNS_PTR_Record);
  734. ASSERT(pRecord->GetType() == DNS_TYPE_PTR);
  735. CDNS_PTR_CNAME_MB_MD_MF_MG_MR_NSCache_RecordPropertyPage::SetUIData();
  736. //
  737. // get useful pointers
  738. //
  739. CDNSIPv4Control* pNameIPCtrl = GetIPv4Ctrl();
  740. CDNSRootData* pRootData = (CDNSRootData*)pHolder->GetComponentData()->GetRootData();
  741. ASSERT(pRootData != NULL);
  742. CDNSRecordNodeBase* pRecordNodeBase = pHolder->GetRecordNode();
  743. ASSERT(pRecordNodeBase != NULL);
  744. CDNSDomainNode* pDomainNode = pHolder->GetDomainNode();
  745. ASSERT(pDomainNode != NULL);
  746. //
  747. // set standard fields
  748. //
  749. GetTTLCtrl()->SetTTL(pRecord->m_dwTtlSeconds);
  750. GetRRNameEdit()->SetWindowText(pRecord->m_szNameNode);
  751. //
  752. // set the FQDN for the domain the record is in
  753. //
  754. GetDomainEditBox()->SetWindowText(pHolder->GetDomainNode()->GetFullName());
  755. m_bAdvancedView = pRootData->IsAdvancedView();
  756. //
  757. // force advanced view if we are in a forward lookup zone
  758. //
  759. if (!(pDomainNode->GetZoneNode()->IsReverse()))
  760. {
  761. m_bAdvancedView = TRUE;
  762. }
  763. //
  764. // determine if we can have a normal view representation
  765. //
  766. CString szDomainName = pDomainNode->GetFullName();
  767. if (!m_bAdvancedView)
  768. {
  769. //
  770. // to have normal view we have to have a valid arpa suffix
  771. //
  772. BOOL bArpa = RemoveInAddrArpaSuffix(szDomainName.GetBuffer(1));
  773. szDomainName.ReleaseBuffer(); // got "77.80.55.157"
  774. if (!bArpa)
  775. {
  776. m_bAdvancedView = TRUE; // no need to toggle
  777. }
  778. else
  779. {
  780. m_nOctets = ReverseIPString(szDomainName.GetBuffer(1));
  781. szDomainName.ReleaseBuffer(); // finally got "157.55.80.77"
  782. // to have a normal view representation we cannot
  783. // have more than 3 octects
  784. if (m_nOctets > 3)
  785. {
  786. m_bAdvancedView = TRUE; // force advanced for classless
  787. }
  788. else
  789. {
  790. ASSERT(m_nOctets > 0);
  791. if (pHolder->IsWizardMode())
  792. {
  793. szDomainName += _T(".0"); // placeholder
  794. }
  795. else
  796. {
  797. szDomainName += _T(".");
  798. szDomainName += ((CDNS_PTR_RecordNode*)pRecordNodeBase)->GetTrueRecordName();
  799. }
  800. switch(m_nOctets)
  801. {
  802. case 1: // e.g. "157", now "157._"
  803. szDomainName += _T(".0.0"); // got "157._.0.0"
  804. break;
  805. case 2: // e.g. "157.55"
  806. szDomainName += _T(".0"); // got "157.55._.0"
  807. break;
  808. };
  809. // set the IP control with IP mask value
  810. IP_ADDRESS ipAddr = IPStringToAddr(szDomainName);
  811. if (ipAddr != INADDR_NONE)
  812. {
  813. pNameIPCtrl->SetIPv4Val(ipAddr);
  814. switch(m_nOctets)
  815. {
  816. case 1:
  817. pNameIPCtrl->Clear(2);
  818. pNameIPCtrl->Clear(3);
  819. break;
  820. case 2:
  821. pNameIPCtrl->Clear(3);
  822. break;
  823. }
  824. // in wizard modeneed to disable all fields but the one to fill in
  825. if (pHolder->IsWizardMode())
  826. {
  827. for (int k=0; k<4; k++)
  828. pNameIPCtrl->EnableField(k, k >= m_nOctets);
  829. }
  830. }
  831. else
  832. {
  833. m_bAdvancedView = TRUE;
  834. }
  835. }
  836. }
  837. }
  838. //
  839. // view might have been changed to advanced
  840. //
  841. if (m_bAdvancedView)
  842. {
  843. GetRRNameEdit()->SetWindowText(pRecordNodeBase->GetDisplayName());
  844. }
  845. //
  846. // enable/hide appropriate controls
  847. //
  848. if (m_bAdvancedView)
  849. {
  850. pNameIPCtrl->EnableWindow(FALSE);
  851. pNameIPCtrl->ShowWindow(FALSE);
  852. //
  853. // can edit the name only when creating the record
  854. //
  855. GetRRNameEdit()->SetReadOnly(!pHolder->IsWizardMode());
  856. }
  857. else
  858. {
  859. GetRRNameEdit()->EnableWindow(FALSE);
  860. GetRRNameEdit()->ShowWindow(FALSE);
  861. //
  862. // can edit the name only when creating the record
  863. //
  864. pNameIPCtrl->EnableWindow(pHolder->IsWizardMode());
  865. }
  866. //
  867. // Set the aging/scavenging controls
  868. //
  869. GetDeleteStale()->SetCheck(pRecord->m_dwScavengeStart != 0);
  870. SetTimeStampEdit(pRecord->m_dwScavengeStart);
  871. }
  872. DNS_STATUS CDNS_PTR_RecordPropertyPage::GetUIDataEx(BOOL)
  873. {
  874. STANDARD_REC_PP_PTRS(CDNS_PTR_Record);
  875. GetTTLCtrl()->GetTTL(&(pRecord->m_dwTtlSeconds));
  876. GetNameNodeEdit()->GetWindowText(pRecord->m_szNameNode);
  877. //
  878. // only in wizard mode we can change the edit box content
  879. //
  880. if(pHolder->IsWizardMode())
  881. {
  882. CString s;
  883. CDNSRecordNodeBase* pRecordNode = pHolder->GetRecordNode();
  884. if (m_bAdvancedView)
  885. {
  886. //
  887. // No need to validate name for PTR in advanced mode
  888. //
  889. GetEditBoxText(s);
  890. ASSERT(!s.IsEmpty());
  891. }
  892. else // normal view
  893. {
  894. CDNSIPv4Control* pNameIPCtrl = GetIPv4Ctrl();
  895. DWORD dwArr[4];
  896. pNameIPCtrl->GetArray(dwArr, IP_OCTET_COUNT);
  897. ASSERT(dwArr[m_nOctets] <= 255);
  898. s.Format(_T("%d"), dwArr[m_nOctets]);
  899. for (int idx = m_nOctets + 1; idx < IP_OCTET_COUNT; idx++)
  900. {
  901. if (dwArr[idx] != FIELD_EMPTY)
  902. {
  903. CString szTemp;
  904. szTemp.Format(_T("%d."), dwArr[idx]);
  905. s = szTemp + s;
  906. }
  907. }
  908. }
  909. pRecordNode->SetRecordName(s,FALSE /*bAtTheNode*/);
  910. if (!m_bAdvancedView)
  911. {
  912. CDNSRecordNodeBase* pRecordNodeBase = pHolder->GetRecordNode();
  913. ASSERT(pRecordNodeBase != NULL);
  914. ((CDNS_PTR_RecordNode*)pRecordNodeBase)->ChangeDisplayName(pHolder->GetDomainNode(),
  915. m_bAdvancedView);
  916. }
  917. } // if wizard mode
  918. //
  919. // Get the aging/scavenging info from controls
  920. //
  921. if (GetDeleteStale()->GetCheck())
  922. {
  923. pRecord->m_dwFlags |= DNS_RPC_RECORD_FLAG_AGING_ON;
  924. }
  925. else
  926. {
  927. pRecord->m_dwFlags &= ~DNS_RPC_RECORD_FLAG_AGING_ON;
  928. }
  929. if (pHolder->IsWizardMode() &&
  930. GetSecurityCheckCtrl()->GetCheck())
  931. {
  932. pRecord->m_dwFlags |= DNS_RPC_FLAG_OPEN_ACL;
  933. }
  934. return 0;
  935. }
  936. ////////////////////////////////////////////////////////////////////////////
  937. // CDNS_MINFO_RP_RecordPropertyPage
  938. BEGIN_MESSAGE_MAP(CDNS_MINFO_RP_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  939. ON_EN_CHANGE(IDC_NAME_MAILBOX_EDIT, OnNameMailBoxChange)
  940. ON_EN_CHANGE(IDC_ERROR_MAILBOX_EDIT, OnErrorToMailboxChange)
  941. ON_BN_CLICKED(IDC_BROWSE_NAME_MAILBOX_BUTTON, OnBrowseNameMailBox)
  942. ON_BN_CLICKED(IDC_BROWSE_ERROR_MAILBOX_BUTTON, OnBrowseErrorToMailbox)
  943. END_MESSAGE_MAP()
  944. CDNS_MINFO_RP_RecordPropertyPage::
  945. CDNS_MINFO_RP_RecordPropertyPage(UINT nIDTemplate) :
  946. CDNSRecordStandardPropertyPage(nIDTemplate)
  947. {
  948. }
  949. void CDNS_MINFO_RP_RecordPropertyPage::OnNameMailBoxChange()
  950. {
  951. SetDirty(TRUE);
  952. }
  953. void CDNS_MINFO_RP_RecordPropertyPage::OnErrorToMailboxChange()
  954. {
  955. SetDirty(TRUE);
  956. }
  957. void CDNS_MINFO_RP_RecordPropertyPage::OnBrowseNameMailBox()
  958. {
  959. STANDARD_REC_PP_PTRS(CDNS_MINFO_RP_Record);
  960. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  961. FIX_THREAD_STATE_MFC_BUG();
  962. CThemeContextActivator activator;
  963. CDNSBrowserDlg dlg(pHolder->GetComponentData(), pHolder, RECORD_MB);
  964. if (IDOK == dlg.DoModal())
  965. {
  966. GetNameMailBoxCtrl()->SetWindowText(dlg.GetSelectionString());
  967. }
  968. }
  969. void CDNS_MINFO_RP_RecordPropertyPage::OnBrowseErrorToMailbox()
  970. {
  971. STANDARD_REC_PP_PTRS(CDNS_MINFO_RP_Record);
  972. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  973. FIX_THREAD_STATE_MFC_BUG();
  974. CThemeContextActivator activator;
  975. CDNSBrowserDlg dlg(pHolder->GetComponentData(), pHolder,
  976. (pRecord->m_wType == DNS_TYPE_RP) ? RECORD_TEXT : RECORD_MB);
  977. if (IDOK == dlg.DoModal())
  978. {
  979. GetErrorToMailboxCtrl()->SetWindowText(dlg.GetSelectionString());
  980. }
  981. }
  982. void CDNS_MINFO_RP_RecordPropertyPage::SetUIData()
  983. {
  984. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_MINFO_RP_Record);
  985. GetNameMailBoxCtrl()->SetLimitText(MAX_DNS_NAME_LEN);
  986. GetNameMailBoxCtrl()->SetWindowText(pRecord->m_szNameMailBox);
  987. GetErrorToMailboxCtrl()->SetLimitText(MAX_DNS_NAME_LEN);
  988. GetErrorToMailboxCtrl()->SetWindowText(pRecord->m_szErrorToMailbox);
  989. }
  990. DNS_STATUS CDNS_MINFO_RP_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  991. {
  992. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_MINFO_RP_Record);
  993. GetNameMailBoxCtrl()->GetWindowText(pRecord->m_szNameMailBox);
  994. GetErrorToMailboxCtrl()->GetWindowText(pRecord->m_szErrorToMailbox);
  995. return dwErr;
  996. }
  997. ////////////////////////////////////////////////////////////////////////////
  998. // CDNS_MINFO_RecordPropertyPage
  999. CDNS_MINFO_RecordPropertyPage::CDNS_MINFO_RecordPropertyPage()
  1000. : CDNS_MINFO_RP_RecordPropertyPage(IDD_RR_MINFO)
  1001. {
  1002. }
  1003. ////////////////////////////////////////////////////////////////////////////
  1004. // CDNS_RP_RecordPropertyPage
  1005. CDNS_RP_RecordPropertyPage::CDNS_RP_RecordPropertyPage()
  1006. : CDNS_MINFO_RP_RecordPropertyPage(IDD_RR_RP)
  1007. {
  1008. }
  1009. ////////////////////////////////////////////////////////////////////////////
  1010. // CDNS_MX_AFSDB_RT_RecordPropertyPage
  1011. BEGIN_MESSAGE_MAP(CDNS_MX_AFSDB_RT_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  1012. ON_EN_CHANGE(IDC_NAME_EXCHANGE_EDIT, OnNameExchangeChange)
  1013. ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowse)
  1014. END_MESSAGE_MAP()
  1015. CDNS_MX_AFSDB_RT_RecordPropertyPage::
  1016. CDNS_MX_AFSDB_RT_RecordPropertyPage(UINT nIDTemplate) :
  1017. CDNSRecordStandardPropertyPage(nIDTemplate)
  1018. {
  1019. }
  1020. void CDNS_MX_AFSDB_RT_RecordPropertyPage::OnNameExchangeChange()
  1021. {
  1022. SetDirty(TRUE);
  1023. }
  1024. void CDNS_MX_AFSDB_RT_RecordPropertyPage::OnBrowse()
  1025. {
  1026. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1027. FIX_THREAD_STATE_MFC_BUG();
  1028. CThemeContextActivator activator;
  1029. CDNSBrowserDlg dlg(GetHolder()->GetComponentData(), GetHolder(), RECORD_A);
  1030. if (IDOK == dlg.DoModal())
  1031. {
  1032. GetNameExchangeCtrl()->SetWindowText(dlg.GetSelectionString());
  1033. }
  1034. }
  1035. void CDNS_MX_AFSDB_RT_RecordPropertyPage::SetUIData()
  1036. {
  1037. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_MX_AFSDB_RT_Record);
  1038. GetNameExchangeCtrl()->SetLimitText(MAX_DNS_NAME_LEN);
  1039. GetNameExchangeCtrl()->SetWindowText(pRecord->m_szNameExchange);
  1040. }
  1041. DNS_STATUS CDNS_MX_AFSDB_RT_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  1042. {
  1043. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_MX_AFSDB_RT_Record);
  1044. CString szNameExchange;
  1045. GetNameExchangeCtrl()->GetWindowText(szNameExchange);
  1046. DWORD dwNameChecking = pHolder->GetDomainNode()->GetServerNode()->GetNameCheckFlag();
  1047. dwErr = ::ValidateDnsNameAgainstServerFlags(szNameExchange,
  1048. DnsNameHostnameFull,
  1049. dwNameChecking);
  1050. if (dwErr != 0)
  1051. {
  1052. return dwErr;
  1053. }
  1054. pRecord->m_szNameExchange = szNameExchange;
  1055. return dwErr;
  1056. }
  1057. ////////////////////////////////////////////////////////////////////////////
  1058. // CDNS_MX_RT_RecordPropertyPage
  1059. BEGIN_MESSAGE_MAP(CDNS_MX_RT_RecordPropertyPage, CDNS_MX_AFSDB_RT_RecordPropertyPage)
  1060. ON_EN_CHANGE(IDC_PREFERENCE_EDIT, OnPreferenceChange)
  1061. END_MESSAGE_MAP()
  1062. CDNS_MX_RT_RecordPropertyPage::
  1063. CDNS_MX_RT_RecordPropertyPage(UINT nIDTemplate) :
  1064. CDNS_MX_AFSDB_RT_RecordPropertyPage(nIDTemplate)
  1065. {
  1066. }
  1067. BOOL CDNS_MX_RT_RecordPropertyPage::OnInitDialog()
  1068. {
  1069. CDNS_MX_AFSDB_RT_RecordPropertyPage::OnInitDialog();
  1070. VERIFY(m_preferenceEdit.SubclassDlgItem(IDC_PREFERENCE_EDIT, this));
  1071. m_preferenceEdit.SetRange(0,0xffff ); // unsigned short
  1072. // Disable IME support on the control
  1073. ImmAssociateContext(m_preferenceEdit.GetSafeHwnd(), NULL);
  1074. return TRUE;
  1075. }
  1076. void CDNS_MX_RT_RecordPropertyPage::OnPreferenceChange()
  1077. {
  1078. SetDirty(TRUE);
  1079. }
  1080. void CDNS_MX_RT_RecordPropertyPage::SetUIData()
  1081. {
  1082. STANDARD_REC_PP_PTRS(CDNS_MX_AFSDB_RT_Record)
  1083. CDNS_MX_AFSDB_RT_RecordPropertyPage::SetUIData();
  1084. VERIFY(m_preferenceEdit.SetVal(pRecord->m_wPreference));
  1085. }
  1086. DNS_STATUS CDNS_MX_RT_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  1087. {
  1088. STANDARD_REC_PP_PTRS(CDNS_MX_AFSDB_RT_Record)
  1089. DNS_STATUS dwErr = CDNS_MX_AFSDB_RT_RecordPropertyPage::GetUIDataEx(bSilent);
  1090. pRecord->m_wPreference = (WORD)m_preferenceEdit.GetVal();
  1091. return dwErr;
  1092. }
  1093. ////////////////////////////////////////////////////////////////////////////
  1094. // CDNS_MX_RecordPropertyPage
  1095. CDNS_MX_RecordPropertyPage::CDNS_MX_RecordPropertyPage()
  1096. : CDNS_MX_RT_RecordPropertyPage(IDD_RR_MX)
  1097. {
  1098. }
  1099. DNS_STATUS CDNS_MX_RecordPropertyPage::ValidateRecordName(PCWSTR pszName, DWORD dwNameChecking)
  1100. {
  1101. CDNSRecordPropertyPageHolder* pHolder = GetDNSRecordHolder();
  1102. CDNSRootData* pRootData = (CDNSRootData*)pHolder->GetComponentData()->GetRootData();
  1103. ASSERT(pRootData != NULL);
  1104. if (pRootData->IsAdvancedView())
  1105. {
  1106. //
  1107. // Don't validate the name in advanced view
  1108. //
  1109. return 0;
  1110. }
  1111. DNS_STATUS dwError = CDNSRecordStandardPropertyPage::ValidateRecordName(pszName, dwNameChecking);
  1112. if (dwError != 0)
  1113. {
  1114. DNS_STATUS dwWildcardError = ::ValidateDnsNameAgainstServerFlags(pszName, DnsNameWildcard, dwNameChecking);
  1115. if (dwWildcardError == 0)
  1116. {
  1117. dwError = 0;
  1118. }
  1119. }
  1120. return dwError;
  1121. }
  1122. ////////////////////////////////////////////////////////////////////////////
  1123. // CDNS_RT_RecordPropertyPage
  1124. CDNS_RT_RecordPropertyPage::CDNS_RT_RecordPropertyPage()
  1125. : CDNS_MX_RT_RecordPropertyPage(IDD_RR_RT)
  1126. {
  1127. }
  1128. /////////////////////////////////////////////////////////////////////////////
  1129. // CDNS_AFSDB_RecordPropertyPage
  1130. BEGIN_MESSAGE_MAP(CDNS_AFSDB_RecordPropertyPage, CDNS_MX_AFSDB_RT_RecordPropertyPage)
  1131. ON_EN_CHANGE(IDC_SUBTYPE_EDIT, OnSubtypeEditChange)
  1132. ON_BN_CLICKED(IDC_AFS_VLS_RADIO, OnSubtypeRadioChange)
  1133. ON_BN_CLICKED(IDC_DCE_ANS_RADIO, OnSubtypeRadioChange)
  1134. ON_BN_CLICKED(IDC_OTHER_RADIO, OnSubtypeRadioChange)
  1135. END_MESSAGE_MAP()
  1136. CDNS_AFSDB_RecordPropertyPage::CDNS_AFSDB_RecordPropertyPage()
  1137. : CDNS_MX_AFSDB_RT_RecordPropertyPage(IDD_RR_AFSDB)
  1138. {
  1139. }
  1140. BOOL CDNS_AFSDB_RecordPropertyPage::OnInitDialog()
  1141. {
  1142. CDNS_MX_AFSDB_RT_RecordPropertyPage::OnInitDialog();
  1143. VERIFY(m_subtypeEdit.SubclassDlgItem(IDC_SUBTYPE_EDIT, this));
  1144. m_subtypeEdit.SetRange(0,0xffff); // unsigned short
  1145. m_subtypeEdit.SetLimitText(5);
  1146. // Disable IME support on the controls
  1147. ImmAssociateContext(m_subtypeEdit.GetSafeHwnd(), NULL);
  1148. return TRUE;
  1149. }
  1150. void CDNS_AFSDB_RecordPropertyPage::OnSubtypeEditChange()
  1151. {
  1152. SetDirty(TRUE);
  1153. }
  1154. void CDNS_AFSDB_RecordPropertyPage::OnSubtypeRadioChange()
  1155. {
  1156. STANDARD_REC_PP_PTRS(CDNS_MX_AFSDB_RT_Record)
  1157. CButton* pAFSRadioButton = GetAFSRadioButton();
  1158. CButton* pDCERadioButton = GetDCERadioButton();
  1159. if (pAFSRadioButton->GetCheck())
  1160. {
  1161. m_subtypeEdit.EnableWindow(FALSE);
  1162. m_subtypeEdit.SetWindowText(NULL);
  1163. pRecord->m_wPreference = AFSDB_PREF_AFS_CELL_DB_SERV;
  1164. }
  1165. else if (pDCERadioButton->GetCheck())
  1166. {
  1167. m_subtypeEdit.EnableWindow(FALSE);
  1168. m_subtypeEdit.SetWindowText(NULL);
  1169. pRecord->m_wPreference = AFSDB_PREF_DCE_AUTH_NAME_SERV;
  1170. }
  1171. else
  1172. {
  1173. ASSERT(GetOtherRadioButton()->GetCheck());
  1174. m_subtypeEdit.EnableWindow(TRUE);
  1175. VERIFY(m_subtypeEdit.SetVal(pRecord->m_wPreference));
  1176. }
  1177. SetDirty(TRUE);
  1178. }
  1179. void CDNS_AFSDB_RecordPropertyPage::SetUIData()
  1180. {
  1181. STANDARD_REC_PP_PTRS(CDNS_MX_AFSDB_RT_Record)
  1182. CDNS_MX_AFSDB_RT_RecordPropertyPage::SetUIData();
  1183. CButton* pAFSRadioButton = GetAFSRadioButton();
  1184. CButton* pDCERadioButton = GetDCERadioButton();
  1185. CButton* pOtherRadioButton = GetOtherRadioButton();
  1186. switch (pRecord->m_wPreference)
  1187. {
  1188. case AFSDB_PREF_AFS_CELL_DB_SERV:
  1189. {
  1190. pAFSRadioButton->SetCheck(TRUE);
  1191. pDCERadioButton->SetCheck(FALSE);
  1192. pOtherRadioButton->SetCheck(FALSE);
  1193. m_subtypeEdit.EnableWindow(FALSE);
  1194. m_subtypeEdit.SetWindowText(L"");
  1195. }
  1196. break;
  1197. case AFSDB_PREF_DCE_AUTH_NAME_SERV:
  1198. {
  1199. pAFSRadioButton->SetCheck(FALSE);
  1200. pDCERadioButton->SetCheck(TRUE);
  1201. pOtherRadioButton->SetCheck(FALSE);
  1202. m_subtypeEdit.EnableWindow(FALSE);
  1203. m_subtypeEdit.SetWindowText(L"");
  1204. }
  1205. break;
  1206. default:
  1207. {
  1208. pAFSRadioButton->SetCheck(FALSE);
  1209. pDCERadioButton->SetCheck(FALSE);
  1210. pOtherRadioButton->SetCheck(TRUE);
  1211. m_subtypeEdit.EnableWindow(TRUE);
  1212. VERIFY(m_subtypeEdit.SetVal(pRecord->m_wPreference));
  1213. }
  1214. }
  1215. }
  1216. DNS_STATUS CDNS_AFSDB_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  1217. {
  1218. STANDARD_REC_PP_PTRS(CDNS_MX_AFSDB_RT_Record)
  1219. DNS_STATUS dwErr = CDNS_MX_AFSDB_RT_RecordPropertyPage::GetUIDataEx(bSilent);
  1220. CButton* pAFSRadioButton = GetAFSRadioButton();
  1221. CButton* pDCERadioButton = GetDCERadioButton();
  1222. if (pAFSRadioButton->GetCheck())
  1223. {
  1224. pRecord->m_wPreference = AFSDB_PREF_AFS_CELL_DB_SERV;
  1225. }
  1226. else if (pDCERadioButton->GetCheck())
  1227. {
  1228. pRecord->m_wPreference = AFSDB_PREF_DCE_AUTH_NAME_SERV;
  1229. }
  1230. else
  1231. {
  1232. ASSERT(GetOtherRadioButton()->GetCheck());
  1233. pRecord->m_wPreference = (WORD)m_subtypeEdit.GetVal();
  1234. }
  1235. return dwErr;
  1236. }
  1237. ////////////////////////////////////////////////////////////////////////////
  1238. // CDNS_WKS_RecordPropertyPage
  1239. BEGIN_MESSAGE_MAP(CDNS_WKS_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  1240. ON_EN_CHANGE(IDC_IPEDIT, OnIPv4CtrlChange)
  1241. ON_BN_CLICKED(IDC_TCP_RADIO, OnProtocolRadioChange)
  1242. ON_BN_CLICKED(IDC_UDP_RADIO, OnProtocolRadioChange)
  1243. ON_EN_CHANGE(IDC_SERVICES_EDIT, OnServicesEditChange)
  1244. END_MESSAGE_MAP()
  1245. CDNS_WKS_RecordPropertyPage::CDNS_WKS_RecordPropertyPage()
  1246. : CDNSRecordStandardPropertyPage(IDD_RR_WKS)
  1247. {
  1248. }
  1249. BOOL CDNS_WKS_RecordPropertyPage::CreateRecord()
  1250. {
  1251. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  1252. ASSERT(pHolder->IsWizardMode());
  1253. //
  1254. // Get the data from the UI
  1255. //
  1256. DNS_STATUS err = GetUIDataEx(FALSE);
  1257. if (err != 0)
  1258. {
  1259. DNSErrorDialog(err,IDS_MSG_RECORD_CREATE_FAILED);
  1260. return FALSE;
  1261. }
  1262. //
  1263. // Create the new record
  1264. //
  1265. err = pHolder->CreateNewRecord(CanCreateDuplicateRecords());
  1266. if (err != 0)
  1267. {
  1268. if (err == DNS_ERROR_INVALID_DATA)
  1269. {
  1270. //
  1271. // Filter out invalid data error and present a more meaningful error message
  1272. //
  1273. DNSMessageBox(IDS_ERRMSG_WKS_INVALID_DATA);
  1274. }
  1275. else
  1276. {
  1277. DNSErrorDialog(err,IDS_MSG_RECORD_CREATE_FAILED);
  1278. }
  1279. return FALSE;
  1280. }
  1281. return TRUE;
  1282. }
  1283. void CDNS_WKS_RecordPropertyPage::OnIPv4CtrlChange()
  1284. {
  1285. STANDARD_REC_PP_PTRS(CDNS_WKS_Record)
  1286. SetDirty(TRUE);
  1287. }
  1288. void CDNS_WKS_RecordPropertyPage::OnProtocolRadioChange()
  1289. {
  1290. STANDARD_REC_PP_PTRS(CDNS_WKS_Record)
  1291. CButton* pTCPRadio = GetTCPRadioButton();
  1292. CButton* pUDPRadio = GetUDPRadioButton();
  1293. if (pTCPRadio->GetCheck())
  1294. {
  1295. pUDPRadio->SetCheck(FALSE);
  1296. }
  1297. else if (pUDPRadio->GetCheck())
  1298. {
  1299. pTCPRadio->SetCheck(FALSE);
  1300. }
  1301. SetDirty(TRUE);
  1302. }
  1303. void CDNS_WKS_RecordPropertyPage::OnServicesEditChange()
  1304. {
  1305. SetDirty(TRUE);
  1306. }
  1307. void CDNS_WKS_RecordPropertyPage::SetUIData()
  1308. {
  1309. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_WKS_Record);
  1310. GetIPv4Ctrl()->SetIPv4Val(pRecord->m_ipAddress);
  1311. CButton* pTCPRadio = GetTCPRadioButton();
  1312. CButton* pUDPRadio = GetUDPRadioButton();
  1313. if (pRecord->m_chProtocol == DNS_WKS_PROTOCOL_TCP)
  1314. {
  1315. pTCPRadio->SetCheck(TRUE);
  1316. pUDPRadio->SetCheck(FALSE);
  1317. }
  1318. else // assume UDP
  1319. {
  1320. ASSERT(pRecord->m_chProtocol == DNS_WKS_PROTOCOL_UDP);
  1321. pTCPRadio->SetCheck(FALSE);
  1322. pUDPRadio->SetCheck(TRUE);
  1323. }
  1324. GetServicesEdit()->SetWindowText(pRecord->m_szServiceList);
  1325. }
  1326. DNS_STATUS CDNS_WKS_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  1327. {
  1328. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_WKS_Record);
  1329. GetIPv4Ctrl()->GetIPv4Val(&(pRecord->m_ipAddress));
  1330. if (GetTCPRadioButton()->GetCheck())
  1331. {
  1332. pRecord->m_chProtocol = DNS_WKS_PROTOCOL_TCP;
  1333. }
  1334. else
  1335. {
  1336. ASSERT(GetUDPRadioButton()->GetCheck());
  1337. pRecord->m_chProtocol = DNS_WKS_PROTOCOL_UDP;
  1338. }
  1339. GetServicesEdit()->GetWindowText(pRecord->m_szServiceList);
  1340. return dwErr;
  1341. }
  1342. ////////////////////////////////////////////////////////////////////////////
  1343. // CDNS_SRV_RecordPropertyPage
  1344. // Added by JEFFJON 2/26/99
  1345. // The following is used to prime the services, protocol, and port combo/edit boxes
  1346. //
  1347. struct SERVICE
  1348. {
  1349. LPCWSTR lpszService;
  1350. LPCWSTR protocolArr[2];
  1351. UINT uiPort;
  1352. };
  1353. // WARNING!!! REVIEW_JEFFJON : this has to be in alphabetical order on the lpszService field
  1354. // or else everything breaks below
  1355. SERVICE services[] = { L"_finger", { L"_tcp", L"_udp" }, 79 ,
  1356. L"_ftp", { L"_tcp", L"_udp" }, 21 ,
  1357. L"_http", { L"_tcp", L"_udp" }, 80 ,
  1358. L"_kerberos", { L"_tcp", L"_udp" }, 88 ,
  1359. L"_ldap", { L"_tcp", L"_udp" }, 389 ,
  1360. L"_nntp", { L"_tcp", L"_udp" }, 119 ,
  1361. L"_telnet", { L"_tcp", L"_udp" }, 23 ,
  1362. L"_whois", { L"_tcp", NULL }, 43 ,
  1363. NULL, { NULL }, 0 };
  1364. BOOL CALLBACK _ComboEnumChildWndProc(HWND hwnd, LPARAM lParam)
  1365. {
  1366. HWND* pHwnd = (HWND*)lParam;
  1367. *pHwnd = hwnd;
  1368. return TRUE;
  1369. }
  1370. BOOL CDNS_SRV_RR_ComboBox::Initialize(UINT nCtrlID, CWnd* pParent)
  1371. {
  1372. if (!SubclassDlgItem(nCtrlID, pParent))
  1373. {
  1374. return FALSE;
  1375. }
  1376. HWND hwndChildEdit = NULL;
  1377. EnumChildWindows(GetSafeHwnd(),_ComboEnumChildWndProc, (LPARAM)&hwndChildEdit);
  1378. ASSERT(hwndChildEdit != NULL);
  1379. ::SendMessage(hwndChildEdit, EM_LIMITTEXT, MAX_DNS_NAME_LEN, 0);
  1380. return TRUE;
  1381. }
  1382. #define SRV_RR_PROTOCOL_COMBO_ITEM_COUNT 2
  1383. BEGIN_MESSAGE_MAP(CDNS_SRV_RecordPropertyPage, CDNSRecordStandardPropertyPage)
  1384. ON_CBN_EDITCHANGE(IDC_SERVICE_NAME_COMBO, OnServiceComboEditChange)
  1385. ON_CBN_EDITCHANGE(IDC_PROTOCOL_NAME_COMBO, OnProtocolComboEditChange)
  1386. ON_CBN_SELCHANGE(IDC_SERVICE_NAME_COMBO, OnServiceComboSelChange)
  1387. ON_CBN_SELCHANGE(IDC_PROTOCOL_NAME_COMBO, OnProtocolComboSelChange)
  1388. ON_EN_CHANGE(IDC_PRIORITY_EDIT, OnNumericEditChange)
  1389. ON_EN_CHANGE(IDC_WEIGHT_EDIT, OnNumericEditChange)
  1390. ON_EN_CHANGE(IDC_PORT_EDIT, OnNumericEditChange)
  1391. ON_EN_CHANGE(IDC_NAME_TARGET_EDIT, OnNameTargetEditChange)
  1392. END_MESSAGE_MAP()
  1393. CDNS_SRV_RecordPropertyPage::CDNS_SRV_RecordPropertyPage()
  1394. : CDNSRecordStandardPropertyPage(IDD_RR_SRV)
  1395. {
  1396. m_pOldDomainNode = NULL;
  1397. m_pSubdomainNode = NULL;
  1398. m_bCreateSubdomain = FALSE;
  1399. m_bSubdomainCreated = FALSE;
  1400. m_bCreated = FALSE;
  1401. }
  1402. void CDNS_SRV_RecordPropertyPage::OnInitName()
  1403. {
  1404. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  1405. //
  1406. // initialize combo boxes
  1407. //
  1408. VERIFY(m_serviceCombo.Initialize(IDC_SERVICE_NAME_COMBO, this));
  1409. VERIFY(m_protocolCombo.Initialize(IDC_PROTOCOL_NAME_COMBO, this));
  1410. //
  1411. // limit the text length the user can type
  1412. //
  1413. int nUTF8ParentLen = UTF8StringLen(pHolder->GetDomainNode()->GetFullName());
  1414. m_serviceCombo.LimitText(MAX_DNS_NAME_LEN - nUTF8ParentLen - 1); // count dot when chaining
  1415. m_protocolCombo.LimitText(MAX_DNS_NAME_LEN - nUTF8ParentLen - 1); // count dot when chaining
  1416. //
  1417. // can edit/change combos only when creating the record
  1418. //
  1419. m_serviceCombo.EnableWindow(GetHolder()->IsWizardMode());
  1420. m_protocolCombo.EnableWindow(GetHolder()->IsWizardMode());
  1421. //
  1422. // set the FQDN for the parent of the domain the record is in
  1423. //
  1424. CEdit* pEdit = GetDomainEditBox();
  1425. CDNSDomainNode* pDomainNode = pHolder->GetDomainNode();
  1426. if (pHolder->IsWizardMode())
  1427. {
  1428. pEdit->SetWindowText(pDomainNode->GetFullName());
  1429. }
  1430. else
  1431. {
  1432. if (!pDomainNode->IsZone())
  1433. {
  1434. CDNSDomainNode* pParentDomainNode = dynamic_cast<CDNSDomainNode*>(pDomainNode->GetContainer());
  1435. ASSERT(pParentDomainNode != NULL);
  1436. pEdit->SetWindowText(pParentDomainNode->GetFullName());
  1437. }
  1438. else
  1439. {
  1440. //
  1441. // SRV record can be at the zone level if the _<protocol> domain was delegated
  1442. //
  1443. CDNSZoneNode* pZoneNode = dynamic_cast<CDNSZoneNode*>(pDomainNode);
  1444. ASSERT(pZoneNode != NULL);
  1445. if (pZoneNode != NULL)
  1446. {
  1447. pEdit->SetWindowText(pZoneNode->GetFullName());
  1448. }
  1449. }
  1450. }
  1451. }
  1452. void CDNS_SRV_RecordPropertyPage::PrimeServicesCombo()
  1453. {
  1454. m_serviceCombo.ResetContent();
  1455. SERVICE* service = services;
  1456. while (service->lpszService != NULL)
  1457. {
  1458. m_serviceCombo.AddString(service->lpszService);
  1459. service++;
  1460. }
  1461. }
  1462. void CDNS_SRV_RecordPropertyPage::OnSetName(CDNSRecordNodeBase* pRecordNode)
  1463. {
  1464. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  1465. if (pHolder->IsWizardMode())
  1466. {
  1467. m_serviceCombo.SetCurSel(0);
  1468. m_protocolCombo.SetCurSel(0);
  1469. }
  1470. else
  1471. {
  1472. //
  1473. // service name is the RR record name
  1474. //
  1475. m_serviceCombo.SetWindowText(pRecordNode->GetDisplayName());
  1476. //
  1477. // protocol name from the parent domain FQDN
  1478. //
  1479. if (!pRecordNode->GetDomainNode()->IsZone())
  1480. {
  1481. m_protocolCombo.SetWindowText(pRecordNode->GetDomainNode()->GetDisplayName());
  1482. }
  1483. else
  1484. {
  1485. //
  1486. // The SRV record can be at the zone level if the _<protocol> domain
  1487. // was delegated
  1488. //
  1489. CString szZoneName = pRecordNode->GetDomainNode()->GetFullName();
  1490. //
  1491. // Retrieve a single label
  1492. //
  1493. int iDot = szZoneName.Find(L'.');
  1494. if (iDot != -1)
  1495. {
  1496. szZoneName = szZoneName.Left(iDot);
  1497. }
  1498. m_protocolCombo.SetWindowText(szZoneName);
  1499. }
  1500. }
  1501. }
  1502. void CDNS_SRV_RecordPropertyPage::OnGetName(CString& s)
  1503. {
  1504. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  1505. ASSERT(pHolder->IsWizardMode());
  1506. //
  1507. // the service name is going to be the name of the RR record
  1508. //
  1509. m_serviceCombo.GetWindowText(s);
  1510. //
  1511. // the protocol name is going to be the name of the created folder
  1512. //
  1513. m_protocolCombo.GetWindowText(m_szProtocolName);
  1514. if (m_bCreated)
  1515. {
  1516. return;
  1517. }
  1518. //
  1519. // find a subfolder in the UI for the protocol
  1520. //
  1521. if (m_pSubdomainNode == NULL)
  1522. {
  1523. CDNSDomainNode* pCurrentDomainNode = pHolder->GetDomainNode();
  1524. //
  1525. // Retrieve the FQDN
  1526. // First check to see if the current domain node is a protocol domain
  1527. // if not then check for a subdomain that is
  1528. //
  1529. CString szCurrentDomainName = pCurrentDomainNode->GetFullName();
  1530. int iDot = szCurrentDomainName.Find(L'.');
  1531. if (iDot != -1)
  1532. {
  1533. szCurrentDomainName = szCurrentDomainName.Left(iDot);
  1534. }
  1535. CDNSDomainNode* pSubdomainNode = NULL;
  1536. if (_wcsicmp(szCurrentDomainName, m_szProtocolName) == 0)
  1537. {
  1538. pSubdomainNode = pCurrentDomainNode;
  1539. }
  1540. else
  1541. {
  1542. CString szSubdomainFQDN;
  1543. szSubdomainFQDN.Format(_T("%s.%s"), m_szProtocolName, pCurrentDomainNode->GetFullName());
  1544. //
  1545. // Find the sub-domain node
  1546. //
  1547. pSubdomainNode = pCurrentDomainNode->FindSubdomainNode(szSubdomainFQDN);
  1548. }
  1549. if (pSubdomainNode == NULL)
  1550. {
  1551. //
  1552. // If sub-domain doesn't exist, create it
  1553. //
  1554. pSubdomainNode = pCurrentDomainNode->CreateSubdomainNode();
  1555. ASSERT(pSubdomainNode != NULL);
  1556. CComponentDataObject* pComponentData = pHolder->GetComponentData();
  1557. CDNSRootData* pRootData = (CDNSRootData*)pComponentData->GetRootData();
  1558. pCurrentDomainNode->SetSubdomainName(pSubdomainNode, m_szProtocolName,
  1559. pRootData->IsAdvancedView());
  1560. m_bCreateSubdomain = TRUE;
  1561. }
  1562. //
  1563. // move down one level
  1564. //
  1565. m_pOldDomainNode = pCurrentDomainNode;
  1566. m_pSubdomainNode = pSubdomainNode;
  1567. pHolder->SetContainerNode(pSubdomainNode);
  1568. pHolder->GetRecordNode()->SetContainer(m_pSubdomainNode);
  1569. }
  1570. }
  1571. BOOL CDNS_SRV_RecordPropertyPage::CreateRecord()
  1572. {
  1573. if (m_bCreated)
  1574. {
  1575. return TRUE;
  1576. }
  1577. //
  1578. // create a subfolder i the server, if needed
  1579. //
  1580. if (m_bCreateSubdomain && !m_bSubdomainCreated)
  1581. {
  1582. DNS_STATUS err = m_pOldDomainNode->CreateSubdomain(m_pSubdomainNode,
  1583. GetHolder()->GetComponentData());
  1584. if (err != 0)
  1585. {
  1586. DNSErrorDialog(err,IDS_MSG_RECORD_CREATE_FAILED);
  1587. m_bCreated = FALSE;
  1588. //
  1589. // something went wrong, bail out
  1590. //
  1591. delete m_pSubdomainNode;
  1592. m_pSubdomainNode = NULL;
  1593. GetHolder()->SetContainerNode(m_pOldDomainNode);
  1594. ((CDNSRecordPropertyPageHolder*)GetHolder())->GetRecordNode()->SetContainer(m_pOldDomainNode);
  1595. return FALSE;
  1596. }
  1597. m_bSubdomainCreated = TRUE;
  1598. //
  1599. // mark the node as enumerated and force transition to "loaded"
  1600. //
  1601. m_pSubdomainNode->MarkEnumeratedAndLoaded(GetHolder()->GetComponentData());
  1602. }
  1603. m_pSubdomainNode = NULL;
  1604. if (!CDNSRecordStandardPropertyPage::CreateRecord())
  1605. {
  1606. m_bCreated = FALSE;
  1607. return FALSE;
  1608. }
  1609. m_bCreated = TRUE;
  1610. return TRUE;
  1611. }
  1612. void CDNS_SRV_RecordPropertyPage::OnNumericEditChange()
  1613. {
  1614. SetDirty(TRUE);
  1615. }
  1616. void CDNS_SRV_RecordPropertyPage::OnNameTargetEditChange()
  1617. {
  1618. SetDirty(TRUE);
  1619. }
  1620. void CDNS_SRV_RecordPropertyPage::OnServiceComboEditChange()
  1621. {
  1622. CString szText;
  1623. m_serviceCombo.GetWindowText(szText);
  1624. GetHolder()->EnableSheetControl(IDOK,!szText.IsEmpty());
  1625. }
  1626. void CDNS_SRV_RecordPropertyPage::OnProtocolComboEditChange()
  1627. {
  1628. CString szText;
  1629. m_protocolCombo.GetWindowText(szText);
  1630. GetHolder()->EnableSheetControl(IDOK,!szText.IsEmpty());
  1631. }
  1632. void CDNS_SRV_RecordPropertyPage::OnServiceComboSelChange()
  1633. {
  1634. GetHolder()->EnableSheetControl(IDOK, TRUE);
  1635. m_protocolCombo.ResetContent();
  1636. int nSel = m_serviceCombo.GetCurSel();
  1637. for (int idx = 0; idx < SRV_RR_PROTOCOL_COMBO_ITEM_COUNT; idx++)
  1638. {
  1639. if (services[nSel].protocolArr[idx] != NULL)
  1640. {
  1641. m_protocolCombo.AddString(services[nSel].protocolArr[idx]);
  1642. }
  1643. }
  1644. m_protocolCombo.SetCurSel(0);
  1645. m_portEdit.SetVal(services[nSel].uiPort);
  1646. }
  1647. void CDNS_SRV_RecordPropertyPage::OnProtocolComboSelChange()
  1648. {
  1649. GetHolder()->EnableSheetControl(IDOK, TRUE);
  1650. }
  1651. void CDNS_SRV_RecordPropertyPage::SetUIData()
  1652. {
  1653. STANDARD_REC_PP_SETUI_PROLOGUE(CDNS_SRV_Record);
  1654. VERIFY(m_priorityEdit.SetVal(pRecord->m_wPriority));
  1655. VERIFY(m_weightEdit.SetVal(pRecord->m_wWeight));
  1656. if (pRecord->m_wPort != 0)
  1657. {
  1658. VERIFY(m_portEdit.SetVal(pRecord->m_wPort));
  1659. }
  1660. GetNameTargetEdit()->SetLimitText(MAX_DNS_NAME_LEN);
  1661. GetNameTargetEdit()->SetWindowText(pRecord->m_szNameTarget);
  1662. }
  1663. DNS_STATUS CDNS_SRV_RecordPropertyPage::GetUIDataEx(BOOL bSilent)
  1664. {
  1665. STANDARD_REC_PP_GETUI_PROLOGUE(CDNS_SRV_Record);
  1666. ASSERT(dwErr == 0);
  1667. pRecord->m_wPriority = (WORD)m_priorityEdit.GetVal();
  1668. pRecord->m_wWeight = (WORD)m_weightEdit.GetVal();
  1669. pRecord->m_wPort = (WORD)m_portEdit.GetVal();
  1670. GetNameTargetEdit()->GetWindowText(pRecord->m_szNameTarget);
  1671. if (pHolder->IsWizardMode() &&
  1672. GetSecurityCheckCtrl()->GetCheck())
  1673. {
  1674. pRecord->m_dwFlags |= DNS_RPC_FLAG_OPEN_ACL;
  1675. }
  1676. return 0;
  1677. }
  1678. BOOL CDNS_SRV_RecordPropertyPage::OnInitDialog()
  1679. {
  1680. CDNSRecordStandardPropertyPage::OnInitDialog();
  1681. VERIFY(m_priorityEdit.SubclassDlgItem(IDC_PRIORITY_EDIT, this));
  1682. m_priorityEdit.SetRange(0,0xffff ); // unsigned short
  1683. VERIFY(m_weightEdit.SubclassDlgItem(IDC_WEIGHT_EDIT, this));
  1684. m_weightEdit.SetRange(0,0xffff ); // unsigned short
  1685. VERIFY(m_portEdit.SubclassDlgItem(IDC_PORT_EDIT, this));
  1686. m_portEdit.SetRange(0,0xffff ); // unsigned short
  1687. //
  1688. // Disable IME support on the controls
  1689. //
  1690. ImmAssociateContext(m_priorityEdit.GetSafeHwnd(), NULL);
  1691. ImmAssociateContext(m_weightEdit.GetSafeHwnd(), NULL);
  1692. ImmAssociateContext(m_portEdit.GetSafeHwnd(), NULL);
  1693. //
  1694. // This has to be done after both m_serviceCombo and m_protocolCombo have been initialized
  1695. //
  1696. PrimeServicesCombo();
  1697. m_serviceCombo.SetCurSel(0);
  1698. OnServiceComboSelChange();
  1699. //
  1700. // Only enable the security checkbox if we are talking to a 2473 or greater
  1701. // Whistler server
  1702. //
  1703. CDNSRecordPropertyPageHolder* pHolder = (CDNSRecordPropertyPageHolder*)GetHolder();
  1704. CDNSZoneNode* pZoneNode = pHolder->GetDomainNode()->GetZoneNode();
  1705. CDNSServerNode* pServerNode = pZoneNode->GetServerNode();
  1706. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER_NEW_SECURITY_SETTINGS ||
  1707. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  1708. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER) ||
  1709. !pHolder->IsWizardMode() ||
  1710. !pZoneNode->IsDSIntegrated())
  1711. {
  1712. GetSecurityCheckCtrl()->ShowWindow(FALSE);
  1713. GetSecurityCheckCtrl()->EnableWindow(FALSE);
  1714. }
  1715. // Set the focus to the Service combo box
  1716. m_serviceCombo.SetFocus();
  1717. return FALSE;
  1718. }
  1719. ////////////////////////////////////////////////////////////////////////
  1720. // CNewHostDialog
  1721. BEGIN_MESSAGE_MAP(CNewHostDialog, CHelpDialog)
  1722. ON_EN_CHANGE(IDC_RR_NAME_EDIT, OnEditChange)
  1723. ON_BN_CLICKED(IDC_BUTTON_ADDHOST, OnAddHost)
  1724. END_MESSAGE_MAP()
  1725. CNewHostDialog::CNewHostDialog(CDNSDomainNode* pParentDomainNode,
  1726. CComponentDataObject* pComponentData)
  1727. : CHelpDialog(IDD_DOMAIN_ADDNEWHOST, pComponentData)
  1728. {
  1729. ASSERT(pParentDomainNode != NULL);
  1730. ASSERT(pComponentData != NULL);
  1731. m_pParentDomainNode = pParentDomainNode;
  1732. m_pComponentData = pComponentData;
  1733. m_nUTF8ParentLen = UTF8StringLen(pParentDomainNode->GetFullName());
  1734. m_pTempDNSRecord = new CDNS_A_Record;
  1735. if (m_pTempDNSRecord)
  1736. {
  1737. m_pTempDNSRecord->m_dwTtlSeconds = m_pParentDomainNode->GetDefaultTTL();
  1738. }
  1739. m_bFirstCreation = TRUE;
  1740. }
  1741. CNewHostDialog::~CNewHostDialog()
  1742. {
  1743. delete m_pTempDNSRecord;
  1744. }
  1745. BOOL CNewHostDialog::OnInitDialog()
  1746. {
  1747. CHelpDialog::OnInitDialog();
  1748. //
  1749. // hook up Cancel/Done button
  1750. //
  1751. UINT nButtonIDs[2] = { IDS_BUTTON_TEXT_CANCEL, IDS_BUTTON_TEXT_DONE };
  1752. VERIFY(m_cancelDoneTextHelper.Init(this, IDCANCEL, nButtonIDs));
  1753. m_cancelDoneTextHelper.SetToggleState(m_bFirstCreation);
  1754. //
  1755. // limit the text length the user can type
  1756. //
  1757. int nUTF8ParentLen = UTF8StringLen(m_pParentDomainNode->GetFullName());
  1758. int nUTF8Len = MAX_DNS_NAME_LEN - nUTF8ParentLen - 3; // count dot when chaining
  1759. //
  1760. // hook up name edit control
  1761. //
  1762. GetNameEdit()->SetLimitText(nUTF8Len);
  1763. //
  1764. // determine if we need to hide TTL control
  1765. //
  1766. CDNSRootData* pRootData = (CDNSRootData*)m_pComponentData->GetRootData();
  1767. ASSERT(pRootData != NULL);
  1768. BOOL bShow = pRootData->IsAdvancedView();
  1769. CDNSTTLControl* pCtrl = GetTTLCtrl();
  1770. ASSERT(pCtrl != NULL);
  1771. pCtrl->EnableWindow(bShow);
  1772. pCtrl->ShowWindow(bShow);
  1773. CWnd* pWnd = GetDlgItem(IDC_STATIC_TTL);
  1774. ASSERT(pWnd != NULL);
  1775. pWnd->EnableWindow(bShow);
  1776. pWnd->ShowWindow(bShow);
  1777. CWnd* pLabelWnd = GetDlgItem(IDC_TTL_LABEL);
  1778. ASSERT(pLabelWnd != NULL);
  1779. pLabelWnd->EnableWindow(bShow);
  1780. pLabelWnd->ShowWindow(bShow);
  1781. //
  1782. // Set Create PTR record checkbox
  1783. //
  1784. if (pRootData != NULL)
  1785. {
  1786. GetPTRCheckCtrl()->SetCheck(pRootData->GetCreatePTRWithHost());
  1787. }
  1788. //
  1789. // set the FQDN for the domain the record is in
  1790. //
  1791. GetDomainEditBox()->SetWindowText(m_pParentDomainNode->GetFullName());
  1792. //
  1793. // Only enable the security checkbox if we are talking to a 2473 or greater
  1794. // Whistler server
  1795. //
  1796. CDNSServerNode* pServerNode = m_pParentDomainNode->GetServerNode();
  1797. CDNSZoneNode* pZoneNode = m_pParentDomainNode->GetZoneNode();
  1798. if (pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER_NEW_SECURITY_SETTINGS ||
  1799. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  1800. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER) ||
  1801. !pZoneNode->IsDSIntegrated())
  1802. {
  1803. GetSecurityCheckCtrl()->ShowWindow(FALSE);
  1804. GetSecurityCheckCtrl()->EnableWindow(FALSE);
  1805. }
  1806. SetUIData(TRUE);
  1807. return TRUE; // return TRUE unless you set the focus to a control
  1808. }
  1809. #ifdef _USE_BLANK
  1810. void CNewHostDialog::OnEditChange()
  1811. {
  1812. CString s;
  1813. GetNameEdit()->GetWindowText(s);
  1814. CString szFullName;
  1815. CString szDisplayName;
  1816. CString szTempName = m_pParentDomainNode->GetFullName();
  1817. ASSERT(szTempName.GetLength() > 0);
  1818. if (szTempName.GetAt(szTempName.GetLength() - 1) != L'.')
  1819. {
  1820. szTempName += L".";
  1821. }
  1822. if (s.IsEmpty())
  1823. {
  1824. szFullName = szTempName;
  1825. }
  1826. else
  1827. {
  1828. szFullName.Format(L"%s.%s", s, szTempName);
  1829. }
  1830. SetDlgItemText(IDC_RR_DOMAIN_EDIT, szFullName);
  1831. }
  1832. #else
  1833. void CNewHostDialog::OnEditChange()
  1834. {
  1835. //
  1836. // Get the server name checking flags
  1837. //
  1838. DWORD dwNameChecking = m_pParentDomainNode->GetServerNode()->GetNameCheckFlag();
  1839. CString s;
  1840. GetNameEdit()->GetWindowText(s);
  1841. CString szFullName;
  1842. CString szDisplayName;
  1843. CString szTempName = m_pParentDomainNode->GetFullName();
  1844. ASSERT(szTempName.GetLength() > 0);
  1845. if (szTempName.GetAt(szTempName.GetLength() - 1) != L'.')
  1846. {
  1847. szTempName += L".";
  1848. }
  1849. if (s.IsEmpty())
  1850. {
  1851. szFullName = szTempName;
  1852. }
  1853. else
  1854. {
  1855. szFullName.Format(L"%s.%s", s, szTempName);
  1856. }
  1857. GetDlgItem(IDC_BUTTON_ADDHOST)->EnableWindow(ValidateRecordName(szFullName, dwNameChecking) == 0);
  1858. SetDlgItemText(IDC_RR_DOMAIN_EDIT, szFullName);
  1859. }
  1860. #endif
  1861. DNS_STATUS CNewHostDialog::ValidateRecordName(PCWSTR pszName, DWORD dwNameChecking)
  1862. {
  1863. CDNSRootData* pRootData = (CDNSRootData*)m_pComponentData->GetRootData();
  1864. ASSERT(pRootData != NULL);
  1865. if (pRootData->IsAdvancedView())
  1866. {
  1867. //
  1868. // Don't validate the name in advanced view
  1869. //
  1870. return 0;
  1871. }
  1872. return ::ValidateDnsNameAgainstServerFlags(pszName, DnsNameHostnameFull, dwNameChecking);
  1873. }
  1874. CDNSRecordNodeBase* CNewHostDialog::CreateRecordNode()
  1875. {
  1876. //
  1877. // create a record node of type A
  1878. //
  1879. CDNSRecordNodeBase* pRecordNode = CDNSRecordInfo::CreateRecordNode(DNS_TYPE_A);
  1880. ASSERT(pRecordNode != NULL);
  1881. //
  1882. // set the normal/advanced view option
  1883. //
  1884. CDNSRootData* pRootData = (CDNSRootData*)m_pComponentData->GetRootData();
  1885. ASSERT(pRootData != NULL);
  1886. pRecordNode->SetFlagsDown(TN_FLAG_DNS_RECORD_FULL_NAME, !pRootData->IsAdvancedView());
  1887. //
  1888. // hookup container for node
  1889. //
  1890. pRecordNode->SetContainer(m_pParentDomainNode);
  1891. return pRecordNode;
  1892. }
  1893. void CNewHostDialog::SetUIData(BOOL bFirstTime)
  1894. {
  1895. CDNS_A_Record* pARec = (CDNS_A_Record*)m_pTempDNSRecord;
  1896. if (!bFirstTime)
  1897. {
  1898. //
  1899. // keep the first 3 octects and reset the last one to zero
  1900. //
  1901. pARec->m_ipAddress = static_cast<DWORD>(MAKEIPADDRESS(FIRST_IPADDRESS(0),
  1902. SECOND_IPADDRESS(pARec->m_ipAddress),
  1903. THIRD_IPADDRESS(pARec->m_ipAddress),
  1904. FOURTH_IPADDRESS(pARec->m_ipAddress)));
  1905. }
  1906. GetNameEdit()->SetWindowText(L"");
  1907. GetIPv4Ctrl()->SetIPv4Val(pARec->m_ipAddress);
  1908. GetTTLCtrl()->SetTTL(m_pTempDNSRecord->m_dwTtlSeconds);
  1909. }
  1910. DNS_STATUS CNewHostDialog::GetUIData(CDNSRecordNodeBase* pRecordNode)
  1911. {
  1912. ASSERT(m_pTempDNSRecord->m_dwFlags == DNS_RPC_RECORD_FLAG_DEFAULT);
  1913. #ifdef _USE_BLANK
  1914. BOOL bAtTheNode = GetNameEdit()->GetWindowTextLength() == 0;
  1915. #else
  1916. BOOL bAtTheNode = (s == g_szAtTheNodeInput);
  1917. #endif
  1918. if (bAtTheNode)
  1919. {
  1920. //
  1921. //name null, node is at the node level, use name of parent
  1922. //
  1923. pRecordNode->SetRecordName(pRecordNode->GetDomainNode()->GetDisplayName(),bAtTheNode);
  1924. }
  1925. else
  1926. {
  1927. //
  1928. // non null name, node is a child
  1929. //
  1930. CString szName;
  1931. GetNameEdit()->GetWindowText(szName);
  1932. pRecordNode->SetRecordName(szName, bAtTheNode);
  1933. }
  1934. GetIPv4Ctrl()->GetIPv4Val(&(((CDNS_A_Record*)m_pTempDNSRecord)->m_ipAddress));
  1935. GetTTLCtrl()->GetTTL(&(m_pTempDNSRecord->m_dwTtlSeconds));
  1936. if (GetPTRCheckCtrl()->GetCheck())
  1937. {
  1938. m_pTempDNSRecord->m_dwFlags |= DNS_RPC_RECORD_FLAG_CREATE_PTR;
  1939. }
  1940. if (GetSecurityCheckCtrl()->GetCheck())
  1941. {
  1942. m_pTempDNSRecord->m_dwFlags |= DNS_RPC_FLAG_OPEN_ACL;
  1943. }
  1944. CDNSRootData* pRootData = dynamic_cast<CDNSRootData*>(m_pComponentData->GetRootData());
  1945. if (pRootData != NULL)
  1946. {
  1947. pRootData->SetCreatePTRWithHost(GetPTRCheckCtrl()->GetCheck());
  1948. }
  1949. return 0;
  1950. }
  1951. void CNewHostDialog::OnAddHost()
  1952. {
  1953. CDNSRecordNodeBase* pRecordNode = CreateRecordNode();
  1954. ASSERT(pRecordNode != NULL);
  1955. ASSERT(m_pTempDNSRecord != NULL);
  1956. //
  1957. // get data from the UI
  1958. // Don't need to handle a failure here because the name is
  1959. //
  1960. DNS_STATUS dwErr = GetUIData(pRecordNode);
  1961. ASSERT(dwErr == 0);
  1962. DWORD dwNameChecking = m_pParentDomainNode->GetServerNode()->GetNameCheckFlag();
  1963. if (!pRecordNode->IsAtTheNode())
  1964. {
  1965. LPCWSTR lpszHostName = pRecordNode->GetTrueRecordName();
  1966. DNS_STATUS errName = ValidateRecordName(lpszHostName, dwNameChecking);
  1967. if (errName != 0)
  1968. {
  1969. //
  1970. // Bring up an error for an invalid name
  1971. //
  1972. CString szFmt, szMsg;
  1973. szFmt.LoadString(IDS_MSG_RECORD_CREATE_HOST_NAME_FAILED);
  1974. szMsg.Format((LPCWSTR)szFmt, lpszHostName);
  1975. if (DNSMessageBox(szMsg, MB_YESNO) != IDYES)
  1976. {
  1977. return;
  1978. }
  1979. }
  1980. }
  1981. //
  1982. // See if a child of that name already exists
  1983. //
  1984. RECORD_SEARCH recordSearch = RECORD_NOT_FOUND;
  1985. CDNSDomainNode* pNewParentDomain = NULL;
  1986. CString szFullRecordName;
  1987. pRecordNode->GetFullName(szFullRecordName);
  1988. CString szNonExistentDomain;
  1989. CDNSRecordNodeBase* pExistingRecordNode = 0;
  1990. recordSearch = m_pParentDomainNode->GetZoneNode()->DoesContain(szFullRecordName,
  1991. m_pComponentData,
  1992. &pNewParentDomain,
  1993. &pExistingRecordNode,
  1994. szNonExistentDomain,
  1995. TRUE);
  1996. if ((recordSearch == RECORD_NOT_FOUND || pRecordNode->IsAtTheNode() || recordSearch == RECORD_NOT_FOUND_AT_THE_NODE) &&
  1997. pNewParentDomain != NULL)
  1998. {
  1999. //
  2000. // write record to server
  2001. //
  2002. BOOL bUseDefaultTTL = TRUE;
  2003. if (pNewParentDomain != NULL)
  2004. {
  2005. bUseDefaultTTL = (m_pTempDNSRecord->m_dwTtlSeconds == pNewParentDomain->GetDefaultTTL());
  2006. }
  2007. else
  2008. {
  2009. bUseDefaultTTL = (m_pTempDNSRecord->m_dwTtlSeconds == m_pParentDomainNode->GetDefaultTTL());
  2010. }
  2011. DNS_STATUS err = pRecordNode->Update(m_pTempDNSRecord, bUseDefaultTTL);
  2012. CString szFmt;
  2013. CString szMsg;
  2014. BOOL bNeedToggle = TRUE;
  2015. if (err == 0 || err == DNS_WARNING_PTR_CREATE_FAILED)
  2016. {
  2017. //
  2018. // add the node to the UI
  2019. //
  2020. if (pNewParentDomain != NULL)
  2021. {
  2022. //
  2023. // Set the container to the found domain and alter the record name to reflect this
  2024. //
  2025. pRecordNode->SetContainer(pNewParentDomain);
  2026. CString szSingleLabel;
  2027. int iFindResult = szFullRecordName.Find(L'.');
  2028. if (iFindResult != -1)
  2029. {
  2030. szSingleLabel = szFullRecordName.Left(iFindResult);
  2031. }
  2032. if (recordSearch == RECORD_NOT_FOUND)
  2033. {
  2034. pRecordNode->SetRecordName(szSingleLabel, pRecordNode->IsAtTheNode());
  2035. }
  2036. else
  2037. {
  2038. pRecordNode->SetRecordName(szSingleLabel, TRUE);
  2039. }
  2040. VERIFY(pNewParentDomain->AddChildToListAndUI(pRecordNode, m_pComponentData));
  2041. m_pComponentData->SetDescriptionBarText(pNewParentDomain);
  2042. }
  2043. SetUIData(FALSE);
  2044. if (err == DNS_WARNING_PTR_CREATE_FAILED)
  2045. {
  2046. DNSMessageBox(IDS_MSG_RECORD_WARNING_CREATE_PTR);
  2047. }
  2048. else
  2049. {
  2050. szFmt.LoadString(IDS_MSG_RECORD_CREATE_HOST_SUCCESS);
  2051. szMsg.Format((LPCWSTR)szFmt, (LPCWSTR)szFullRecordName);
  2052. DNSMessageBox(szMsg, MB_ICONINFORMATION | MB_OK);
  2053. }
  2054. }
  2055. else
  2056. {
  2057. szFmt.LoadString(IDS_MSG_RECORD_CREATE_HOST_FAIL);
  2058. szMsg.Format((LPCWSTR)szFmt, (LPCWSTR)szFullRecordName);
  2059. DNSErrorDialog(err, szMsg);
  2060. delete pRecordNode; // discarded on failure
  2061. bNeedToggle = FALSE;
  2062. }
  2063. //
  2064. // reset fields of temporary record
  2065. //
  2066. m_pTempDNSRecord->m_dwFlags = DNS_RPC_RECORD_FLAG_DEFAULT;
  2067. //
  2068. // toggle the Cancel/Done button label
  2069. //
  2070. if (bNeedToggle && m_bFirstCreation)
  2071. {
  2072. m_bFirstCreation = FALSE;
  2073. m_cancelDoneTextHelper.SetToggleState(m_bFirstCreation);
  2074. }
  2075. //
  2076. // Set the focus back to the name field
  2077. //
  2078. GetDlgItem(IDC_RR_NAME_EDIT)->SetFocus();
  2079. }
  2080. else if (recordSearch == NON_EXISTENT_SUBDOMAIN && pNewParentDomain != NULL)
  2081. {
  2082. //
  2083. // Create the record and then search for it so that we expand the newly
  2084. // created domains on the way down
  2085. //
  2086. BOOL bUseDefaultTTL = TRUE;
  2087. if (pNewParentDomain != NULL)
  2088. {
  2089. bUseDefaultTTL = (m_pTempDNSRecord->m_dwTtlSeconds == pNewParentDomain->GetDefaultTTL());
  2090. }
  2091. else
  2092. {
  2093. bUseDefaultTTL = (m_pTempDNSRecord->m_dwTtlSeconds == m_pParentDomainNode->GetDefaultTTL());
  2094. }
  2095. DNS_STATUS err = pRecordNode->Update(m_pTempDNSRecord, bUseDefaultTTL);
  2096. CString szFmt;
  2097. CString szMsg;
  2098. BOOL bNeedToggle = TRUE;
  2099. if (err == 0 || err == DNS_WARNING_PTR_CREATE_FAILED)
  2100. {
  2101. //
  2102. // add the node to the UI
  2103. //
  2104. if (pNewParentDomain != NULL)
  2105. {
  2106. //
  2107. // Set the container to the found domain and alter the record name to reflect this
  2108. //
  2109. pRecordNode->SetContainer(pNewParentDomain);
  2110. CString szSingleLabel;
  2111. int iFindResult = szFullRecordName.Find(L'.');
  2112. if (iFindResult != -1)
  2113. {
  2114. szSingleLabel = szFullRecordName.Left(iFindResult);
  2115. pRecordNode->SetRecordName(szSingleLabel, pRecordNode->IsAtTheNode());
  2116. }
  2117. ASSERT(!szNonExistentDomain.IsEmpty());
  2118. if (!szNonExistentDomain.IsEmpty())
  2119. {
  2120. //
  2121. // Create the first subdomain because the current domain is already enumerated
  2122. // so we have to start the remaining enumeration at the new subdomain that is needed
  2123. //
  2124. CDNSDomainNode* pSubdomainNode = pNewParentDomain->CreateSubdomainNode();
  2125. ASSERT(pSubdomainNode != NULL);
  2126. CDNSRootData* pRootData = (CDNSRootData*)m_pComponentData->GetRootData();
  2127. pNewParentDomain->SetSubdomainName(pSubdomainNode, szNonExistentDomain, pRootData->IsAdvancedView());
  2128. VERIFY(pNewParentDomain->AddChildToListAndUISorted(pSubdomainNode, m_pComponentData));
  2129. m_pComponentData->SetDescriptionBarText(pNewParentDomain);
  2130. //
  2131. // I don't care what the results of this are, I am just using it
  2132. // to do the expansion to the new record
  2133. //
  2134. recordSearch = pSubdomainNode->GetZoneNode()->DoesContain(szFullRecordName,
  2135. m_pComponentData,
  2136. &pNewParentDomain,
  2137. &pExistingRecordNode,
  2138. szNonExistentDomain,
  2139. TRUE);
  2140. }
  2141. }
  2142. SetUIData(FALSE);
  2143. if (err == DNS_WARNING_PTR_CREATE_FAILED)
  2144. {
  2145. DNSMessageBox(IDS_MSG_RECORD_WARNING_CREATE_PTR);
  2146. }
  2147. else
  2148. {
  2149. szFmt.LoadString(IDS_MSG_RECORD_CREATE_HOST_SUCCESS);
  2150. szMsg.Format((LPCWSTR)szFmt, (LPCWSTR)szFullRecordName);
  2151. DNSMessageBox(szMsg, MB_ICONINFORMATION | MB_OK);
  2152. }
  2153. }
  2154. else
  2155. {
  2156. szFmt.LoadString(IDS_MSG_RECORD_CREATE_HOST_FAIL);
  2157. szMsg.Format((LPCWSTR)szFmt, (LPCWSTR)szFullRecordName);
  2158. DNSErrorDialog(err, szMsg);
  2159. delete pRecordNode; // discarded on failure
  2160. bNeedToggle = FALSE;
  2161. }
  2162. //
  2163. // reset fields of temporary record
  2164. //
  2165. m_pTempDNSRecord->m_dwFlags = DNS_RPC_RECORD_FLAG_DEFAULT;
  2166. //
  2167. // toggle the Cancel/Done button label
  2168. //
  2169. if (bNeedToggle && m_bFirstCreation)
  2170. {
  2171. m_bFirstCreation = FALSE;
  2172. m_cancelDoneTextHelper.SetToggleState(m_bFirstCreation);
  2173. }
  2174. //
  2175. // Set the focus back to the name field
  2176. //
  2177. GetDlgItem(IDC_RR_NAME_EDIT)->SetFocus();
  2178. }
  2179. else
  2180. {
  2181. //
  2182. // write record to server
  2183. //
  2184. BOOL bUseDefaultTTL = TRUE;
  2185. if (pNewParentDomain != NULL)
  2186. {
  2187. bUseDefaultTTL = (m_pTempDNSRecord->m_dwTtlSeconds == pNewParentDomain->GetDefaultTTL());
  2188. }
  2189. else
  2190. {
  2191. bUseDefaultTTL = (m_pTempDNSRecord->m_dwTtlSeconds == m_pParentDomainNode->GetDefaultTTL());
  2192. }
  2193. DNS_STATUS err = pRecordNode->Update(m_pTempDNSRecord, bUseDefaultTTL);
  2194. CString szFmt;
  2195. CString szMsg;
  2196. BOOL bNeedToggle = TRUE;
  2197. if (err == 0 || err == DNS_WARNING_PTR_CREATE_FAILED)
  2198. {
  2199. if (pNewParentDomain != NULL)
  2200. {
  2201. //
  2202. // Set the container to the found domain and alter the record name to reflect this
  2203. //
  2204. pRecordNode->SetContainer(pNewParentDomain);
  2205. CString szSingleLabel;
  2206. int iFindResult = szFullRecordName.Find(L'.');
  2207. if (iFindResult != -1)
  2208. {
  2209. szSingleLabel = szFullRecordName.Left(iFindResult);
  2210. pRecordNode->SetRecordName(szSingleLabel, pRecordNode->IsAtTheNode());
  2211. }
  2212. VERIFY(pNewParentDomain->AddChildToListAndUI(pRecordNode, m_pComponentData));
  2213. m_pComponentData->SetDescriptionBarText(pNewParentDomain);
  2214. }
  2215. SetUIData(FALSE);
  2216. if (err == DNS_WARNING_PTR_CREATE_FAILED)
  2217. {
  2218. DNSMessageBox(IDS_MSG_RECORD_WARNING_CREATE_PTR);
  2219. }
  2220. else
  2221. {
  2222. szFmt.LoadString(IDS_MSG_RECORD_CREATE_HOST_SUCCESS);
  2223. szMsg.Format((LPCWSTR)szFmt, (LPCWSTR)szFullRecordName);
  2224. DNSMessageBox(szMsg, MB_ICONINFORMATION | MB_OK);
  2225. }
  2226. }
  2227. else
  2228. {
  2229. szFmt.LoadString(IDS_MSG_RECORD_CREATE_HOST_FAIL);
  2230. szMsg.Format((LPCWSTR)szFmt, (LPCWSTR)szFullRecordName);
  2231. DNSErrorDialog(err, szMsg);
  2232. delete pRecordNode; // discarded on failure
  2233. bNeedToggle = FALSE;
  2234. }
  2235. //
  2236. // reset fields of temporary record
  2237. //
  2238. m_pTempDNSRecord->m_dwFlags = DNS_RPC_RECORD_FLAG_DEFAULT;
  2239. //
  2240. // toggle the Cancel/Done button label
  2241. //
  2242. if (bNeedToggle && m_bFirstCreation)
  2243. {
  2244. m_bFirstCreation = FALSE;
  2245. m_cancelDoneTextHelper.SetToggleState(m_bFirstCreation);
  2246. }
  2247. //
  2248. // Set the focus back to the name field
  2249. //
  2250. GetDlgItem(IDC_RR_NAME_EDIT)->SetFocus();
  2251. }
  2252. }