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

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