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.

2072 lines
56 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: zone.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. // CDNSZoneNode
  29. // {720132B9-44B2-11d1-B92F-00A0C9A06D2D}
  30. const GUID CDNSZoneNode::NodeTypeGUID =
  31. { 0x720132b9, 0x44b2, 0x11d1, { 0xb9, 0x2f, 0x0, 0xa0, 0xc9, 0xa0, 0x6d, 0x2d } };
  32. extern ZONE_TYPE_MAP _ZoneTypeStrings[];
  33. CDNSZoneNode::CDNSZoneNode()
  34. {
  35. ASSERT(!IsDelegation());
  36. m_pZoneNode = this; // the zone is us
  37. m_pZoneInfoEx = new CDNSZoneInfoEx; // empty object with no data inside
  38. // data valid when zone info not available
  39. m_dwZoneFlags = 0x0;
  40. m_wZoneType = 0x0;
  41. NullCachedPointers();
  42. }
  43. CDNSZoneNode::~CDNSZoneNode()
  44. {
  45. TRACE(_T("~CDNSZoneNode(), name <%s>\n"),GetDisplayName());
  46. if (m_pZoneInfoEx != NULL)
  47. delete m_pZoneInfoEx;
  48. }
  49. #ifdef USE_NDNC
  50. ReplicationType CDNSZoneNode::GetDirectoryPartitionFlagsAsReplType()
  51. {
  52. ReplicationType replReturn = w2k;
  53. DWORD dwFlags = GetDirectoryPartitionFlags();
  54. if (dwFlags & DNS_DP_DOMAIN_DEFAULT)
  55. {
  56. replReturn = domain;
  57. }
  58. else if (dwFlags & DNS_DP_FOREST_DEFAULT)
  59. {
  60. replReturn = forest;
  61. }
  62. else
  63. {
  64. if (dwFlags & DNS_DP_LEGACY)
  65. {
  66. replReturn = w2k;
  67. }
  68. else
  69. {
  70. replReturn = custom;
  71. }
  72. }
  73. return replReturn;
  74. }
  75. PCWSTR CDNSZoneNode::GetCustomPartitionName()
  76. {
  77. USES_CONVERSION;
  78. if (m_pZoneInfoEx &&
  79. m_pZoneInfoEx->HasData())
  80. {
  81. m_szPartitionName = UTF8_TO_W(m_pZoneInfoEx->m_pZoneInfo->pszDpFqdn);
  82. }
  83. return m_szPartitionName;
  84. }
  85. DNS_STATUS CDNSZoneNode::ChangeDirectoryPartitionType(ReplicationType type, PCWSTR pszCustomPartition)
  86. {
  87. USES_CONVERSION;
  88. PSTR pszReplScope = 0;
  89. switch (type)
  90. {
  91. case domain :
  92. pszReplScope = DNS_DP_DOMAIN_STR;
  93. break;
  94. case forest :
  95. pszReplScope = DNS_DP_FOREST_STR;
  96. break;
  97. case w2k :
  98. pszReplScope = DNS_DP_LEGACY_STR;
  99. break;
  100. default :
  101. pszReplScope = W_TO_UTF8(pszCustomPartition);
  102. break;
  103. }
  104. DNS_STATUS dwErr = ::DnssrvChangeZoneDirectoryPartition(GetServerNode()->GetRPCName(),
  105. W_TO_UTF8(GetFullName()),
  106. pszReplScope);
  107. if (dwErr == 0)
  108. {
  109. GetZoneInfo();
  110. }
  111. return dwErr;
  112. }
  113. #endif // USE_NDNC
  114. LPCWSTR CDNSZoneNode::GetString(int nCol)
  115. {
  116. switch (nCol)
  117. {
  118. case 0:
  119. //
  120. // Zone name
  121. //
  122. return GetDisplayName();
  123. case 1:
  124. //
  125. // Zone type
  126. //
  127. {
  128. if (GetZoneType() == DNS_ZONE_TYPE_PRIMARY && IsDSIntegrated())
  129. {
  130. return _ZoneTypeStrings[0].szBuffer;
  131. }
  132. if (GetZoneType() == DNS_ZONE_TYPE_SECONDARY)
  133. {
  134. return _ZoneTypeStrings[2].szBuffer;
  135. }
  136. if (GetZoneType() == DNS_ZONE_TYPE_STUB)
  137. {
  138. if (IsDSIntegrated())
  139. {
  140. return _ZoneTypeStrings[6].szBuffer;
  141. }
  142. else
  143. {
  144. return _ZoneTypeStrings[5].szBuffer;
  145. }
  146. }
  147. //
  148. // Standard primary
  149. //
  150. return _ZoneTypeStrings[1].szBuffer;
  151. }
  152. /* case 2:
  153. //
  154. // Directory Partition Name
  155. //
  156. {
  157. CDNSServerNode* pServerNode = GetServerNode();
  158. if (!IsDSIntegrated() ||
  159. pServerNode->GetBuildNumber() < DNS_SRV_BUILD_NUMBER_WHISTLER ||
  160. (pServerNode->GetMajorVersion() <= DNS_SRV_MAJOR_VERSION_NT_5 &&
  161. pServerNode->GetMinorVersion() < DNS_SRV_MINOR_VERSION_WHISTLER))
  162. {
  163. //
  164. // The zone is not DS integrated
  165. // or
  166. // this is a pre-Whistler server, no Application Directory Partition support
  167. //
  168. return g_lpszNullString;
  169. }
  170. DWORD dwDpFlags = GetDirectoryPartitionFlags();
  171. if (dwDpFlags == 0 ||
  172. dwDpFlags & DNS_DP_LEGACY)
  173. {
  174. //
  175. // To all DCs in the domain
  176. //
  177. // REVIEW_JEFFJON : todo!!!
  178. return g_lpszNullString;
  179. }
  180. else if (dwDpFlags & DNS_DP_DOMAIN_DEFAULT)
  181. {
  182. //
  183. // To all DNS servers in the domain
  184. //
  185. // REVIEW_JEFFJON : todo!!!
  186. return g_lpszNullString;
  187. }
  188. else if (dwDpFlags & DNS_DP_ENTERPRISE_DEFAULT)
  189. {
  190. //
  191. // To all DNS servers in the forest
  192. //
  193. // REVIEW_JEFFJON : todo!!!
  194. return g_lpszNullString;
  195. }
  196. else if (dwDpFlags & DNS_DP_ENLISTED)
  197. {
  198. //
  199. // To all DCs in the application directory partition
  200. //
  201. return GetCustomPartitionName();
  202. }
  203. }
  204. break;
  205. */
  206. case 2:
  207. //
  208. // Status
  209. //
  210. {
  211. if (IsPaused())
  212. {
  213. return _ZoneTypeStrings[4].szBuffer;
  214. }
  215. return _ZoneTypeStrings[3].szBuffer;
  216. }
  217. }
  218. return g_lpszNullString;
  219. }
  220. void CDNSZoneNode::InitializeFromRPCZoneInfo(PDNS_RPC_ZONE pZoneInfo, BOOL bAdvancedView)
  221. {
  222. USES_CONVERSION;
  223. ASSERT(m_pZoneInfoEx != NULL);
  224. ASSERT(!m_pZoneInfoEx->HasData());
  225. ASSERT(pZoneInfo != NULL);
  226. m_dwZoneFlags = 0x0;
  227. if (pZoneInfo->Flags.Paused) m_dwZoneFlags |= DNS_ZONE_Paused;
  228. if (pZoneInfo->Flags.Shutdown) m_dwZoneFlags |= DNS_ZONE_Shutdown;
  229. if (pZoneInfo->Flags.Reverse) m_dwZoneFlags |= DNS_ZONE_Reverse;
  230. if (pZoneInfo->Flags.AutoCreated) m_dwZoneFlags |= DNS_ZONE_AutoCreated;
  231. if (pZoneInfo->Flags.DsIntegrated) m_dwZoneFlags |= DNS_ZONE_DsIntegrated;
  232. m_wZoneType = pZoneInfo->ZoneType;
  233. SetNames(IsZone(), pZoneInfo->Flags.Reverse, bAdvancedView,
  234. pZoneInfo->pszZoneName, pZoneInfo->pszZoneName);
  235. }
  236. void CDNSZoneNode::FreeZoneInfo()
  237. {
  238. if (m_pZoneInfoEx)
  239. {
  240. m_pZoneInfoEx->FreeInfo();
  241. }
  242. }
  243. DNS_STATUS CDNSZoneNode::GetZoneInfo()
  244. {
  245. ASSERT(m_pZoneInfoEx != NULL);
  246. CDNSServerNode* pServerNode = GetServerNode();
  247. ASSERT(pServerNode != NULL);
  248. return m_pZoneInfoEx->Query(pServerNode->GetRPCName(),
  249. GetFullName(),
  250. pServerNode->GetVersion());
  251. }
  252. void CDNSZoneNode::AttachZoneInfo(CDNSZoneInfoEx* pNewInfo)
  253. {
  254. ASSERT(pNewInfo != NULL);
  255. if (m_pZoneInfoEx != NULL)
  256. delete m_pZoneInfoEx;
  257. m_pZoneInfoEx = pNewInfo;
  258. }
  259. void CDNSZoneNode::SetZoneNormalViewHelper(CString& szDisplayName)
  260. {
  261. // the display name is stripped of the "in-addr.arpa" suffix
  262. // e.g. from "127.in-addr.arpa" to "127"
  263. // e.g. from "55.157.in-addr.arpa" to "55.157"
  264. BOOL bArpa = RemoveInAddrArpaSuffix(szDisplayName.GetBuffer(1));
  265. szDisplayName.ReleaseBuffer();
  266. if (!bArpa)
  267. return;
  268. LPWSTR lpsz1 = szDisplayName.GetBuffer(1);
  269. int nOctects = ReverseIPString(lpsz1);
  270. //ASSERT(nOctects > 0 && nOctects < 4);
  271. szDisplayName.ReleaseBuffer(); // got "157.80"
  272. switch(nOctects)
  273. {
  274. case 1:
  275. szDisplayName += _T(".x.x.x Subnet");
  276. break;
  277. case 2:
  278. szDisplayName += _T(".x.x Subnet");
  279. break;
  280. case 3:
  281. szDisplayName += _T(".x Subnet");
  282. break;
  283. }
  284. }
  285. void CDNSZoneNode::ChangeViewOption(BOOL bAdvanced,
  286. CComponentDataObject* pComponentDataObject)
  287. {
  288. ASSERT(IsReverse());
  289. if (!IsReverse())
  290. return;
  291. // change the display name
  292. m_szDisplayName = GetFullName();
  293. if (!bAdvanced)
  294. {
  295. SetZoneNormalViewHelper(m_szDisplayName);
  296. }
  297. if(IsVisible())
  298. VERIFY(SUCCEEDED(pComponentDataObject->ChangeNode(this, CHANGE_RESULT_ITEM_DATA)));
  299. // change the display name for all PTR records in the tree
  300. ChangePTRRecordsViewOption(bAdvanced, pComponentDataObject);
  301. }
  302. BOOL CDNSZoneNode::OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  303. long *pInsertionAllowed)
  304. {
  305. DWORD dwType = GetZoneType();
  306. //
  307. // call this before the base class because it filters it out
  308. //
  309. if (pContextMenuItem2->lCommandID == IDM_ZONE_TRANSFER ||
  310. pContextMenuItem2->lCommandID == IDM_ZONE_RELOAD_FROM_MASTER)
  311. {
  312. //
  313. // if it is not a secondary, just bail out
  314. //
  315. if ( (dwType != DNS_ZONE_TYPE_SECONDARY) && (dwType != DNS_ZONE_TYPE_STUB))
  316. {
  317. return FALSE;
  318. }
  319. //
  320. // have the menu item added. but it might be grayed out...
  321. //
  322. if (IsThreadLocked() || (m_nState == notLoaded) || (m_nState == loading))
  323. {
  324. //
  325. // thread locked or not loaded state
  326. //
  327. pContextMenuItem2->fFlags |= MF_GRAYED;
  328. }
  329. return TRUE;
  330. }
  331. if (pContextMenuItem2->lCommandID == IDM_ZONE_UPDATE_DATA_FILE)
  332. {
  333. //
  334. // cannot update data file on secondary zones, the cache or autocreated zones
  335. //
  336. if ( (dwType != DNS_ZONE_TYPE_PRIMARY) || IsAutocreated() )
  337. {
  338. return FALSE;
  339. }
  340. //
  341. // have the menu item added. but it might be grayed out...
  342. //
  343. if (m_nState != loaded)
  344. {
  345. //
  346. // not loaded state
  347. //
  348. pContextMenuItem2->fFlags |= MF_GRAYED;
  349. }
  350. else if ( (dwType == DNS_ZONE_TYPE_PRIMARY) && IsDSIntegrated() )
  351. {
  352. //
  353. // primaries DS integrated
  354. //
  355. pContextMenuItem2->fFlags |= MF_GRAYED;
  356. }
  357. return TRUE;
  358. }
  359. if (pContextMenuItem2->lCommandID == IDM_ZONE_RELOAD)
  360. {
  361. //
  362. // cannot reload the cache or autocreated zones
  363. //
  364. if ( (dwType == DNS_ZONE_TYPE_CACHE) || IsAutocreated() )
  365. {
  366. return FALSE;
  367. }
  368. //
  369. // have the menu item added. but it might be grayed out...
  370. //
  371. if (IsThreadLocked() || (m_nState != loaded))
  372. {
  373. // not loaded state
  374. pContextMenuItem2->fFlags |= MF_GRAYED;
  375. }
  376. return TRUE;
  377. }
  378. //
  379. // NOTE: the base class knows about the derived class, so must call like this
  380. //
  381. if (!CDNSDomainNode::OnAddMenuItem(pContextMenuItem2,pInsertionAllowed))
  382. {
  383. return FALSE;
  384. }
  385. return TRUE;
  386. }
  387. BOOL CDNSZoneNode::OnSetRenameVerbState(DATA_OBJECT_TYPES,
  388. BOOL* pbHide,
  389. CNodeList*)
  390. {
  391. // REVIEW_JEFFJON : removed from Whistler release
  392. //*pbHide = FALSE;
  393. //return TRUE;
  394. *pbHide = TRUE;
  395. return FALSE;
  396. }
  397. HRESULT CDNSZoneNode::OnRename(CComponentDataObject*,
  398. LPWSTR lpszNewName)
  399. {
  400. TRACE(_T("CDNSZoneNode::OnRename() : new name = %ws\n"), lpszNewName);
  401. return S_FALSE;
  402. }
  403. HRESULT CDNSZoneNode::GetResultViewType(CComponentDataObject*,
  404. LPOLESTR *ppViewType,
  405. long *pViewOptions)
  406. {
  407. HRESULT hr = S_FALSE;
  408. BOOL bUseMessageView = FALSE;
  409. DWORD dwType = GetZoneType();
  410. // special case for paused/expired zones
  411. switch (m_nState)
  412. {
  413. case loaded:
  414. {
  415. if (dwType == DNS_ZONE_TYPE_CACHE)
  416. {
  417. bUseMessageView = FALSE;
  418. }
  419. else // authoritated zone
  420. {
  421. if (IsPaused())
  422. bUseMessageView = FALSE;
  423. else if (IsExpired())
  424. bUseMessageView = TRUE;
  425. else
  426. bUseMessageView = FALSE;
  427. }
  428. }
  429. break;
  430. case unableToLoad:
  431. case accessDenied:
  432. bUseMessageView = TRUE;
  433. break;
  434. default:
  435. bUseMessageView = FALSE;
  436. }
  437. if (bUseMessageView)
  438. {
  439. *pViewOptions = MMC_VIEW_OPTIONS_NOLISTVIEWS;
  440. LPOLESTR psz = NULL;
  441. StringFromCLSID(CLSID_MessageView, &psz);
  442. USES_CONVERSION;
  443. if (psz != NULL)
  444. {
  445. *ppViewType = psz;
  446. hr = S_OK;
  447. }
  448. }
  449. else
  450. {
  451. *pViewOptions = MMC_VIEW_OPTIONS_MULTISELECT;
  452. *ppViewType = NULL;
  453. hr = S_FALSE;
  454. }
  455. return hr;
  456. }
  457. HRESULT CDNSZoneNode::OnShow(LPCONSOLE lpConsole)
  458. {
  459. CComPtr<IUnknown> spUnknown;
  460. CComPtr<IMessageView> spMessageView;
  461. HRESULT hr = lpConsole->QueryResultView(&spUnknown);
  462. if (FAILED(hr))
  463. return S_OK;
  464. hr = spUnknown->QueryInterface(IID_IMessageView, (PVOID*)&spMessageView);
  465. if (SUCCEEDED(hr))
  466. {
  467. CString szTitle, szMessage;
  468. IconIdentifier iconID;
  469. DWORD dwType = GetZoneType();
  470. if ((dwType == DNS_ZONE_TYPE_PRIMARY) && IsDSIntegrated())
  471. {
  472. VERIFY(szTitle.LoadString(IDS_MESSAGE_VIEW_ZONE_NOT_LOADED_TITLE));
  473. VERIFY(szMessage.LoadString(IDS_MESSAGE_VIEW_ZONE_NOT_LOADED_DS_MESSAGE));
  474. iconID = Icon_Error;
  475. }
  476. else if ((dwType == DNS_ZONE_TYPE_PRIMARY) && !IsDSIntegrated())
  477. {
  478. VERIFY(szTitle.LoadString(IDS_MESSAGE_VIEW_ZONE_NOT_LOADED_TITLE));
  479. VERIFY(szMessage.LoadString(IDS_MESSAGE_VIEW_ZONE_NOT_LOADED_PRIMARY_MESSAGE));
  480. iconID = Icon_Error;
  481. }
  482. else
  483. {
  484. VERIFY(szTitle.LoadString(IDS_MESSAGE_VIEW_ZONE_NOT_LOADED_TITLE));
  485. VERIFY(szMessage.LoadString(IDS_MESSAGE_VIEW_ZONE_NOT_LOADED_SECONDARY_MESSAGE));
  486. iconID = Icon_Error;
  487. }
  488. spMessageView->SetTitleText(szTitle);
  489. spMessageView->SetBodyText(szMessage);
  490. spMessageView->SetIcon(iconID);
  491. }
  492. return S_OK;
  493. }
  494. int CDNSZoneNode::GetImageIndex(BOOL)
  495. {
  496. DWORD dwType = GetZoneType();
  497. BOOL bPrimary = (dwType == DNS_ZONE_TYPE_PRIMARY);
  498. // special case for paused/expired zones
  499. int nIndex = -1;
  500. switch (m_nState)
  501. {
  502. case notLoaded:
  503. nIndex = (bPrimary) ? ZONE_IMAGE_NOT_LOADED_1 : ZONE_IMAGE_NOT_LOADED_2;
  504. break;
  505. case loading:
  506. nIndex = (bPrimary) ? ZONE_IMAGE_LOADING_1 : ZONE_IMAGE_LOADING_2;
  507. break;
  508. case loaded:
  509. {
  510. if (dwType == DNS_ZONE_TYPE_CACHE)
  511. {
  512. nIndex = (bPrimary) ? ZONE_IMAGE_LOADED_1 : ZONE_IMAGE_LOADED_2;
  513. }
  514. else // authoritated zone
  515. {
  516. if (IsPaused())
  517. nIndex = (bPrimary) ? ZONE_IMAGE_PAUSED_1 : ZONE_IMAGE_PAUSED_2;
  518. else if (IsExpired())
  519. nIndex = (bPrimary) ? ZONE_IMAGE_EXPIRED_1 : ZONE_IMAGE_EXPIRED_2;
  520. else
  521. nIndex = (bPrimary) ? ZONE_IMAGE_LOADED_1 : ZONE_IMAGE_LOADED_2;
  522. }
  523. }
  524. break;
  525. case unableToLoad:
  526. nIndex = (bPrimary) ? ZONE_IMAGE_UNABLE_TO_LOAD_1 : ZONE_IMAGE_UNABLE_TO_LOAD_2;
  527. break;
  528. case accessDenied:
  529. nIndex = (bPrimary) ? ZONE_IMAGE_ACCESS_DENIED_1 : ZONE_IMAGE_ACCESS_DENIED_2;
  530. break;
  531. default:
  532. ASSERT(FALSE);
  533. }
  534. ASSERT(nIndex > 0);
  535. return nIndex;
  536. }
  537. HRESULT CDNSZoneNode::OnCommand(long nCommandID,
  538. DATA_OBJECT_TYPES,
  539. CComponentDataObject* pComponentData,
  540. CNodeList* pNodeList)
  541. {
  542. if (pNodeList->GetCount() > 1) // multiple selection
  543. {
  544. return E_FAIL;
  545. }
  546. switch (nCommandID)
  547. {
  548. case IDM_DOMAIN_NEW_DOMAIN:
  549. OnNewDomain(pComponentData);
  550. break;
  551. case IDM_DOMAIN_NEW_DELEGATION:
  552. OnNewDelegation(pComponentData);
  553. break;
  554. case IDM_DOMAIN_NEW_RECORD:
  555. OnNewRecord(pComponentData, pNodeList);
  556. break;
  557. case IDM_DOMAIN_NEW_HOST:
  558. OnNewHost(pComponentData);
  559. break;
  560. case IDM_DOMAIN_NEW_ALIAS:
  561. OnNewAlias(pComponentData);
  562. break;
  563. case IDM_DOMAIN_NEW_MX:
  564. OnNewMailExchanger(pComponentData);
  565. break;
  566. case IDM_DOMAIN_NEW_PTR:
  567. OnNewPointer(pComponentData);
  568. break;
  569. case IDM_ZONE_UPDATE_DATA_FILE:
  570. OnUpdateDataFile(pComponentData);
  571. break;
  572. case IDM_ZONE_RELOAD:
  573. OnReload(pComponentData);
  574. break;
  575. case IDM_ZONE_TRANSFER:
  576. OnTransferFromMaster(pComponentData);
  577. break;
  578. case IDM_ZONE_RELOAD_FROM_MASTER:
  579. OnReloadFromMaster(pComponentData);
  580. break;
  581. case IDM_SNAPIN_ADVANCED_VIEW:
  582. ((CDNSRootData*)pComponentData->GetRootData())->OnViewOptions(pComponentData);
  583. break;
  584. case IDM_SNAPIN_FILTERING:
  585. {
  586. if (((CDNSRootData*)pComponentData->GetRootData())->OnFilteringOptions(pComponentData))
  587. {
  588. pComponentData->SetDescriptionBarText(this);
  589. }
  590. }
  591. break;
  592. default:
  593. ASSERT(FALSE); // Unknown command!
  594. return E_FAIL;
  595. }
  596. return S_OK;
  597. }
  598. void CDNSZoneNode::OnUpdateDataFile(CComponentDataObject* pComponentData)
  599. {
  600. // if there are sheets up, ask to close them down, because a
  601. // failure would "Red X" the server and remove all the children
  602. if (IsSheetLocked())
  603. {
  604. if (!CanCloseSheets())
  605. return;
  606. pComponentData->GetPropertyPageHolderTable()->DeleteSheetsOfNode(this);
  607. }
  608. ASSERT(m_nState == loaded);
  609. OnChangeState(pComponentData); // move to loading
  610. { // scope for the wait cursor
  611. CWaitCursor wait;
  612. m_dwErr = WriteToDatabase();
  613. }
  614. // if there is a failure, remove all children,
  615. // will need a refresh to get them back
  616. if (m_dwErr != 0)
  617. {
  618. RemoveAllChildrenHelper(pComponentData);
  619. ASSERT(!HasChildren());
  620. }
  621. OnChangeState(pComponentData); // move to loaded or unableToLoad
  622. }
  623. void CDNSZoneNode::OnReload(CComponentDataObject* pComponentData)
  624. {
  625. UINT nRet = DNSConfirmOperation(IDS_MSG_ZONE_RELOAD, this);
  626. if (IDCANCEL == nRet ||
  627. IDNO == nRet)
  628. {
  629. return;
  630. }
  631. // if there are sheets up, ask to close them down, because
  632. // we will need a refresh
  633. if (IsSheetLocked())
  634. {
  635. if (!CanCloseSheets())
  636. return;
  637. pComponentData->GetPropertyPageHolderTable()->DeleteSheetsOfNode(this);
  638. }
  639. ASSERT(m_nState == loaded);
  640. DNS_STATUS err;
  641. { // scope for the wait cursor
  642. CWaitCursor wait;
  643. err = Reload();
  644. }
  645. if (err != 0)
  646. {
  647. // need to let the user know the operation failed
  648. DNSErrorDialog(err, IDS_MSG_ZONE_FAIL_RELOAD);
  649. return;
  650. }
  651. CNodeList nodeList;
  652. nodeList.AddTail(this);
  653. // the zone has been reloaded cause a refresh to get new data
  654. VERIFY(OnRefresh(pComponentData, &nodeList));
  655. }
  656. void CDNSZoneNode::OnTransferFromMaster(CComponentDataObject* pComponentData)
  657. {
  658. // if there are sheets up, ask to close them down, because
  659. // we will need a refresh
  660. if (IsSheetLocked())
  661. {
  662. if (!CanCloseSheets())
  663. return;
  664. pComponentData->GetPropertyPageHolderTable()->DeleteSheetsOfNode(this);
  665. }
  666. ASSERT(m_nState != notLoaded);
  667. ASSERT(m_nState != loading);
  668. DNS_STATUS err;
  669. { // scope for the wait cursor
  670. CWaitCursor wait;
  671. err = TransferFromMaster();
  672. }
  673. if (err != 0)
  674. {
  675. // need to let the user know the operation failed
  676. DNSErrorDialog(err, IDS_MSG_ZONE_FAIL_TRANSFER);
  677. return;
  678. }
  679. CNodeList nodeList;
  680. nodeList.AddTail(this);
  681. // the zone has been reloaded cause a refresh to get new data
  682. VERIFY(OnRefresh(pComponentData, &nodeList));
  683. }
  684. void CDNSZoneNode::OnReloadFromMaster(CComponentDataObject* pComponentData)
  685. {
  686. // if there are sheets up, ask to close them down, because
  687. // we will need a refresh
  688. if (IsSheetLocked())
  689. {
  690. if (!CanCloseSheets())
  691. return;
  692. pComponentData->GetPropertyPageHolderTable()->DeleteSheetsOfNode(this);
  693. }
  694. ASSERT(m_nState != notLoaded);
  695. ASSERT(m_nState != loading);
  696. DNS_STATUS err;
  697. { // scope for the wait cursor
  698. CWaitCursor wait;
  699. err = ReloadFromMaster();
  700. }
  701. if (err != 0)
  702. {
  703. // need to let the user know the operation failed
  704. DNSErrorDialog(err, IDS_MSG_ZONE_FAIL_RELOAD_FROM_MASTER);
  705. return;
  706. }
  707. CNodeList nodeList;
  708. nodeList.AddTail(this);
  709. // the zone has been reloaded cause a refresh to get new data
  710. VERIFY(OnRefresh(pComponentData, &nodeList));
  711. }
  712. void CDNSZoneNode::OnDelete(CComponentDataObject* pComponentData,
  713. CNodeList* pNodeList)
  714. {
  715. if (pNodeList->GetCount() > 1) // multiple selection
  716. {
  717. OnMultiselectDelete(pComponentData, pNodeList);
  718. return;
  719. }
  720. UINT nRet = DNSConfirmOperation(IDS_MSG_ZONE_DELETE, this);
  721. if (IDCANCEL == nRet ||
  722. IDNO == nRet)
  723. {
  724. return;
  725. }
  726. BOOL bDeleteFromDS = FALSE;
  727. if (((GetZoneType() == DNS_ZONE_TYPE_PRIMARY) || (GetZoneType() == DNS_ZONE_TYPE_STUB)) &&
  728. IsDSIntegrated())
  729. {
  730. if (GetServerNode()->GetBootMethod() == BOOT_METHOD_DIRECTORY)
  731. {
  732. // ask confirmation on delete from DS
  733. int nRetVal = DNSMessageBox(IDS_MSG_ZONE_DELETE_FROM_DS_BOOT3,
  734. MB_YESNO | MB_DEFBUTTON2);
  735. if (IDNO == nRetVal)
  736. return;
  737. bDeleteFromDS = TRUE;
  738. }
  739. else
  740. {
  741. // ask confirmation on delete from DS
  742. int nRetVal = DNSMessageBox(IDS_MSG_ZONE_DELETE_FROM_DS,
  743. MB_YESNOCANCEL | MB_DEFBUTTON3);
  744. if (IDCANCEL == nRetVal)
  745. return;
  746. bDeleteFromDS = (nRetVal == IDYES);
  747. }
  748. }
  749. if (IsSheetLocked())
  750. {
  751. // NTRAID#NTBUG-594003-2002/04/11-JeffJon-Don't offer
  752. // to shutdown the sheets for the user because if the
  753. // sheet brought up a modal dialog we will deadlock
  754. // ourselves.
  755. DNSMessageBox(IDS_ZONE_WARNING_SHEETS_UP, MB_OK);
  756. return;
  757. }
  758. DNS_STATUS err = Delete(bDeleteFromDS);
  759. if (err != 0)
  760. {
  761. DNSErrorDialog(err, IDS_MSG_ZONE_FAIL_DELETE);
  762. return;
  763. }
  764. // now remove from the UI and from the cache
  765. DeleteHelper(pComponentData);
  766. pComponentData->UpdateResultPaneView(GetContainer());
  767. if (IsRootZone())
  768. {
  769. if (DNSMessageBox(IDS_MSG_ZONE_DELETE_ROOT, MB_YESNO) == IDYES)
  770. {
  771. GetServerNode()->SetProppageStart(3); // 3 signifies the Root Hints page
  772. if (GetServerNode()->GetSheetCount() > 0)
  773. {
  774. GetServerNode()->GetRootHints()->ShowPageForNode(pComponentData);
  775. }
  776. else
  777. {
  778. pComponentData->CreatePropertySheet(
  779. GetServerNode(),
  780. NULL,
  781. GetServerNode()->GetDisplayName());
  782. }
  783. }
  784. }
  785. delete this; // gone
  786. }
  787. BOOL CDNSZoneNode::HasPropertyPages(DATA_OBJECT_TYPES,
  788. BOOL* pbHideVerb,
  789. CNodeList* pNodeList)
  790. {
  791. if (pNodeList->GetCount() > 1) // multiple selection
  792. {
  793. return FALSE;
  794. }
  795. *pbHideVerb = FALSE; // always show the verb
  796. if (!m_bHasDataForPropPages)
  797. return FALSE;
  798. // cannot have property pages only in loaded state
  799. // if (m_nState != loaded)
  800. // return FALSE;
  801. ASSERT(m_pZoneInfoEx != NULL);
  802. if ( (!m_pZoneInfoEx->HasData()) ||
  803. ( (GetZoneType() == DNS_ZONE_TYPE_CACHE) || IsAutocreated() ) )
  804. {
  805. return FALSE;
  806. }
  807. return TRUE;
  808. }
  809. HRESULT CDNSZoneNode::CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  810. LONG_PTR handle,
  811. CNodeList* pNodeList)
  812. {
  813. ASSERT(pNodeList->GetCount() == 1); // multi-select not supported
  814. ASSERT(m_bHasDataForPropPages);
  815. if (GetSheetCount() > 0)
  816. {
  817. CComponentDataObject* pComponentDataObject =
  818. ((CRootData*)(GetContainer()->GetRootContainer()))->GetComponentDataObject();
  819. ASSERT(pComponentDataObject != NULL);
  820. pComponentDataObject->GetPropertyPageHolderTable()->BroadcastSelectPage(this, ZONE_HOLDER_GEN);
  821. return S_OK;
  822. }
  823. return CreatePropertyPagesHelper(lpProvider, handle, ZONE_HOLDER_GEN);
  824. }
  825. HRESULT CDNSZoneNode::CreatePropertyPagesHelper(LPPROPERTYSHEETCALLBACK lpProvider,
  826. LONG_PTR handle, long nStartPageCode)
  827. {
  828. CComponentDataObject* pComponentDataObject =
  829. ((CRootData*)(GetContainer()->GetRootContainer()))->GetComponentDataObject();
  830. ASSERT(pComponentDataObject != NULL);
  831. HRESULT hr = S_OK;
  832. CDNSZonePropertyPageHolder* pHolder =
  833. new CDNSZonePropertyPageHolder((CCathegoryFolderNode*)GetContainer(), this, pComponentDataObject);
  834. if (pHolder)
  835. {
  836. pHolder->SetStartPageCode(nStartPageCode);
  837. pHolder->SetSheetTitle(IDS_PROP_SHEET_TITLE_FMT, this);
  838. hr = pHolder->CreateModelessSheet(lpProvider, handle);
  839. }
  840. else
  841. {
  842. hr = E_OUTOFMEMORY;
  843. }
  844. return hr;
  845. }
  846. void CDNSZoneNode::Show(BOOL bShow, CComponentDataObject* pComponentData)
  847. {
  848. CDNSDomainNode::Show(bShow, pComponentData);
  849. if (!bShow)
  850. NullCachedPointers();
  851. }
  852. void CDNSZoneNode::NullCachedPointers()
  853. {
  854. m_pSOARecordNode = NULL;
  855. m_pWINSRecordNode = NULL;
  856. }
  857. BOOL CDNSZoneNode::OnRefresh(CComponentDataObject* pComponentData,
  858. CNodeList* pNodeList)
  859. {
  860. if (pNodeList->GetCount() > 1) // multiple selection
  861. {
  862. BOOL bRet = TRUE;
  863. POSITION pos = pNodeList->GetHeadPosition();
  864. while (pos != NULL)
  865. {
  866. CTreeNode* pNode = pNodeList->GetNext(pos);
  867. ASSERT(pNode != NULL);
  868. CNodeList nodeList;
  869. nodeList.AddTail(pNode);
  870. if (!pNode->OnRefresh(pComponentData, &nodeList))
  871. {
  872. bRet = FALSE;
  873. }
  874. }
  875. return bRet;
  876. }
  877. CNodeList nodeList;
  878. nodeList.AddTail(this);
  879. if (CDNSDomainNode::OnRefresh(pComponentData, &nodeList))
  880. {
  881. FreeZoneInfo();
  882. NullCachedPointers();
  883. return TRUE;
  884. }
  885. return FALSE;
  886. }
  887. void CDNSZoneNode::OnHaveData(CObjBase* pObj, CComponentDataObject* pComponentDataObject)
  888. {
  889. // if we get the zone info, just set it and bail out (no UI)
  890. if (IS_CLASS(*pObj, CDNSZoneInfoEx))
  891. {
  892. ASSERT(!HasChildren()); // must be the first one coming from the thread
  893. AttachZoneInfo(dynamic_cast<CDNSZoneInfoEx*>(pObj));
  894. return;
  895. }
  896. CDNSDomainNode::OnHaveData(pObj, pComponentDataObject);
  897. }
  898. void CDNSZoneNode::OnHaveRecord(CDNSRecordNodeBase* pRecordNode,
  899. CComponentDataObject* pComponentDataObject)
  900. {
  901. CDNSDomainNode::OnHaveRecord(pRecordNode, pComponentDataObject);
  902. if ((pRecordNode->GetType() == DNS_TYPE_SOA) && pRecordNode->IsAtTheNode())
  903. {
  904. ASSERT(m_pSOARecordNode == NULL);
  905. m_pSOARecordNode = (CDNS_SOA_RecordNode*)pRecordNode;
  906. }
  907. else if ( ( (pRecordNode->GetType() == DNS_TYPE_WINS) ||
  908. (pRecordNode->GetType() == DNS_TYPE_NBSTAT) ) && pRecordNode->IsAtTheNode() )
  909. {
  910. ASSERT(m_pWINSRecordNode == NULL);
  911. ASSERT( (IsReverse() && pRecordNode->GetType() == DNS_TYPE_NBSTAT) ||
  912. (!IsReverse() && pRecordNode->GetType() == DNS_TYPE_WINS ) );
  913. m_pWINSRecordNode = pRecordNode;
  914. }
  915. }
  916. //////////////////////////////////////////////////////////////////////////////////
  917. DNS_STATUS CDNSZoneNode::CreatePrimary(LPCTSTR lpszDBName,
  918. BOOL bLoadExisting,
  919. BOOL bDSIntegrated,
  920. UINT nDynamicUpdate)
  921. {
  922. USES_CONVERSION;
  923. DWORD dwZoneType = DNS_ZONE_TYPE_PRIMARY;
  924. IP_ADDRESS adwIpAddressDummy = 0;
  925. LPCWSTR lpszServerName = GetServerNode()->GetRPCName();
  926. LPCSTR lpszAnsiZoneName = W_TO_UTF8(GetFullName());
  927. // create the zone
  928. DNS_STATUS err = ::DnssrvCreateZone(
  929. lpszServerName,
  930. lpszAnsiZoneName,
  931. dwZoneType, // Zone type
  932. NULL, // RNAME field should be NULL according to bug 135245
  933. 0, // Number of masters, NA for primary
  934. &adwIpAddressDummy, // Array of masters, dummy for primary
  935. bLoadExisting,
  936. bDSIntegrated,
  937. bDSIntegrated ? NULL : W_TO_UTF8(lpszDBName), // Database file
  938. 0,
  939. 0);
  940. if (err != 0)
  941. return err;
  942. // set the dynamic update flag
  943. err = ::DnssrvResetDwordProperty(lpszServerName, lpszAnsiZoneName,
  944. DNS_REGKEY_ZONE_ALLOW_UPDATE, nDynamicUpdate);
  945. if (err != 0)
  946. return err;
  947. ASSERT(m_pZoneInfoEx != NULL);
  948. return GetZoneInfo();
  949. }
  950. #ifdef USE_NDNC
  951. DNS_STATUS CDNSZoneNode::CreatePrimaryInDirectoryPartition(BOOL bLoadExisting,
  952. UINT nDynamicUpdate,
  953. ReplicationType replType,
  954. PCWSTR pszPartitionName)
  955. {
  956. USES_CONVERSION;
  957. DWORD dwZoneType = DNS_ZONE_TYPE_PRIMARY;
  958. IP_ADDRESS adwIpAddressDummy = 0;
  959. DWORD dwPartitionFlags = 0;
  960. switch (replType)
  961. {
  962. case forest:
  963. dwPartitionFlags |= DNS_DP_FOREST_DEFAULT;
  964. break;
  965. case domain:
  966. dwPartitionFlags |= DNS_DP_DOMAIN_DEFAULT;
  967. break;
  968. case w2k:
  969. dwPartitionFlags |= DNS_DP_LEGACY;
  970. break;
  971. case custom:
  972. dwPartitionFlags = 0;
  973. break;
  974. case none:
  975. default:
  976. ASSERT(FALSE);
  977. break;
  978. }
  979. LPCWSTR lpszServerName = GetServerNode()->GetRPCName();
  980. LPCSTR lpszAnsiZoneName = W_TO_UTF8(GetFullName());
  981. LPCSTR lpszUTF8PartitionName = W_TO_UTF8(pszPartitionName);
  982. // create the zone
  983. DNS_STATUS err = ::DnssrvCreateZoneInDirectoryPartition(
  984. lpszServerName,
  985. lpszAnsiZoneName,
  986. dwZoneType, // Zone type
  987. NULL, // RNAME field should be NULL according to bug 135245
  988. 0, // Number of masters, NA for primary
  989. &adwIpAddressDummy, // Array of masters, dummy for primary
  990. bLoadExisting,
  991. 0, // dwTimeout
  992. 0, // fSlave
  993. dwPartitionFlags,
  994. (replType == custom) ? lpszUTF8PartitionName : NULL);
  995. if (err != 0)
  996. return err;
  997. // set the dynamic update flag
  998. err = ::DnssrvResetDwordProperty(lpszServerName, lpszAnsiZoneName,
  999. DNS_REGKEY_ZONE_ALLOW_UPDATE, nDynamicUpdate);
  1000. if (err != 0)
  1001. return err;
  1002. ASSERT(m_pZoneInfoEx != NULL);
  1003. return GetZoneInfo();
  1004. }
  1005. DNS_STATUS CDNSZoneNode::CreateStubInDirectoryPartition(DWORD* ipMastersArray,
  1006. int nIPMastersCount,
  1007. BOOL bLoadExisting,
  1008. ReplicationType replType,
  1009. PCWSTR pszPartitionName)
  1010. {
  1011. USES_CONVERSION;
  1012. DWORD dwZoneType = DNS_ZONE_TYPE_STUB;
  1013. DWORD dwPartitionFlags = 0;
  1014. switch (replType)
  1015. {
  1016. case forest:
  1017. dwPartitionFlags |= DNS_DP_FOREST_DEFAULT;
  1018. break;
  1019. case domain:
  1020. dwPartitionFlags |= DNS_DP_DOMAIN_DEFAULT;
  1021. break;
  1022. case w2k:
  1023. dwPartitionFlags |= DNS_DP_LEGACY;
  1024. break;
  1025. case custom:
  1026. dwPartitionFlags = 0;
  1027. break;
  1028. case none:
  1029. default:
  1030. ASSERT(FALSE);
  1031. break;
  1032. }
  1033. ASSERT(ipMastersArray != NULL);
  1034. ASSERT(nIPMastersCount > 0);
  1035. LPCWSTR lpszServerName = GetServerNode()->GetRPCName();
  1036. LPCSTR lpszAnsiZoneName = W_TO_UTF8(GetFullName());
  1037. LPCSTR lpszUTF8PartitionName = W_TO_UTF8(pszPartitionName);
  1038. // create the zone
  1039. DNS_STATUS err = ::DnssrvCreateZoneInDirectoryPartition(
  1040. lpszServerName,
  1041. lpszAnsiZoneName,
  1042. dwZoneType, // Zone type
  1043. NULL, // RNAME field should be NULL according to bug 135245
  1044. nIPMastersCount, // Number of masters, NA for primary
  1045. ipMastersArray, // Array of masters, dummy for primary
  1046. bLoadExisting,
  1047. 0, // dwTimeout
  1048. 0, // fSlave
  1049. dwPartitionFlags,
  1050. (replType == custom) ? lpszUTF8PartitionName : NULL);
  1051. if (err != 0)
  1052. return err;
  1053. ASSERT(m_pZoneInfoEx != NULL);
  1054. return GetZoneInfo();
  1055. }
  1056. #endif // USE_NDNC
  1057. DNS_STATUS CDNSZoneNode::CreateSecondary(DWORD* ipMastersArray, int nIPMastersCount,
  1058. LPCTSTR lpszDBName, BOOL bLoadExisting)
  1059. {
  1060. USES_CONVERSION;
  1061. DWORD dwZoneType = DNS_ZONE_TYPE_SECONDARY;
  1062. ASSERT(ipMastersArray != NULL);
  1063. ASSERT(nIPMastersCount > 0);
  1064. DNS_STATUS err = ::DnssrvCreateZone(
  1065. GetServerNode()->GetRPCName(), // Server name
  1066. W_TO_UTF8(GetFullName()), // Zone name
  1067. dwZoneType, // Zone type
  1068. NULL, // RNAME field should be NULL according to bug 135245
  1069. (DWORD)nIPMastersCount, // Number of masters
  1070. ipMastersArray, // Array of masters
  1071. bLoadExisting,
  1072. FALSE, // fDSIntegrated (secondaries are not in the DS)
  1073. W_TO_UTF8(lpszDBName), // Database file
  1074. 0,
  1075. 0);
  1076. if (err != 0)
  1077. return err;
  1078. ASSERT(m_pZoneInfoEx != NULL);
  1079. return GetZoneInfo();
  1080. }
  1081. DNS_STATUS CDNSZoneNode::CreateStub(DWORD* ipMastersArray,
  1082. int nIPMastersCount,
  1083. LPCTSTR lpszDBName,
  1084. BOOL bLoadExisting,
  1085. BOOL bDSIntegrated)
  1086. {
  1087. USES_CONVERSION;
  1088. DWORD dwZoneType = DNS_ZONE_TYPE_STUB;
  1089. ASSERT(ipMastersArray != NULL);
  1090. ASSERT(nIPMastersCount > 0);
  1091. DNS_STATUS err = ::DnssrvCreateZone(
  1092. GetServerNode()->GetRPCName(), // Server name
  1093. W_TO_UTF8(GetFullName()), // Zone name
  1094. dwZoneType, // Zone type
  1095. NULL, // RNAME field should be NULL according to bug 135245
  1096. (DWORD)nIPMastersCount, // Number of masters
  1097. ipMastersArray, // Array of masters
  1098. bLoadExisting,
  1099. bDSIntegrated,
  1100. (bDSIntegrated) ? NULL : W_TO_UTF8(lpszDBName), // Database file
  1101. 0,
  1102. 0);
  1103. if (err != 0)
  1104. return err;
  1105. ASSERT(m_pZoneInfoEx != NULL);
  1106. return GetZoneInfo();
  1107. }
  1108. DNS_STATUS CDNSZoneNode::CreateForwarder(DWORD* ipMastersArray,
  1109. int nIPMastersCount,
  1110. DWORD dwTimeout,
  1111. DWORD fSlave)
  1112. {
  1113. USES_CONVERSION;
  1114. DWORD dwZoneType = DNS_ZONE_TYPE_FORWARDER;
  1115. DNS_STATUS err = ::DnssrvCreateZone(
  1116. GetServerNode()->GetRPCName(), // Server name
  1117. W_TO_UTF8(GetFullName()), // Zone name
  1118. dwZoneType, // Zone type
  1119. NULL, // RNAME field should be NULL according to bug 135245
  1120. (DWORD)nIPMastersCount, // Number of masters
  1121. ipMastersArray, // Array of masters
  1122. FALSE, // Load existing?
  1123. FALSE, // fDSIntegrated (secondaries are not in the DS)
  1124. NULL, // Database file
  1125. dwTimeout, // Time out
  1126. fSlave); // Slave?
  1127. if (err != 0)
  1128. return err;
  1129. ASSERT(m_pZoneInfoEx != NULL);
  1130. return GetZoneInfo();
  1131. }
  1132. DNS_STATUS CDNSZoneNode::SetSecondary(DWORD cMasters, PIP_ADDRESS aipMasters,
  1133. DWORD dwLoadOptions, LPCTSTR lpszDataFile)
  1134. {
  1135. USES_CONVERSION;
  1136. ASSERT_VALID_ZONE_INFO();
  1137. if (cMasters == 0)
  1138. return DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP;
  1139. DNS_STATUS err = 0;
  1140. IP_ADDRESS dummy;
  1141. if (aipMasters == NULL)
  1142. {
  1143. ASSERT(cMasters == 0);
  1144. aipMasters = &dummy; // RPC wants non null ip array
  1145. }
  1146. err = ::DnssrvResetZoneTypeEx(GetServerNode()->GetRPCName(), // server name
  1147. W_TO_UTF8(GetFullName()), // zone name
  1148. DNS_ZONE_TYPE_SECONDARY,
  1149. cMasters,
  1150. aipMasters,
  1151. dwLoadOptions,
  1152. FALSE, // bDSIntegrated
  1153. W_TO_UTF8(lpszDataFile),
  1154. 0, // DP flags
  1155. NULL); // DP FQDN
  1156. if (err == 0)
  1157. err = GetZoneInfo();
  1158. return err;
  1159. }
  1160. DNS_STATUS CDNSZoneNode::SetStub(DWORD cMasters,
  1161. PIP_ADDRESS aipMasters,
  1162. DWORD dwLoadOptions,
  1163. BOOL bDSIntegrated,
  1164. LPCTSTR lpszDataFile,
  1165. BOOL bLocalListOfMasters)
  1166. {
  1167. USES_CONVERSION;
  1168. ASSERT_VALID_ZONE_INFO();
  1169. if (cMasters == 0)
  1170. return DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP;
  1171. DNS_STATUS err = 0;
  1172. IP_ADDRESS dummy;
  1173. if (aipMasters == NULL)
  1174. {
  1175. ASSERT(cMasters == 0);
  1176. aipMasters = &dummy; // RPC wants non null ip array
  1177. }
  1178. err = ::DnssrvResetZoneTypeEx(GetServerNode()->GetRPCName(), // server name
  1179. W_TO_UTF8(GetFullName()), // zone name
  1180. DNS_ZONE_TYPE_STUB,
  1181. cMasters,
  1182. aipMasters,
  1183. dwLoadOptions,
  1184. bDSIntegrated,
  1185. (bDSIntegrated) ? NULL : W_TO_UTF8(lpszDataFile),
  1186. 0, // DP flags
  1187. NULL); // DP FQDN
  1188. if (err != 0)
  1189. return err;
  1190. if (bLocalListOfMasters)
  1191. {
  1192. err = ::DnssrvResetZoneMastersEx(GetServerNode()->GetRPCName(),
  1193. W_TO_UTF8(GetFullName()),
  1194. cMasters,
  1195. aipMasters,
  1196. TRUE); // LocalListOfMasters
  1197. }
  1198. else
  1199. {
  1200. err = ::DnssrvResetZoneMastersEx(GetServerNode()->GetRPCName(),
  1201. W_TO_UTF8(GetFullName()),
  1202. 0,
  1203. NULL,
  1204. TRUE); // LocalListOfMasters
  1205. }
  1206. if (err == 0)
  1207. err = GetZoneInfo();
  1208. return err;
  1209. }
  1210. DNS_STATUS CDNSZoneNode::SetPrimary(DWORD dwLoadOptions, BOOL bDSIntegrated,
  1211. LPCTSTR lpszDataFile)
  1212. {
  1213. USES_CONVERSION;
  1214. ASSERT_VALID_ZONE_INFO();
  1215. DWORD cDummyMasters = 0; // dummy
  1216. DWORD dwDummyArr = 0;
  1217. DNS_STATUS err = ::DnssrvResetZoneTypeEx(GetServerNode()->GetRPCName(), // server name
  1218. W_TO_UTF8(GetFullName()), // zone name
  1219. DNS_ZONE_TYPE_PRIMARY,
  1220. cDummyMasters, // not neeeded, but have to pass valid RPC val
  1221. &dwDummyArr,
  1222. dwLoadOptions,
  1223. bDSIntegrated,
  1224. bDSIntegrated ? "" : W_TO_UTF8(lpszDataFile),
  1225. 0, // DP flags
  1226. NULL); // DP FQDN
  1227. if (err == 0)
  1228. err = GetZoneInfo();
  1229. return err;
  1230. }
  1231. DNS_STATUS CDNSZoneNode::SetAgingNoRefreshInterval(DWORD dwNoRefreshInterval)
  1232. {
  1233. ASSERT_VALID_ZONE_INFO();
  1234. USES_CONVERSION;
  1235. DNS_STATUS dwErr = ::DnssrvResetDwordProperty(GetServerNode()->GetRPCName(),
  1236. W_TO_UTF8(GetFullName()),
  1237. DNS_REGKEY_ZONE_NOREFRESH_INTERVAL,
  1238. dwNoRefreshInterval);
  1239. if (dwErr == 0 &&
  1240. m_pZoneInfoEx)
  1241. {
  1242. m_pZoneInfoEx->m_pZoneInfo->dwNoRefreshInterval = dwNoRefreshInterval;
  1243. }
  1244. return dwErr;
  1245. }
  1246. DNS_STATUS CDNSZoneNode::SetAgingRefreshInterval(DWORD dwRefreshInterval)
  1247. {
  1248. ASSERT_VALID_ZONE_INFO();
  1249. USES_CONVERSION;
  1250. DNS_STATUS dwErr = ::DnssrvResetDwordProperty(GetServerNode()->GetRPCName(),
  1251. W_TO_UTF8(GetFullName()),
  1252. DNS_REGKEY_ZONE_REFRESH_INTERVAL,
  1253. dwRefreshInterval);
  1254. if (dwErr == 0 &&
  1255. m_pZoneInfoEx)
  1256. {
  1257. m_pZoneInfoEx->m_pZoneInfo->dwRefreshInterval = dwRefreshInterval;
  1258. }
  1259. return dwErr;
  1260. }
  1261. DNS_STATUS CDNSZoneNode::SetScavengingEnabled(BOOL bEnable)
  1262. {
  1263. ASSERT_VALID_ZONE_INFO();
  1264. USES_CONVERSION;
  1265. DNS_STATUS dwErr = ::DnssrvResetDwordProperty(GetServerNode()->GetRPCName(),
  1266. W_TO_UTF8(GetFullName()),
  1267. DNS_REGKEY_ZONE_AGING,
  1268. bEnable);
  1269. if (dwErr == 0 &&
  1270. m_pZoneInfoEx)
  1271. {
  1272. m_pZoneInfoEx->m_pZoneInfo->fAging = bEnable;
  1273. }
  1274. return dwErr;
  1275. }
  1276. DNS_STATUS CDNSZoneNode::Delete(BOOL bDeleteFromDs)
  1277. {
  1278. ASSERT(m_pZoneInfoEx != NULL);
  1279. USES_CONVERSION;
  1280. if (((GetZoneType() == DNS_ZONE_TYPE_PRIMARY) ||
  1281. (GetZoneType() == DNS_ZONE_TYPE_STUB) ||
  1282. (GetZoneType() == DNS_ZONE_TYPE_FORWARDER)) &&
  1283. IsDSIntegrated() && bDeleteFromDs)
  1284. {
  1285. return ::DnssrvOperation(GetServerNode()->GetRPCName(), // server name
  1286. W_TO_UTF8(GetFullName()),
  1287. DNSSRV_OP_ZONE_DELETE_FROM_DS,
  1288. DNSSRV_TYPEID_NULL,
  1289. NULL);
  1290. }
  1291. else
  1292. {
  1293. return ::DnssrvDeleteZone(GetServerNode()->GetRPCName(),
  1294. W_TO_UTF8(GetFullName()));
  1295. }
  1296. }
  1297. DNS_STATUS CDNSZoneNode::IncrementVersion()
  1298. {
  1299. ASSERT(GetZoneType() == DNS_ZONE_TYPE_PRIMARY);
  1300. ASSERT(!IsAutocreated());
  1301. ASSERT(m_pZoneInfoEx != NULL);
  1302. USES_CONVERSION;
  1303. DNS_STATUS err = ::DnssrvIncrementZoneVersion(GetServerNode()->GetRPCName(),
  1304. W_TO_UTF8(GetFullName()));
  1305. // refresh Zone Info if already present
  1306. if ((err == 0) && m_pZoneInfoEx->HasData())
  1307. err = GetZoneInfo();
  1308. return err;
  1309. }
  1310. DNS_STATUS CDNSZoneNode::Reload()
  1311. {
  1312. ASSERT(GetZoneType() == DNS_ZONE_TYPE_PRIMARY);
  1313. ASSERT(!IsAutocreated());
  1314. ASSERT(m_pZoneInfoEx != NULL);
  1315. USES_CONVERSION;
  1316. return ::DnssrvOperation(GetServerNode()->GetRPCName(), // server name
  1317. W_TO_UTF8(GetFullName()),
  1318. DNSSRV_OP_ZONE_RELOAD,
  1319. DNSSRV_TYPEID_NULL,
  1320. NULL);
  1321. }
  1322. DNS_STATUS CDNSZoneNode::TransferFromMaster()
  1323. {
  1324. ASSERT(GetZoneType() == DNS_ZONE_TYPE_SECONDARY || GetZoneType() == DNS_ZONE_TYPE_STUB);
  1325. ASSERT(!IsAutocreated());
  1326. ASSERT(m_pZoneInfoEx != NULL);
  1327. USES_CONVERSION;
  1328. return ::DnssrvOperation(GetServerNode()->GetRPCName(), // server name
  1329. W_TO_UTF8(GetFullName()),
  1330. DNSSRV_OP_ZONE_REFRESH,
  1331. DNSSRV_TYPEID_NULL,
  1332. NULL);
  1333. }
  1334. DNS_STATUS CDNSZoneNode::ReloadFromMaster()
  1335. {
  1336. ASSERT(GetZoneType() == DNS_ZONE_TYPE_SECONDARY || GetZoneType() == DNS_ZONE_TYPE_STUB);
  1337. ASSERT(!IsAutocreated());
  1338. ASSERT(m_pZoneInfoEx != NULL);
  1339. USES_CONVERSION;
  1340. return ::DnssrvOperation(GetServerNode()->GetRPCName(), // server name
  1341. W_TO_UTF8(GetFullName()),
  1342. DNSSRV_OP_ZONE_EXPIRE,
  1343. DNSSRV_TYPEID_NULL,
  1344. NULL);
  1345. }
  1346. PCWSTR CDNSZoneNode::GetDN()
  1347. {
  1348. ASSERT(IsDSIntegrated());
  1349. ASSERT(m_pZoneInfoEx);
  1350. ASSERT(m_pZoneInfoEx->HasData());
  1351. if (m_pZoneInfoEx &&
  1352. m_pZoneInfoEx->HasData())
  1353. {
  1354. return m_pZoneInfoEx->m_pZoneInfo->pwszZoneDn;
  1355. }
  1356. return L"";
  1357. }
  1358. BOOL CDNSZoneNode::IsDSIntegrated()
  1359. {
  1360. if (GetZoneType() == DNS_ZONE_TYPE_CACHE)
  1361. return FALSE;
  1362. BOOL result = FALSE;
  1363. if (m_pZoneInfoEx)
  1364. {
  1365. result = (m_pZoneInfoEx->HasData()) ?
  1366. (m_pZoneInfoEx->m_pZoneInfo->fUseDatabase ? TRUE : FALSE):
  1367. ((m_dwZoneFlags & DNS_ZONE_DsIntegrated) != 0);
  1368. }
  1369. return result;
  1370. }
  1371. //sz = _T("LDAP://DC=uidev-one,DC=ntdev,DC=Microsoft,DC=Com,O=Internet");
  1372. void CDNSZoneNode::GetDataFile(CString& szName)
  1373. {
  1374. ASSERT_VALID_ZONE_INFO();
  1375. USES_CONVERSION;
  1376. if (m_pZoneInfoEx == NULL || m_pZoneInfoEx->m_pZoneInfo == NULL)
  1377. {
  1378. szName = L"";
  1379. }
  1380. else
  1381. {
  1382. szName = UTF8_TO_W(m_pZoneInfoEx->m_pZoneInfo->pszDataFile);
  1383. }
  1384. }
  1385. LPCSTR CDNSZoneNode::GetDataFile()
  1386. {
  1387. ASSERT_VALID_ZONE_INFO();
  1388. if (m_pZoneInfoEx == NULL || m_pZoneInfoEx->m_pZoneInfo == NULL)
  1389. {
  1390. return "";
  1391. }
  1392. return m_pZoneInfoEx->m_pZoneInfo->pszDataFile;
  1393. }
  1394. DNS_STATUS CDNSZoneNode::ResetDatabase(BOOL bDSIntegrated, LPCTSTR lpszDataFile)
  1395. {
  1396. ASSERT_VALID_ZONE_INFO();
  1397. USES_CONVERSION;
  1398. DNS_STATUS err = ::DnssrvResetZoneDatabase(GetServerNode()->GetRPCName(), // server name
  1399. W_TO_UTF8(GetFullName()), // zone name
  1400. bDSIntegrated,
  1401. W_TO_UTF8(lpszDataFile));
  1402. if (err == 0)
  1403. err = GetZoneInfo();
  1404. return err;
  1405. }
  1406. DNS_STATUS CDNSZoneNode::WriteToDatabase()
  1407. {
  1408. ASSERT_VALID_ZONE_INFO();
  1409. return CDNSZoneNode::WriteToDatabase(GetServerNode()->GetRPCName(), // server name
  1410. GetFullName()); // zone name
  1411. }
  1412. DNS_STATUS CDNSZoneNode::WriteToDatabase(LPCWSTR lpszServer, LPCWSTR lpszZone)
  1413. {
  1414. USES_CONVERSION;
  1415. return ::DnssrvOperation(lpszServer, W_TO_UTF8(lpszZone),
  1416. DNSSRV_OP_ZONE_WRITE_BACK_FILE,
  1417. DNSSRV_TYPEID_NULL,
  1418. NULL);
  1419. }
  1420. DNS_STATUS CDNSZoneNode::WriteToDatabase(LPCWSTR lpszServer, LPCSTR lpszZone)
  1421. {
  1422. return ::DnssrvOperation(lpszServer, lpszZone,
  1423. DNSSRV_OP_ZONE_WRITE_BACK_FILE,
  1424. DNSSRV_TYPEID_NULL,
  1425. NULL);
  1426. }
  1427. UINT CDNSZoneNode::GetDynamicUpdate()
  1428. {
  1429. ASSERT_VALID_ZONE_INFO();
  1430. UINT result = 0;
  1431. if (m_pZoneInfoEx &&
  1432. m_pZoneInfoEx->HasData())
  1433. {
  1434. result = m_pZoneInfoEx->m_pZoneInfo->fAllowUpdate;
  1435. }
  1436. return result;
  1437. }
  1438. DNS_STATUS CDNSZoneNode::SetDynamicUpdate(UINT nDynamic)
  1439. {
  1440. ASSERT_VALID_ZONE_INFO();
  1441. DNS_STATUS err = 0;
  1442. // call only if the info is dirty
  1443. if (GetDynamicUpdate() != nDynamic)
  1444. {
  1445. USES_CONVERSION;
  1446. err = ::DnssrvResetDwordProperty(GetServerNode()->GetRPCName(), // server name
  1447. m_pZoneInfoEx->m_pZoneInfo->pszZoneName,
  1448. DNS_REGKEY_ZONE_ALLOW_UPDATE,
  1449. nDynamic);
  1450. if (err != 0)
  1451. return err;
  1452. err = GetZoneInfo();
  1453. }
  1454. return err;
  1455. }
  1456. DNS_STATUS CDNSZoneNode::ResetSecondaries(DWORD fSecureSecondaries,
  1457. DWORD cSecondaries, PIP_ADDRESS aipSecondaries,
  1458. DWORD fNotifyLevel,
  1459. DWORD cNotify, PIP_ADDRESS aipNotify)
  1460. {
  1461. ASSERT_VALID_ZONE_INFO();
  1462. DNS_STATUS err = 0;
  1463. BOOL bSecondariesDirty = (m_pZoneInfoEx->m_pZoneInfo->fSecureSecondaries != fSecureSecondaries) ||
  1464. (m_pZoneInfoEx->m_pZoneInfo->fNotifyLevel != fNotifyLevel) ||
  1465. (!(m_pZoneInfoEx->m_pZoneInfo->aipSecondaries == NULL && cSecondaries == 0) &&
  1466. (
  1467. (m_pZoneInfoEx->m_pZoneInfo->aipSecondaries == NULL && cSecondaries > 0) || // no addr --> more than one
  1468. (m_pZoneInfoEx->m_pZoneInfo->aipSecondaries->AddrCount != cSecondaries) || // change the # of addresses
  1469. (memcmp(aipSecondaries, m_pZoneInfoEx->m_pZoneInfo->aipSecondaries->AddrArray, sizeof(IP_ADDRESS)*cSecondaries) != 0)
  1470. )
  1471. );
  1472. BOOL bNotifyDirty =
  1473. (!(m_pZoneInfoEx->m_pZoneInfo->aipNotify == NULL && cNotify == 0) &&
  1474. (
  1475. (m_pZoneInfoEx->m_pZoneInfo->aipNotify == NULL && cNotify > 0) || // no addr --> more than one
  1476. (m_pZoneInfoEx->m_pZoneInfo->aipNotify->AddrCount != cNotify) || // change the # of addresses
  1477. (memcmp(aipNotify, m_pZoneInfoEx->m_pZoneInfo->aipNotify->AddrArray, sizeof(IP_ADDRESS)*cNotify) != 0)
  1478. )
  1479. );
  1480. if (bSecondariesDirty || bNotifyDirty)
  1481. {
  1482. USES_CONVERSION;
  1483. err = ::DnssrvResetZoneSecondaries(GetServerNode()->GetRPCName(), // server name
  1484. W_TO_UTF8(GetFullName()), // zone name
  1485. fSecureSecondaries,
  1486. cSecondaries,
  1487. aipSecondaries,
  1488. fNotifyLevel,
  1489. cNotify,
  1490. aipNotify
  1491. );
  1492. }
  1493. if (err == 0)
  1494. err = GetZoneInfo();
  1495. return err;
  1496. }
  1497. void CDNSZoneNode::GetSecondariesInfo(DWORD* pfSecureSecondaries,
  1498. DWORD* pcSecondaries, PIP_ADDRESS* paipSecondaries,
  1499. DWORD* pfNotifyLevel,
  1500. DWORD* pcNotify, PIP_ADDRESS* paipNotify)
  1501. {
  1502. ASSERT_VALID_ZONE_INFO();
  1503. ASSERT(pfSecureSecondaries != NULL);
  1504. ASSERT(pcSecondaries != NULL);
  1505. ASSERT(paipSecondaries != NULL);
  1506. ASSERT(pfNotifyLevel != NULL);
  1507. ASSERT(pcNotify != NULL);
  1508. ASSERT(paipNotify != NULL);
  1509. *pfSecureSecondaries = m_pZoneInfoEx->m_pZoneInfo->fSecureSecondaries;
  1510. // return pointers to struct fields, caller has to copy data elsewhere
  1511. if (m_pZoneInfoEx->m_pZoneInfo->aipSecondaries == NULL)
  1512. {
  1513. *pcSecondaries = 0;
  1514. *paipSecondaries = NULL;
  1515. }
  1516. else
  1517. {
  1518. *pcSecondaries = m_pZoneInfoEx->m_pZoneInfo->aipSecondaries->AddrCount;
  1519. *paipSecondaries = m_pZoneInfoEx->m_pZoneInfo->aipSecondaries->AddrArray;
  1520. }
  1521. *pfNotifyLevel = m_pZoneInfoEx->m_pZoneInfo->fNotifyLevel;
  1522. // return pointers to struct fields, caller has to copy data elsewhere
  1523. if (m_pZoneInfoEx->m_pZoneInfo->aipNotify == NULL)
  1524. {
  1525. *pcNotify = 0;
  1526. *paipNotify = NULL;
  1527. }
  1528. else
  1529. {
  1530. *pcNotify = m_pZoneInfoEx->m_pZoneInfo->aipNotify->AddrCount;
  1531. *paipNotify = m_pZoneInfoEx->m_pZoneInfo->aipNotify->AddrArray;
  1532. }
  1533. }
  1534. DNS_STATUS CDNSZoneNode::ResetMasters(DWORD cMasters, PIP_ADDRESS aipMasters, BOOL bLocalMasters)
  1535. {
  1536. ASSERT_VALID_ZONE_INFO();
  1537. if (cMasters == 0)
  1538. return DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP;
  1539. USES_CONVERSION;
  1540. // make the call only if the data is dirty
  1541. DNS_STATUS err = 0;
  1542. if ((m_pZoneInfoEx->m_pZoneInfo->aipMasters == NULL && cMasters > 0) || // no addr --> more than one
  1543. (m_pZoneInfoEx->m_pZoneInfo->aipMasters->AddrCount != cMasters) || // change the # of addresses
  1544. (memcmp(aipMasters, m_pZoneInfoEx->m_pZoneInfo->aipMasters->AddrArray, sizeof(IP_ADDRESS)*cMasters) != 0) )
  1545. {
  1546. IP_ADDRESS dummy;
  1547. if (aipMasters == NULL)
  1548. {
  1549. ASSERT(cMasters == 0);
  1550. aipMasters = &dummy; // RPC wants non null ip array
  1551. }
  1552. err = ::DnssrvResetZoneMastersEx(GetServerNode()->GetRPCName(), // server name
  1553. W_TO_UTF8(GetFullName()), // zone name
  1554. cMasters,
  1555. aipMasters,
  1556. bLocalMasters);
  1557. if (!bLocalMasters)
  1558. {
  1559. //
  1560. // Reset local list of masters
  1561. //
  1562. err = ::DnssrvResetZoneMastersEx(GetServerNode()->GetRPCName(), // server name
  1563. W_TO_UTF8(GetFullName()), // zone name
  1564. 0,
  1565. NULL,
  1566. TRUE); // LocalListOfMasters
  1567. if (err != 0)
  1568. return err;
  1569. }
  1570. }
  1571. if (err == 0)
  1572. err = GetZoneInfo();
  1573. return err;
  1574. }
  1575. void CDNSZoneNode::GetMastersInfo(DWORD* pcAddrCount, PIP_ADDRESS* ppipAddrs)
  1576. {
  1577. ASSERT_VALID_ZONE_INFO();
  1578. ASSERT(pcAddrCount != NULL);
  1579. ASSERT(ppipAddrs != NULL);
  1580. // return pointers to struct fields, caller has to copy data elsewhere
  1581. if (m_pZoneInfoEx == NULL ||
  1582. m_pZoneInfoEx->m_pZoneInfo == NULL ||
  1583. m_pZoneInfoEx->m_pZoneInfo->aipMasters == NULL)
  1584. {
  1585. *pcAddrCount = 0;
  1586. *ppipAddrs = NULL;
  1587. }
  1588. else
  1589. {
  1590. *pcAddrCount = m_pZoneInfoEx->m_pZoneInfo->aipMasters->AddrCount;
  1591. *ppipAddrs = m_pZoneInfoEx->m_pZoneInfo->aipMasters->AddrArray;
  1592. }
  1593. }
  1594. void CDNSZoneNode::GetLocalListOfMasters(DWORD* pcAddrCount, PIP_ADDRESS* ppipAddrs)
  1595. {
  1596. ASSERT_VALID_ZONE_INFO();
  1597. ASSERT(pcAddrCount != NULL);
  1598. ASSERT(ppipAddrs != NULL);
  1599. // return pointers to struct fields, caller has to copy data elsewhere
  1600. if (m_pZoneInfoEx->m_pZoneInfo->aipLocalMasters == NULL)
  1601. {
  1602. *pcAddrCount = 0;
  1603. *ppipAddrs = NULL;
  1604. }
  1605. else
  1606. {
  1607. *pcAddrCount = m_pZoneInfoEx->m_pZoneInfo->aipLocalMasters->AddrCount;
  1608. *ppipAddrs = m_pZoneInfoEx->m_pZoneInfo->aipLocalMasters->AddrArray;
  1609. }
  1610. }
  1611. DNS_STATUS CDNSZoneNode::TogglePauseHelper(CComponentDataObject* pComponentData)
  1612. {
  1613. ASSERT(m_nState == loaded);
  1614. OnChangeState(pComponentData); // move to loading
  1615. m_dwErr = TogglePause();
  1616. OnChangeState(pComponentData); // move to loaded or unableToLoad
  1617. return (DNS_STATUS)m_dwErr;
  1618. }
  1619. DNS_STATUS CDNSZoneNode::TogglePause()
  1620. {
  1621. ASSERT_VALID_ZONE_INFO();
  1622. USES_CONVERSION;
  1623. DNS_STATUS err;
  1624. if (IsPaused())
  1625. err = ::DnssrvResumeZone(GetServerNode()->GetRPCName(),
  1626. W_TO_UTF8(GetFullName()) // zone name
  1627. );
  1628. else
  1629. err = ::DnssrvPauseZone(GetServerNode()->GetRPCName(),
  1630. W_TO_UTF8(GetFullName()) // zone name
  1631. );
  1632. if (err != 0)
  1633. return err;
  1634. err = GetZoneInfo();
  1635. ASSERT(err == 0);
  1636. return err;
  1637. }
  1638. void CDNSZoneNode::ToggleView(CComponentDataObject* pComponentData)
  1639. {
  1640. if (pComponentData)
  1641. {
  1642. pComponentData->UpdateResultPaneView(this);
  1643. }
  1644. }
  1645. BOOL CDNSZoneNode::IsPaused()
  1646. {
  1647. if (m_pZoneInfoEx != NULL && m_pZoneInfoEx->HasData())
  1648. {
  1649. ASSERT_VALID_ZONE_INFO();
  1650. return m_pZoneInfoEx->m_pZoneInfo->fPaused;
  1651. }
  1652. return ((m_dwZoneFlags & DNS_ZONE_Paused) != 0);
  1653. }
  1654. BOOL CDNSZoneNode::IsExpired()
  1655. {
  1656. ASSERT(m_pZoneInfoEx != NULL);
  1657. return (m_pZoneInfoEx->HasData()) ? m_pZoneInfoEx->m_pZoneInfo->fShutdown :
  1658. ((m_dwZoneFlags & DNS_ZONE_Shutdown) != 0);
  1659. }
  1660. //////////////////////////////////////////////////////////////////////////
  1661. // editing API's for special record types
  1662. CDNS_SOA_Record* CDNSZoneNode::GetSOARecordCopy()
  1663. {
  1664. ASSERT(m_pSOARecordNode != NULL);
  1665. if (m_pSOARecordNode == NULL)
  1666. return NULL;
  1667. return (CDNS_SOA_Record*)m_pSOARecordNode->CreateCloneRecord();
  1668. }
  1669. DNS_STATUS CDNSZoneNode::UpdateSOARecord(CDNS_SOA_Record* pNewRecord,
  1670. CComponentDataObject* pComponentData)
  1671. {
  1672. ASSERT(m_pSOARecordNode != NULL);
  1673. if (m_pSOARecordNode == NULL)
  1674. {
  1675. return -1;
  1676. }
  1677. DNS_STATUS err = m_pSOARecordNode->Update(pNewRecord, FALSE /*bUseDefaultTTL*/);
  1678. if ( (err == 0) && (pComponentData != NULL) )
  1679. {
  1680. VERIFY(SUCCEEDED(pComponentData->ChangeNode(m_pSOARecordNode, CHANGE_RESULT_ITEM)));
  1681. }
  1682. return err;
  1683. }
  1684. CDNSRecord* CDNSZoneNode::GetWINSRecordCopy()
  1685. {
  1686. ASSERT(m_pWINSRecordNode != NULL);
  1687. if (m_pWINSRecordNode == NULL)
  1688. return NULL;
  1689. return m_pWINSRecordNode->CreateCloneRecord();
  1690. }
  1691. DNS_STATUS CDNSZoneNode::CreateWINSRecord(CDNSRecord* pNewWINSRecord,
  1692. CComponentDataObject* pComponentData)
  1693. {
  1694. TRACE(_T("CDNSZoneNode::CreateWINSRecord()\n"));
  1695. ASSERT(pNewWINSRecord != NULL);
  1696. if (m_pWINSRecordNode != NULL)
  1697. {
  1698. //
  1699. // should never happen
  1700. //
  1701. ASSERT(FALSE && m_pWINSRecordNode == NULL);
  1702. return -1;
  1703. }
  1704. //
  1705. // create a new record node object
  1706. //
  1707. if (IsReverse())
  1708. {
  1709. m_pWINSRecordNode = CDNSRecordInfo::CreateRecordNode(DNS_TYPE_NBSTAT);
  1710. }
  1711. else
  1712. {
  1713. m_pWINSRecordNode = CDNSRecordInfo::CreateRecordNode(DNS_TYPE_WINS);
  1714. }
  1715. //
  1716. // hook up container and set name of node (same as the zone)
  1717. //
  1718. m_pWINSRecordNode->SetContainer(this);
  1719. m_pWINSRecordNode->SetRecordName(GetDisplayName(), TRUE /*bAtTheNode */);
  1720. CDNSRootData* pRootData = (CDNSRootData*)(pComponentData->GetRootData());
  1721. ASSERT(pRootData != NULL);
  1722. m_pWINSRecordNode->SetFlagsDown(TN_FLAG_DNS_RECORD_FULL_NAME, !pRootData->IsAdvancedView());
  1723. //
  1724. // write on server
  1725. //
  1726. DNS_STATUS err = m_pWINSRecordNode->Update(pNewWINSRecord, TRUE /*bUseDefaultTTL*/);
  1727. if (err == 0)
  1728. {
  1729. VERIFY(AddChildToListAndUI(m_pWINSRecordNode, pComponentData));
  1730. pComponentData->SetDescriptionBarText(this);
  1731. }
  1732. else
  1733. {
  1734. delete m_pWINSRecordNode;
  1735. m_pWINSRecordNode = NULL;
  1736. }
  1737. TRACE(_T("EXIT\n"));
  1738. return err;
  1739. }
  1740. DNS_STATUS CDNSZoneNode::UpdateWINSRecord(CDNSRecord* pNewWINSRecord,
  1741. CComponentDataObject* pComponentData)
  1742. {
  1743. TRACE(_T("CDNSZoneNode::UpdateWINSRecord()\n"));
  1744. ASSERT(pNewWINSRecord != NULL);
  1745. ASSERT(m_pWINSRecordNode != NULL);
  1746. if (m_pWINSRecordNode == NULL)
  1747. {
  1748. return -1; // Bogus error code
  1749. }
  1750. ASSERT(
  1751. (IsReverse() && pNewWINSRecord->GetType() == DNS_TYPE_NBSTAT
  1752. && m_pWINSRecordNode->GetType() == DNS_TYPE_NBSTAT) ||
  1753. (!IsReverse() && pNewWINSRecord->GetType() == DNS_TYPE_WINS
  1754. && m_pWINSRecordNode->GetType() == DNS_TYPE_WINS)
  1755. );
  1756. DNS_STATUS err = m_pWINSRecordNode->Update(pNewWINSRecord, TRUE /*bUseDefaultTTL*/);
  1757. if (err == 0)
  1758. {
  1759. VERIFY(SUCCEEDED(pComponentData->ChangeNode(m_pWINSRecordNode, CHANGE_RESULT_ITEM)));
  1760. }
  1761. TRACE(_T("EXIT\n"));
  1762. return err;
  1763. }
  1764. DNS_STATUS CDNSZoneNode::DeleteWINSRecord(CComponentDataObject* pComponentData)
  1765. {
  1766. TRACE(_T("CDNSZoneNode::DeleteWINSRecord()\n"));
  1767. ASSERT(m_pWINSRecordNode != NULL);
  1768. if (m_pWINSRecordNode == NULL)
  1769. {
  1770. return -1; // bogus error code
  1771. }
  1772. DNS_STATUS err = m_pWINSRecordNode->DeleteOnServerAndUI(pComponentData);
  1773. if (err == 0)
  1774. {
  1775. delete m_pWINSRecordNode;
  1776. m_pWINSRecordNode = NULL;
  1777. }
  1778. TRACE(_T("EXIT\n"));
  1779. return err;
  1780. }