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.

877 lines
27 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: server.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _SERVER_H
  11. #define _SERVER_H
  12. #include "dnsutil.h"
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // GLOBAL FUNCTIONS
  15. DNS_STATUS ServerHasCache(LPCWSTR lpszServerName, BOOL* pbRes);
  16. DNS_STATUS ServerHasRootZone(LPCWSTR lpszServerName, BOOL* pbRes);
  17. extern LPCWSTR DNS_EVT_COMMAND_LINE;
  18. extern LPCWSTR MMC_APP;
  19. ///////////////////////////////////////////////////////////////////////////////
  20. // FORWARD DECLARATIONS
  21. class CDNSMTContainerNode;
  22. class CDNSServerNode;
  23. class CDNSZoneNode;
  24. class CDNSDomainNode;
  25. class CCathegoryFolderNode;
  26. class CDNSRootHintsNode;
  27. class CDNSServer_TestPropertyPage;
  28. class CDNSQueryFilter;
  29. ///////////////////////////////////////////////////////////////////////////////
  30. // defines for server test intervals
  31. #define MIN_SERVER_TEST_INTERVAL 30 // seconds
  32. #define MAX_SERVER_TEST_INTERVAL 3600 // seconds in 1 hour
  33. #define DEFAULT_SERVER_TEST_INTERVAL 60 // seconds
  34. ///////////////////////////////////////////////////////////////////////////////
  35. // defines for server sheet messages
  36. #define SHEET_MSG_SERVER_TEST_DATA (1)
  37. #define SHEET_MSG_SELECT_PAGE (2)
  38. ///////////////////////////////////////////////////////////////////////////////
  39. // CZoneInfoHolder : simple memory manager for arrays of zone info handles
  40. class CZoneInfoHolder
  41. {
  42. public:
  43. CZoneInfoHolder();
  44. ~CZoneInfoHolder();
  45. BOOL Grow();
  46. PDNS_ZONE_INFO* m_zoneInfoArray;
  47. DWORD m_dwArrSize;
  48. DWORD m_dwZoneCount;
  49. private:
  50. void AllocateMemory(DWORD dwArrSize);
  51. void FreeMemory();
  52. };
  53. ///////////////////////////////////////////////////////////////////////////////
  54. // CDNSMTContainerNode
  55. // base class from which all the MT nodes derive from
  56. class CDNSMTContainerNode : public CMTContainerNode
  57. {
  58. public:
  59. // enumeration for node states, to handle icon changes
  60. typedef enum
  61. {
  62. notLoaded = 0, // initial state, valid only if server never contacted
  63. loading,
  64. loaded,
  65. unableToLoad,
  66. accessDenied
  67. } nodeStateType;
  68. CDNSMTContainerNode();
  69. void SetServerNode(CDNSServerNode* pServerNode)
  70. { ASSERT(pServerNode != NULL); m_pServerNode = pServerNode; }
  71. CDNSServerNode* GetServerNode()
  72. { ASSERT( m_pServerNode != NULL); return m_pServerNode; }
  73. virtual HRESULT OnSetToolbarVerbState(IToolbar* pToolbar, CNodeList* pNodeList);
  74. virtual int GetImageIndex(BOOL bOpenImage);
  75. virtual CColumnSet* GetColumnSet()
  76. {
  77. if (m_pColumnSet == NULL)
  78. {
  79. CDNSRootData* pRoot = (CDNSRootData*)GetRootContainer();
  80. m_pColumnSet = ((CDNSComponentDataObjectBase*)pRoot->GetComponentDataObject())->GetColumnSet(L"---Default Column Set---");
  81. }
  82. return m_pColumnSet;
  83. }
  84. virtual LPCWSTR GetColumnID() { return GetColumnSet()->GetColumnID(); }
  85. virtual LPWSTR GetDescriptionBarText();
  86. protected:
  87. virtual BOOL CanCloseSheets();
  88. virtual void OnChangeState(CComponentDataObject* pComponentDataObject);
  89. virtual void OnHaveData(CObjBase* pObj, CComponentDataObject* pComponentDataObject);
  90. virtual void OnError(DWORD dwErr);
  91. CColumnSet* m_pColumnSet;
  92. CString m_szDescriptionBar;
  93. private:
  94. CDNSServerNode* m_pServerNode;
  95. };
  96. ///////////////////////////////////////////////////////////////////////////////
  97. // CDNSQueryObj : general purpose base class
  98. class CDNSQueryObj : public CQueryObj
  99. {
  100. public:
  101. CDNSQueryObj(BOOL bAdvancedView, DWORD dwServerVersion)
  102. {
  103. m_dwServerVersion = dwServerVersion;
  104. m_bAdvancedView = bAdvancedView;
  105. // internal state variables
  106. m_nObjectCount = 0;
  107. m_nMaxObjectCount = DNS_QUERY_OBJ_COUNT_MAX;
  108. m_bGetAll = TRUE;
  109. m_nFilterOption = DNS_QUERY_FILTER_DISABLED;
  110. }
  111. CString m_szServerName;
  112. DWORD m_dwServerVersion;
  113. BOOL m_bAdvancedView;
  114. public:
  115. virtual BOOL AddQueryResult(CObjBase* pObj)
  116. {
  117. BOOL bRet = CQueryObj::AddQueryResult(pObj);
  118. if (bRet)
  119. m_nObjectCount++;
  120. return bRet;
  121. }
  122. void SetFilterOptions(CDNSQueryFilter* pFilter);
  123. BOOL TooMuchData();
  124. protected:
  125. ULONG m_nMaxObjectCount; // max number of objects in a query
  126. BOOL m_bGetAll;
  127. ULONG m_nObjectCount; // number of objects queried so far
  128. UINT m_nFilterOption;
  129. CString m_szFilterString1;
  130. int m_nFilterStringLen1; // cached value
  131. CString m_szFilterString2;
  132. int m_nFilterStringLen2; // cached value
  133. protected:
  134. BOOL MatchName(LPCWSTR lpszName);
  135. };
  136. /////////////////////////////////////////////////////////////////////////
  137. // CCathegoryFolderNode
  138. class CCathegoryFolderQueryObj : public CDNSQueryObj
  139. {
  140. public:
  141. CCathegoryFolderQueryObj(BOOL bAdvancedView, DWORD dwServerVersion)
  142. : CDNSQueryObj(bAdvancedView, dwServerVersion)
  143. {
  144. }
  145. virtual BOOL Enumerate();
  146. typedef enum { unk, cache, fwdAuthoritated, revAuthoritated, domainForwarders } queryType;
  147. void SetType(queryType type) { m_type = type;}
  148. protected:
  149. queryType m_type;
  150. BOOL CanAddZone(PDNS_RPC_ZONE pZoneInfo);
  151. };
  152. class CCathegoryFolderNode : public CDNSMTContainerNode
  153. {
  154. public:
  155. CCathegoryFolderNode()
  156. {
  157. m_type = CCathegoryFolderQueryObj::unk;
  158. }
  159. virtual HRESULT OnCommand(long nCommandID,
  160. DATA_OBJECT_TYPES type,
  161. CComponentDataObject* pComponentData,
  162. CNodeList* pNodeList);
  163. virtual void OnDelete(CComponentDataObject*,
  164. CNodeList*)
  165. { ASSERT(FALSE);}
  166. virtual BOOL OnSetRefreshVerbState(DATA_OBJECT_TYPES type,
  167. BOOL* pbHide,
  168. CNodeList* pNodeList);
  169. virtual LPCWSTR GetString(int nCol)
  170. {
  171. return (nCol == 0) ? GetDisplayName() : g_lpszNullString;
  172. }
  173. CCathegoryFolderQueryObj::queryType GetType() { return m_type;}
  174. virtual LPWSTR GetDescriptionBarText();
  175. virtual CColumnSet* GetColumnSet()
  176. {
  177. if (m_pColumnSet == NULL)
  178. {
  179. CDNSRootData* pRoot = (CDNSRootData*)GetRootContainer();
  180. m_pColumnSet = ((CDNSComponentDataObjectBase*)pRoot->GetComponentDataObject())->GetColumnSet(L"---Zone Column Set---");
  181. }
  182. return m_pColumnSet;
  183. }
  184. virtual BOOL CanExpandSync() { return FALSE; }
  185. protected:
  186. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  187. { return CDNSCathegoryFolderHolder::GetContextMenuItem(); }
  188. virtual BOOL OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  189. long *pInsertionAllowed);
  190. virtual CQueryObj* OnCreateQuery();
  191. CCathegoryFolderQueryObj::queryType m_type;
  192. };
  193. /////////////////////////////////////////////////////////////////////////
  194. // CDNSCacheNode
  195. //
  196. // * contains the root domain "."
  197. // * can delete items underneath, but cannot add or modify
  198. class CDNSCacheNode : public CCathegoryFolderNode
  199. {
  200. public:
  201. CDNSCacheNode();
  202. virtual HRESULT OnCommand(long nCommandID,
  203. DATA_OBJECT_TYPES type,
  204. CComponentDataObject* pComponentData,
  205. CNodeList* pNodeList);
  206. void OnClearCache(CComponentDataObject* pComponentData);
  207. virtual BOOL CanExpandSync() { return FALSE; }
  208. protected:
  209. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  210. { return CDNSCacheMenuHolder::GetContextMenuItem(); }
  211. virtual BOOL OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  212. long *pInsertionAllowed);
  213. };
  214. /////////////////////////////////////////////////////////////////////////
  215. // CDNSDomainForwardersNode
  216. //
  217. // * contains the domain forwarders as zones
  218. // * this node will always be hidden
  219. //
  220. class CDNSDomainForwardersNode : public CCathegoryFolderNode
  221. {
  222. public:
  223. CDNSDomainForwardersNode();
  224. virtual BOOL OnEnumerate(CComponentDataObject* pComponentData, BOOL bAsync = TRUE);
  225. };
  226. /////////////////////////////////////////////////////////////////////////
  227. // CDNSAuthoritatedZonesNode
  228. //
  229. // * contains autoritated zones, both primary and secondary
  230. // * have one for FWD and one for REVERSE
  231. class CDNSAuthoritatedZonesNode : public CCathegoryFolderNode
  232. {
  233. public:
  234. CDNSAuthoritatedZonesNode(BOOL bReverse, UINT nStringID);
  235. BOOL IsReverse() { return m_bReverse;}
  236. virtual HRESULT OnCommand(long nCommandID,
  237. DATA_OBJECT_TYPES type,
  238. CComponentDataObject* pComponentData,
  239. CNodeList* pNodeList);
  240. virtual BOOL OnSetRefreshVerbState(DATA_OBJECT_TYPES type,
  241. BOOL* pbHide,
  242. CNodeList* pNodeList);
  243. virtual HRESULT OnSetToolbarVerbState(IToolbar* pToolbar,
  244. CNodeList* pNodeList);
  245. virtual BOOL CanExpandSync() { return FALSE; }
  246. protected:
  247. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  248. { return CDNSAuthoritatedZonesMenuHolder::GetContextMenuItem(); }
  249. virtual BOOL OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  250. long *pInsertionAllowed);
  251. private:
  252. // command handlers
  253. HRESULT OnNewZone(CComponentDataObject* pComponentData, CNodeList* pNodeList);
  254. // data
  255. BOOL m_bReverse;
  256. DECLARE_TOOLBAR_MAP()
  257. };
  258. /////////////////////////////////////////////////////////////////////////
  259. // CDNSForwardZonesNode
  260. class CDNSForwardZonesNode : public CDNSAuthoritatedZonesNode
  261. {
  262. public:
  263. CDNSForwardZonesNode();
  264. virtual HRESULT OnShow(LPCONSOLE lpConsole);
  265. virtual HRESULT GetResultViewType(CComponentDataObject* pComponentData,
  266. LPOLESTR *ppViewType,
  267. long *pViewOptions);
  268. };
  269. /////////////////////////////////////////////////////////////////////////
  270. // CDNSReverseZonesNode
  271. class CDNSReverseZonesNode : public CDNSAuthoritatedZonesNode
  272. {
  273. public:
  274. CDNSReverseZonesNode();
  275. virtual BOOL OnRefresh(CComponentDataObject* pComponentData,
  276. CNodeList* pNodeList);
  277. protected:
  278. virtual void OnHaveData(CObjBase* pObj, CComponentDataObject* pComponentDataObject);
  279. void ChangeViewOption(BOOL bAdvanced, CComponentDataObject* pComponentDataObject);
  280. virtual HRESULT OnShow(LPCONSOLE lpConsole);
  281. virtual HRESULT GetResultViewType(CComponentDataObject* pComponentData,
  282. LPOLESTR *ppViewType,
  283. long *pViewOptions);
  284. private:
  285. // cached pointers to autocreated zones
  286. CDNSZoneNode* m_p0ZoneNode;
  287. CDNSZoneNode* m_p127ZoneNode;
  288. CDNSZoneNode* m_p255ZoneNode;
  289. friend class CDNSServerNode;
  290. };
  291. /////////////////////////////////////////////////////////////////////////
  292. // CDNSServerTestOptions
  293. class CDNSServerTestOptions
  294. {
  295. public:
  296. CDNSServerTestOptions();
  297. HRESULT Save(IStream* pStm);
  298. HRESULT Load(IStream* pStm);
  299. const CDNSServerTestOptions& operator=(const CDNSServerTestOptions& x);
  300. BOOL operator==(const CDNSServerTestOptions& x) const;
  301. BOOL m_bEnabled; // polling enabled
  302. DWORD m_dwInterval; // seconds
  303. // query types
  304. BOOL m_bSimpleQuery;
  305. BOOL m_bRecursiveQuery;
  306. };
  307. ////////////////////////////////////////////////////////////////////////
  308. // CDNSServerTestQueryResult
  309. class CDNSServerTestQueryResult
  310. {
  311. public:
  312. CDNSServerTestQueryResult()
  313. { memset(this, 0x0, sizeof(CDNSServerTestQueryResult));}
  314. const CDNSServerTestQueryResult& operator=(const CDNSServerTestQueryResult& x)
  315. {
  316. memcpy(this, &x, sizeof(CDNSServerTestQueryResult));
  317. return *this;
  318. }
  319. BOOL operator==(const CDNSServerTestQueryResult& x)
  320. {
  321. ASSERT(m_serverCookie == x.m_serverCookie); // always compare the same server
  322. // we do not compare the time
  323. // we do not compare the force logging flag
  324. // we want just to compare the query flags and the results
  325. return (m_dwQueryFlags == x.m_dwQueryFlags) &&
  326. (m_dwAddressResolutionResult == x.m_dwAddressResolutionResult) &&
  327. (m_dwPlainQueryResult == x.m_dwPlainQueryResult) &&
  328. (m_dwRecursiveQueryResult == x.m_dwRecursiveQueryResult);
  329. }
  330. BOOL Succeded()
  331. {
  332. return (m_dwAddressResolutionResult == 0) &&
  333. (m_dwPlainQueryResult == 0) &&
  334. (m_dwRecursiveQueryResult == 0);
  335. }
  336. static DWORD Pack(BOOL bPlainQuery, BOOL bRecursiveQuery)
  337. {
  338. DWORD dw = 0;
  339. if (bPlainQuery)
  340. dw |= 0x1;
  341. if (bRecursiveQuery)
  342. dw |= 0x2;
  343. return dw;
  344. }
  345. static void Unpack(DWORD dwQueryFlags, BOOL* pbPlainQuery, BOOL* pbRecursiveQuery)
  346. {
  347. *pbPlainQuery = (dwQueryFlags & 0x1);
  348. *pbRecursiveQuery = (dwQueryFlags & 0x2);
  349. }
  350. // Data
  351. MMC_COOKIE m_serverCookie;
  352. BOOL m_bAsyncQuery;
  353. SYSTEMTIME m_queryTime;
  354. DWORD m_dwQueryFlags;
  355. DWORD m_dwAddressResolutionResult;
  356. DWORD m_dwPlainQueryResult;
  357. DWORD m_dwRecursiveQueryResult;
  358. };
  359. ////////////////////////////////////////////////////////////////////////
  360. // CDNSServerTestQueryResultList
  361. class CDNSServerTestQueryResultList : public
  362. CList< CDNSServerTestQueryResult*, CDNSServerTestQueryResult* >
  363. {
  364. public:
  365. typedef enum addAction { none = 0, changed, added, addedAndRemoved};
  366. CDNSServerTestQueryResultList()
  367. {
  368. m_nMaxCount = 50;
  369. ExceptionPropagatingInitializeCriticalSection(&m_cs);
  370. }
  371. ~CDNSServerTestQueryResultList()
  372. {
  373. while (!IsEmpty())
  374. delete RemoveHead();
  375. ::DeleteCriticalSection(&m_cs);
  376. }
  377. public:
  378. void Lock() { ::EnterCriticalSection(&m_cs); }
  379. void Unlock() { ::LeaveCriticalSection(&m_cs); }
  380. addAction AddTestQueryResult(CDNSServerTestQueryResult* pTestResult)
  381. {
  382. addAction action = none;
  383. Lock();
  384. // determine if we have to add
  385. INT_PTR nCount = GetCount();
  386. CDNSServerTestQueryResult* pLastQueryResult = NULL;
  387. if (nCount > 0)
  388. pLastQueryResult = GetHead();
  389. if ((pTestResult->m_bAsyncQuery) ||
  390. (pLastQueryResult == NULL) ||
  391. !(*pLastQueryResult == *pTestResult))
  392. {
  393. // make sure we do not have too many items
  394. BOOL bRemoveLast = nCount > m_nMaxCount;
  395. if (bRemoveLast)
  396. {
  397. delete RemoveTail();
  398. }
  399. // add the item
  400. AddHead(pTestResult);
  401. action = bRemoveLast ? addedAndRemoved : added;
  402. }
  403. else
  404. {
  405. // just just update the time stamp in the last message we have
  406. ASSERT(pLastQueryResult != NULL);
  407. memcpy(&(pLastQueryResult->m_queryTime), &(pTestResult->m_queryTime),
  408. sizeof(SYSTEMTIME));
  409. action = changed;
  410. delete pTestResult; // not added
  411. }
  412. Unlock();
  413. return action;
  414. }
  415. BOOL LastQuerySuceeded()
  416. {
  417. BOOL bRes = TRUE;
  418. Lock();
  419. if (GetCount() > 0)
  420. bRes = GetHead()->Succeded();
  421. Unlock();
  422. return bRes;
  423. }
  424. int GetMaxCount()
  425. {
  426. return m_nMaxCount;
  427. }
  428. private:
  429. CRITICAL_SECTION m_cs;
  430. int m_nMaxCount;
  431. };
  432. /////////////////////////////////////////////////////////////////////////
  433. // CDNSServerNode
  434. class CDNSServerQueryObj : public CDNSQueryObj
  435. {
  436. public:
  437. CDNSServerQueryObj(BOOL bAdvancedView, DWORD dwServerVersion)
  438. : CDNSQueryObj(bAdvancedView, dwServerVersion){}
  439. virtual BOOL Enumerate();
  440. private:
  441. };
  442. class CDNSServerNode : public CDNSMTContainerNode
  443. {
  444. public:
  445. CDNSServerNode(LPCTSTR lpszName, BOOL bIsLocalServer = FALSE);
  446. virtual ~CDNSServerNode();
  447. virtual void SetDisplayName(LPCWSTR lpszDisplayName);
  448. void SetLocalServer(BOOL bLocalServer) { m_bLocalServer = bLocalServer; }
  449. BOOL IsLocalServer() { return m_bLocalServer; }
  450. // node info
  451. DECLARE_NODE_GUID()
  452. virtual HRESULT GetDataHere(CLIPFORMAT cf, LPSTGMEDIUM lpMedium,
  453. CDataObject* pDataObject);
  454. virtual HRESULT GetData(CLIPFORMAT cf, LPSTGMEDIUM lpMedium,
  455. CDataObject* pDataObject);
  456. HRESULT RetrieveEventViewerLogs(LPSTGMEDIUM lpMedium, CDataObject* pDataObject);
  457. virtual CColumnSet* GetColumnSet()
  458. {
  459. if (m_pColumnSet == NULL)
  460. {
  461. CDNSRootData* pRoot = (CDNSRootData*)GetRootContainer();
  462. m_pColumnSet = ((CDNSComponentDataObjectBase*)pRoot->GetComponentDataObject())->GetColumnSet(L"---Server Column Set---");
  463. }
  464. return m_pColumnSet;
  465. }
  466. virtual HRESULT OnCommand(long nCommandID,
  467. DATA_OBJECT_TYPES type,
  468. CComponentDataObject* pComponentData,
  469. CNodeList* pNodeList);
  470. virtual void OnDelete(CComponentDataObject* pComponentData,
  471. CNodeList* pNodeList);
  472. virtual BOOL OnRefresh(CComponentDataObject* pComponentData,
  473. CNodeList* pNodeList);
  474. virtual LPCWSTR GetString(int nCol)
  475. {
  476. return (nCol == 0) ? GetDisplayName() : g_lpszNullString;
  477. }
  478. virtual int GetImageIndex(BOOL bOpenImage);
  479. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  480. BOOL* pbHideVerb,
  481. CNodeList* pNodeList);
  482. virtual HRESULT CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  483. LONG_PTR handle,
  484. CNodeList* pNodeList);
  485. virtual HRESULT CreatePropertyPagesHelper(LPPROPERTYSHEETCALLBACK lpProvider,
  486. LONG_PTR handle,
  487. long nStartProppage);
  488. virtual void DecrementSheetLockCount();
  489. virtual BOOL CanExpandSync() { return TRUE; }
  490. protected:
  491. virtual LPCONTEXTMENUITEM2 OnGetContextMenuItemTable()
  492. { return CDNSServerMenuHolder::GetContextMenuItem(); }
  493. virtual BOOL OnAddMenuItem(LPCONTEXTMENUITEM2 pContextMenuItem2,
  494. long *pInsertionAllowed);
  495. virtual BOOL OnSetDeleteVerbState(DATA_OBJECT_TYPES type,
  496. BOOL* pbHide,
  497. CNodeList* pNodeList);
  498. virtual BOOL OnSetRefreshVerbState(DATA_OBJECT_TYPES type,
  499. BOOL* pbHide,
  500. CNodeList* pNodeList);
  501. virtual HRESULT OnSetToolbarVerbState(IToolbar* pToolbar,
  502. CNodeList* pNodeList);
  503. virtual HRESULT GetResultViewType(CComponentDataObject* pComponentData,
  504. LPOLESTR *ppViewType,
  505. long *pViewOptions);
  506. virtual HRESULT OnShow(LPCONSOLE lpConsole);
  507. virtual CQueryObj* OnCreateQuery();
  508. virtual void OnHaveData(CObjBase* pObj, CComponentDataObject* pComponentDataObject);
  509. #ifdef USE_NDNC
  510. BOOL ContainsDefaultNDNCs();
  511. #endif
  512. virtual void SetRecordAging();
  513. virtual void ScavengeRecords();
  514. private:
  515. // folders mainipulation
  516. //CCathegoryFolderNode* GetCathegoryFolder(CCathegoryFolderQueryObj::queryType type);
  517. CDNSAuthoritatedZonesNode* GetAuthoritatedZoneFolder(BOOL bFwd);
  518. // command handlers
  519. HRESULT OnNewZone(CComponentDataObject* pComponentData, CNodeList* pNodeList);
  520. void OnUpdateDataFiles(CComponentDataObject* pComponentData);
  521. void OnClearCache(CComponentDataObject* pComponentData);
  522. void OnConfigureServer(CComponentDataObject* pComponentData);
  523. void OnLaunchNSLookup();
  524. #ifdef USE_NDNC
  525. void OnCreateNDNC();
  526. #endif
  527. public:
  528. void ChangeViewOption(BOOL bAdvanced, CComponentDataObject* pComponentData);
  529. // serialization from/to stream
  530. static HRESULT CreateFromStream(IStream* pStm, CDNSServerNode** ppServerNode);
  531. HRESULT SaveToStream(IStream* pStm);
  532. // DNS specific helpers
  533. #ifdef USE_NDNC
  534. DNS_STATUS CreatePrimaryZone(LPCTSTR lpszName,
  535. LPCTSTR lpszFileName,
  536. BOOL bLoadExisting,
  537. BOOL bFwd,
  538. BOOL bDSIntegrated,
  539. UINT nDynamicUpdate,
  540. CComponentDataObject* pComponentData,
  541. ReplicationType replType,
  542. PCWSTR pszPartitionName);
  543. DNS_STATUS CreateStubZone(LPCTSTR lpszName,
  544. LPCTSTR lpszFileName,
  545. BOOL bLoadExisting,
  546. BOOL bDSIntegrated,
  547. BOOL bFwd,
  548. DWORD* ipMastersArray,
  549. int nIPMastersCount,
  550. BOOL bLocalListOfMasters,
  551. CComponentDataObject* pComponentData,
  552. ReplicationType replType,
  553. PCWSTR pszPartitionName);
  554. #else
  555. DNS_STATUS CreatePrimaryZone(LPCTSTR lpszName, LPCTSTR lpszFileName, BOOL bLoadExisting,
  556. BOOL bFwd, BOOL bDSIntegrated, UINT nDynamicUpdate,
  557. CComponentDataObject* pComponentData);
  558. DNS_STATUS CreateStubZone(LPCTSTR lpszName, LPCTSTR lpszFileName,
  559. BOOL bLoadExisting, BOOL bDSIntegrated, BOOL bFwd,
  560. DWORD* ipMastersArray, int nIPMastersCount,
  561. BOOL bLocalListOfMasters,
  562. CComponentDataObject* pComponentData);
  563. #endif // USE_NDNC
  564. DNS_STATUS CreateSecondaryZone(LPCTSTR lpszName, LPCTSTR lpszFileName,
  565. BOOL bLoadExisting, BOOL bFwd,
  566. DWORD* ipMastersArray, int nIPMastersCount,
  567. CComponentDataObject* pComponentData);
  568. DNS_STATUS CreateForwarderZone(LPCTSTR lpszName,
  569. DWORD* ipMastersArray,
  570. int nIPMastersCount,
  571. DWORD dwTimeout,
  572. DWORD fSlave,
  573. CComponentDataObject* pComponentData);
  574. DNS_STATUS EnumZoneInfo(CZoneInfoHolder* pZoneInfoHolder);
  575. static DNS_STATUS EnumZoneInfo(LPCTSTR lpszServerName, CZoneInfoHolder* pZoneInfoHolder);
  576. DNS_STATUS ClearCache();
  577. // name used for RPC calls
  578. LPCWSTR GetRPCName();
  579. // server info access functions
  580. BOOL HasServerInfo() { ASSERT(m_pServInfoEx != NULL); return m_pServInfoEx->HasData();}
  581. void AttachServerInfo(CDNSServerInfoEx* pNewInfo);
  582. BOOL CanUseADS();
  583. DWORD GetVersion();
  584. BYTE GetMajorVersion(){ return DNS_SRV_MAJOR_VERSION(GetVersion());}
  585. BYTE GetMinorVersion(){ return DNS_SRV_MINOR_VERSION(GetVersion());}
  586. WORD GetBuildNumber() { return DNS_SRV_BUILD_NUMBER(GetVersion());}
  587. DWORD GetForestVersion();
  588. DWORD GetDomainVersion();
  589. void CreateDsServerLdapPath(CString& sz);
  590. void CreateDsZoneLdapPath(CDNSZoneNode* pZoneNode, CString& sz);
  591. void CreateDsZoneName(CDNSZoneNode* pZoneNode, CString& sz);
  592. void CreateDsNodeLdapPath(CDNSZoneNode* pZoneNode, CDNSDomainNode* pDomainNode, CString& sz);
  593. void CreateLdapPathFromX500Name(LPCWSTR lpszX500Name, CString& szLdapPath);
  594. //
  595. // Server property accessors
  596. //
  597. DWORD GetNameCheckFlag();
  598. DNS_STATUS ResetNameCheckFlag(DWORD dwNameCheckFlag);
  599. DWORD GetLogLevelFlag();
  600. DNS_STATUS ResetLogLevelFlag(DWORD dwLogLevel);
  601. DWORD GetEventLogLevelFlag();
  602. DNS_STATUS ResetEventLogLevelFlag(DWORD dwEventLogLevel);
  603. PIP_ARRAY GetDebugLogFilterList();
  604. DNS_STATUS ResetDebugLogFilterList(PIP_ARRAY pIPArray);
  605. PCWSTR GetDebugLogFileName();
  606. DNS_STATUS ResetDebugLogFileName(PCWSTR pszLogFileName);
  607. DWORD GetDebugLogFileMaxSize();
  608. DNS_STATUS ResetDebugLogFileMaxSize(DWORD dwMaxSize);
  609. BOOL DoesRecursion();
  610. void GetAdvancedOptions(BOOL* bOptionsArray);
  611. DNS_STATUS ResetAdvancedOptions(BOOL* bOptionsArray, DNS_STATUS* dwRegKeyOptionsErrorArr);
  612. UCHAR GetBootMethod();
  613. DNS_STATUS ResetBootMethod(UCHAR fBootMethod);
  614. BOOL IsServerConfigured();
  615. DNS_STATUS SetServerConfigured();
  616. BOOL GetScavengingState();
  617. DWORD GetScavengingInterval();
  618. DNS_STATUS ResetScavengingInterval(DWORD dwScavengingInterval);
  619. DWORD GetDefaultRefreshInterval();
  620. DNS_STATUS ResetDefaultRefreshInterval(DWORD dwRefreshInterval);
  621. DWORD GetDefaultNoRefreshInterval();
  622. DNS_STATUS ResetDefaultNoRefreshInterval(DWORD dwNoRefreshInterval);
  623. DWORD GetDefaultScavengingState();
  624. DNS_STATUS ResetDefaultScavengingState(DWORD bScavengingState);
  625. #ifdef USE_NDNC
  626. PCSTR GetDomainName();
  627. PCSTR GetForestName();
  628. #endif
  629. DNS_STATUS ResetListenAddresses(DWORD cAddrCount, PIP_ADDRESS pipAddrs);
  630. void GetListenAddressesInfo(DWORD* pcAddrCount, PIP_ADDRESS* ppipAddrs);
  631. void GetServerAddressesInfo(DWORD* pcAddrCount, PIP_ADDRESS* ppipAddrs);
  632. DNS_STATUS ResetForwarders(DWORD cForwardersCount, PIP_ADDRESS pipForwarders, DWORD dwForwardTimeout, DWORD fSlave);
  633. void GetForwardersInfo(DWORD* pcForwardersCount, PIP_ADDRESS* ppipForwarders, DWORD* pdwForwardTimeout, DWORD* pfSlave);
  634. // Root Hints management API's
  635. BOOL HasRootHints() { return m_pRootHintsNode != NULL;}
  636. CDNSRootHintsNode* GetRootHints();
  637. void AttachRootHints(CDNSRootHintsNode* pNewRootHints);
  638. // testing options
  639. void GetTestOptions(CDNSServerTestOptions* pOptions);
  640. void ResetTestOptions(CDNSServerTestOptions* pOptions);
  641. BOOL IsTestEnabled() { return m_testOptions.m_bEnabled;}
  642. DWORD GetTestInterval() { return m_testOptions.m_dwInterval;}
  643. BOOL IsTestSimpleQueryEnabled() { return m_testOptions.m_bSimpleQuery;}
  644. BOOL IsRecursiveQueryEnabled() { return m_testOptions.m_bRecursiveQuery;}
  645. // test result manipulation
  646. void AddTestQueryResult(CDNSServerTestQueryResult* pTestResult,
  647. CComponentDataObject* pComponentData);
  648. void SetProppageStart(int nStartPage) { m_nStartProppage = nStartPage; }
  649. CDNSDomainForwardersNode* GetDomainForwardersNode() { return m_pDomainForwardersFolderNode; }
  650. private:
  651. DNS_STATUS WriteDirtyZones();
  652. CDNSZoneNode* GetNewZoneNode();
  653. // server info manipulation
  654. CDNSServerInfoEx* m_pServInfoEx;
  655. void FreeServInfo(); // free memory
  656. DNS_STATUS GetServInfo(); // read info from server
  657. // root hints info
  658. CDNSRootHintsNode* m_pRootHintsNode;
  659. void FreeRootHints();
  660. // server test query info
  661. CDNSServerTestOptions m_testOptions;
  662. DWORD m_dwTestTime;
  663. CDNSServerTestQueryResultList m_testResultList;
  664. BOOL m_bTestQueryPending;
  665. BOOL m_bShowMessages;
  666. BOOL m_bPrevQuerySuccess;
  667. int m_nStartProppage;
  668. BOOL m_bLocalServer;
  669. // cached pointer to cache folder
  670. CDNSCacheNode* m_pCacheFolderNode;
  671. CDNSForwardZonesNode* m_pFwdZonesFolderNode;
  672. CDNSReverseZonesNode* m_pRevZonesFolderNode;
  673. CDNSDomainForwardersNode* m_pDomainForwardersFolderNode;
  674. friend class CDNSRootData;
  675. friend class CDNSServer_TestPropertyPage;
  676. DECLARE_TOOLBAR_MAP()
  677. };
  678. /////////////////////////////////////////////////////////////////////////
  679. // CDNSServerOptionNode
  680. //
  681. // represents the root hints in the UI as leaf node of the server node
  682. // It serves no other function but to give access to the Root Hints page
  683. // of the server properties
  684. class CDNSServerOptionNode : public CLeafNode
  685. {
  686. public:
  687. CDNSServerOptionNode(UINT nDisplayNameID, UINT startPageCode);
  688. virtual void OnDelete(CComponentDataObject*, CNodeList*) { ASSERT(false); } // no delete allowed
  689. virtual LPCWSTR GetString(int nCol);
  690. virtual int GetImageIndex(BOOL bOpenImage);
  691. virtual HRESULT OnSetToolbarVerbState(IToolbar* pToolbar, CNodeList*);
  692. virtual BOOL HasPropertyPages(DATA_OBJECT_TYPES type,
  693. BOOL* pbHideVerb,
  694. CNodeList* pNodeList);
  695. virtual HRESULT CreatePropertyPages(LPPROPERTYSHEETCALLBACK lpProvider,
  696. LONG_PTR handle,
  697. CNodeList* pNodeList);
  698. virtual BOOL DelegatesPPToContainer() { return TRUE; }
  699. virtual void ShowPageForNode(CComponentDataObject* pComponentDataObject);
  700. private:
  701. UINT m_nStartPageCode;
  702. };
  703. #endif // _SERVER_H