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.

671 lines
13 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. w3scfg.h
  5. Abstract:
  6. WWW Configuration Module
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include <lmcons.h>
  17. #include <lmapibuf.h>
  18. #include <svcloc.h>
  19. //
  20. // Required by VC5
  21. //
  22. #ifndef MIDL_INTERFACE
  23. #define MIDL_INTERFACE(x) struct
  24. #endif // MIDL_INTERFACE
  25. #ifndef __RPCNDR_H_VERSION__
  26. #define __RPCNDR_H_VERSION__ 440
  27. #endif // __RPCNDR_H_VERSION__
  28. #include "iwamreg.h"
  29. #include <w3svc.h>
  30. //
  31. // Include Files
  32. //
  33. #include "resource.h"
  34. #include "mmc.h"
  35. #include "svrinfo.h"
  36. #include "comprop.h"
  37. extern const LPCTSTR g_cszSvc;
  38. extern const LPCTSTR g_cszFilters;
  39. extern HINSTANCE hInstance;
  40. //
  41. // Short descriptive name of the service. This
  42. // is what will show up as the name of the service
  43. // in the internet manager tool.
  44. //
  45. // Issue: I'm assuming here that this name does NOT
  46. // require localisation.
  47. //
  48. #define SERVICE_SHORT_NAME _T("Web")
  49. class CConfigDll : public CWinApp
  50. /*++
  51. Class Description:
  52. Base class for the configuration DLL
  53. --*/
  54. {
  55. public:
  56. virtual BOOL InitInstance();
  57. virtual int ExitInstance();
  58. CConfigDll(
  59. IN LPCTSTR pszAppName = NULL
  60. );
  61. protected:
  62. //{{AFX_MSG(CConfigDll)
  63. //}}AFX_MSG
  64. DECLARE_MESSAGE_MAP()
  65. private:
  66. CString m_strHelpPath;
  67. LPCTSTR m_lpOldHelpPath;
  68. };
  69. //
  70. // Helper function to determine if SSL is installed
  71. // and enabled on the given server
  72. //
  73. DWORD
  74. IsSSLEnabledOnServer(
  75. IN LPCTSTR lpszServer,
  76. OUT BOOL & fInstalled,
  77. OUT BOOL & fEnabled
  78. );
  79. //
  80. // Helper function to see if a certificate is installed
  81. //
  82. BOOL
  83. IsCertInstalledOnServer(
  84. IN LPCTSTR lpszServerName,
  85. IN DWORD dwInstance
  86. );
  87. //
  88. // Run key manager app
  89. //
  90. void RunKeyManager(
  91. IN LPCTSTR lpszServer = NULL
  92. );
  93. inline BOOL LoggingEnabled(
  94. IN DWORD dwLogType
  95. )
  96. {
  97. return (dwLogType == MD_LOG_TYPE_ENABLED);
  98. }
  99. inline void EnableLogging(
  100. OUT DWORD & dwLogType,
  101. IN BOOL fEnabled = TRUE
  102. )
  103. {
  104. dwLogType = fEnabled ? MD_LOG_TYPE_ENABLED : MD_LOG_TYPE_DISABLED;
  105. }
  106. //
  107. // Bandwidth definitions
  108. //
  109. #define INFINITE_BANDWIDTH (0xffffffff)
  110. #define INFINITE_CPU_RAW (0xffffffff)
  111. #define KILOBYTE (1024L)
  112. #define MEGABYTE (1024L * KILOBYTE)
  113. #define DEF_BANDWIDTH (1 * MEGABYTE)
  114. #define CPU_THROTTLING_FACTOR (1000)
  115. #define DEFAULT_CPU_PERCENTAGE (10L)
  116. //
  117. // Some sanity values on max connections
  118. //
  119. #define INITIAL_MAX_CONNECTIONS ( 1000L)
  120. #define UNLIMITED_CONNECTIONS (2000000000L)
  121. #define MAX_MAX_CONNECTIONS (UNLIMITED_CONNECTIONS - 1L)
  122. #define MAX_TIMEOUT (0x7FFFFFFF)
  123. class CW3InstanceProps : public CInstanceProps
  124. /*++
  125. Class Description:
  126. WWW Instance properties class
  127. Public Interface:
  128. CW3InstanceProps : Constructor
  129. --*/
  130. {
  131. public:
  132. CW3InstanceProps(
  133. IN LPCTSTR lpszServerName,
  134. IN DWORD dwInstance = MASTER_INSTANCE
  135. );
  136. public:
  137. //
  138. // Write Data if dirty
  139. //
  140. virtual HRESULT WriteDirtyProps();
  141. protected:
  142. //
  143. // Break out GetAllData() data to data fields
  144. //
  145. virtual void ParseFields();
  146. public:
  147. //
  148. // Service Page
  149. //
  150. MP_DWORD m_dwLogType;
  151. MP_CILong m_nMaxConnections;
  152. MP_CILong m_nConnectionTimeOut;
  153. MP_CStringListEx m_strlSecureBindings;
  154. //
  155. // Performance Page
  156. //
  157. MP_int m_nServerSize;
  158. MP_BOOL m_fUseKeepAlives;
  159. MP_BOOL m_fEnableCPUAccounting;
  160. MP_DWORD m_dwCPULimitLogEventRaw;
  161. MP_DWORD m_dwCPULimitPriorityRaw;
  162. MP_DWORD m_dwCPULimitPauseRaw;
  163. MP_DWORD m_dwCPULimitProcStopRaw;
  164. MP_CILong m_nMaxNetworkUse;
  165. //
  166. // Operators Page
  167. //
  168. MP_CBlob m_acl;
  169. //
  170. // Root dir page
  171. //
  172. //MP_BOOL m_fFrontPage;
  173. //
  174. // Default Site page
  175. //
  176. MP_DWORD m_dwDownlevelInstance;
  177. //
  178. // Certificate and CTL information
  179. //
  180. MP_CBlob m_CertHash;
  181. MP_CString m_strCertStoreName;
  182. MP_CString m_strCTLIdentifier;
  183. MP_CString m_strCTLStoreName;
  184. };
  185. class CW3DirProps : public CChildNodeProps
  186. /*++
  187. Class Description:
  188. WWW Directory Properties
  189. Public Interface:
  190. CW3DirProps : Constructor
  191. --*/
  192. {
  193. public:
  194. //
  195. // Constructor
  196. //
  197. CW3DirProps(
  198. IN LPCTSTR lpszServerName,
  199. IN DWORD dwInstance = MASTER_INSTANCE,
  200. IN LPCTSTR lpszParent = NULL,
  201. IN LPCTSTR lpszAlias = NULL
  202. );
  203. public:
  204. //
  205. // Write Data if dirty
  206. //
  207. virtual HRESULT WriteDirtyProps();
  208. protected:
  209. //
  210. // Break out GetAllData() data to data fields
  211. //
  212. virtual void ParseFields();
  213. public:
  214. //
  215. // Directory properties page
  216. //
  217. MP_CString m_strUserName;
  218. MP_CString m_strPassword;
  219. MP_CString m_strDefaultDocument;
  220. MP_CString m_strFooter;
  221. MP_CMaskedDWORD m_dwDirBrowsing;
  222. MP_BOOL m_fDontLog;
  223. MP_BOOL m_fEnableFooter;
  224. MP_BOOL m_fIndexed;
  225. //
  226. // HTTP Page
  227. //
  228. MP_CString m_strExpiration;
  229. MP_CStringListEx m_strlCustomHeaders;
  230. //
  231. // Custom Errors
  232. //
  233. MP_CStringListEx m_strlCustomErrors;
  234. //
  235. // Security page
  236. //
  237. MP_DWORD m_dwAuthFlags;
  238. MP_DWORD m_dwSSLAccessPermissions;
  239. MP_CString m_strBasicDomain;
  240. MP_CString m_strAnonUserName;
  241. MP_CString m_strAnonPassword;
  242. MP_BOOL m_fPasswordSync;
  243. MP_BOOL m_fU2Installed;
  244. MP_BOOL m_fUseNTMapper;
  245. MP_CBlob m_ipl;
  246. };
  247. class CIISFilter : public CObjectPlus
  248. /*++
  249. Class Description:
  250. A single filter description
  251. Public Interface:
  252. CIISFilter : Constructors
  253. IsInitialized : Check to see if the name is set.
  254. Write : Write to the metabase.
  255. QueryResult : Query result from metabase read
  256. QueryError : Returns error as stored in metabase
  257. QueryName : Returns filter name
  258. IsLoaded : TRUE if filter is loaded
  259. IsUnloaded : TRUE if filter is unloaded
  260. IsEnabled : TRUE if filter is enabled
  261. Enable : Enable filter
  262. IsDirty : TRUE if filter values have changed
  263. IsFlaggedForDeletion : TRUE if filter should be deleted
  264. --*/
  265. {
  266. //
  267. // Constructors/Destructors
  268. //
  269. public:
  270. //
  271. // Null Constructor
  272. //
  273. CIISFilter();
  274. //
  275. // Read filter values using provided key
  276. //
  277. CIISFilter(
  278. IN CMetaKey * pKey,
  279. IN LPCTSTR lpszName
  280. );
  281. //
  282. // Copy constructor
  283. //
  284. CIISFilter(
  285. IN const CIISFilter & flt
  286. );
  287. public:
  288. //
  289. // Sorting helper
  290. //
  291. int OrderByPriority(
  292. IN const CObjectPlus * pobAccess
  293. ) const;
  294. BOOL IsInitialized() const { return !m_strName.IsEmpty(); }
  295. //
  296. // Write using provided key
  297. //
  298. HRESULT Write(CMetaKey * pKey);
  299. public:
  300. BOOL IsLoaded() const;
  301. BOOL IsUnloaded() const;
  302. BOOL IsEnabled() const { return m_fEnabled; }
  303. void Enable(BOOL fEnabled = TRUE);
  304. DWORD QueryError() const { return m_dwWin32Error; }
  305. HRESULT QueryResult() const { return m_hrResult; }
  306. //
  307. // Check to see if this item is marked as dirty
  308. //
  309. BOOL IsDirty() const { return m_fDirty; }
  310. //
  311. // Check to see if this item is flagged for deletion
  312. //
  313. BOOL IsFlaggedForDeletion() const { return m_fFlaggedForDeletion; }
  314. //
  315. // Set/reset the dirty flag
  316. //
  317. void Dirty(BOOL fDirty = TRUE);
  318. //
  319. // Flag this item for deletion
  320. //
  321. void FlagForDeletion();
  322. //
  323. // Get the name of this filter
  324. //
  325. LPCTSTR QueryName() const { return m_strName; }
  326. //
  327. // Meta Values
  328. //
  329. public:
  330. int m_nPriority;
  331. int m_nOrder;
  332. BOOL m_fEnabled;
  333. DWORD m_dwState;
  334. DWORD m_dwWin32Error;
  335. HRESULT m_hrResult;
  336. CString m_strName;
  337. CString m_strExecutable;
  338. //
  339. // State Values
  340. //
  341. private:
  342. BOOL m_fDirty;
  343. BOOL m_fFlaggedForDeletion;
  344. DWORD m_dwFlags;
  345. };
  346. class CIISFilterList : public CMetaKey
  347. /*++
  348. Class Description:
  349. A list of filters
  350. Public Interface:
  351. CIISFilterList : Constructor
  352. BeginSearch : Reset the iterator
  353. MoreFilters : More items available in the list?
  354. GetNextFilter : Get the next item in the list
  355. --*/
  356. {
  357. public:
  358. CIISFilterList(
  359. IN LPCTSTR lpszServerName,
  360. IN LPCTSTR lpszService,
  361. IN DWORD dwInstance = MASTER_INSTANCE
  362. );
  363. public:
  364. //
  365. // Write out the filter list
  366. //
  367. HRESULT WriteIfDirty();
  368. //
  369. // Acccess Functions
  370. //
  371. public:
  372. DWORD QueryInstance() const { return m_dwInstance; }
  373. BOOL FiltersLoaded() const { return m_fFiltersLoaded; }
  374. //
  375. // Load each filter in turn
  376. //
  377. HRESULT LoadAllFilters();
  378. //
  379. // Filter Access Functions
  380. //
  381. public:
  382. //
  383. // Reset the filter list iterator
  384. //
  385. void ResetEnumerator();
  386. int GetCount() const { return (int)m_oblFilters.GetCount(); }
  387. //
  388. // More filters available in the list?
  389. //
  390. BOOL MoreFilters() const { return m_pos != NULL; }
  391. //
  392. // Return position of filter by index
  393. //
  394. POSITION GetFilterPositionByIndex(int nSel);
  395. //
  396. // Iterate to the next filter in the list
  397. //
  398. CIISFilter * GetNextFilter();
  399. //
  400. // Remove filter
  401. //
  402. void RemoveFilter(int nItem);
  403. //
  404. // Add new filter
  405. //
  406. void AddFilter(CIISFilter * pFilter);
  407. //
  408. // Exchange two filters in the list
  409. //
  410. BOOL ExchangePositions(
  411. IN int nSel1,
  412. IN int nSel2,
  413. OUT CIISFilter *& p1,
  414. OUT CIISFilter *& p2
  415. );
  416. //
  417. // See if at least one filter is dirty
  418. //
  419. BOOL HasDirtyFilter() const;
  420. //
  421. // Virtual Interface:
  422. //
  423. public:
  424. virtual BOOL Succeeded() const { return SUCCEEDED(m_hrResult); }
  425. virtual HRESULT QueryResult() const { return m_hrResult; }
  426. protected:
  427. //
  428. // Build up order string from component list
  429. //
  430. LPCTSTR BuildFilterOrderString(
  431. OUT CString & strFilterOrder
  432. );
  433. protected:
  434. //
  435. // Seperator string (one character)
  436. //
  437. static const LPCTSTR s_lpszSep;
  438. private:
  439. BOOL m_fFiltersLoaded;
  440. DWORD m_dwInstance;
  441. POSITION m_pos;
  442. HRESULT m_hrResult;
  443. CString m_strFilterOrder;
  444. CObListPlus m_oblFilters;
  445. };
  446. //
  447. // W3 Property sheet
  448. //
  449. class CW3Sheet : public CInetPropertySheet
  450. {
  451. public:
  452. CW3Sheet(
  453. LPCTSTR pszCaption,
  454. DWORD dwAttributes,
  455. LPCTSTR lpszServer,
  456. DWORD dwInstance,
  457. LPCTSTR lpszParent,
  458. LPCTSTR lpszAlias,
  459. CWnd * pParentWnd = NULL,
  460. LPARAM lParam = 0L,
  461. LONG_PTR handle = 0L,
  462. UINT iSelectPage = 0
  463. );
  464. ~CW3Sheet();
  465. public:
  466. HRESULT QueryInstanceResult() const;
  467. HRESULT QueryDirectoryResult() const;
  468. CW3InstanceProps & GetInstanceProperties() { return *m_ppropInst; }
  469. CW3DirProps & GetDirectoryProperties() { return *m_ppropDir; }
  470. virtual HRESULT LoadConfigurationParameters();
  471. virtual void FreeConfigurationParameters();
  472. protected:
  473. virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT);
  474. // Generated message map functions
  475. //{{AFX_MSG(CW3Sheet)
  476. //}}AFX_MSG
  477. DECLARE_MESSAGE_MAP()
  478. private:
  479. DWORD m_fNew;
  480. DWORD m_dwAttributes;
  481. CW3InstanceProps * m_ppropInst;
  482. CW3DirProps * m_ppropDir;
  483. };
  484. //
  485. // Inline Expansion
  486. //
  487. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  488. inline BOOL CIISFilter::IsLoaded() const
  489. {
  490. return m_dwState == MD_FILTER_STATE_LOADED;
  491. }
  492. inline BOOL CIISFilter::IsUnloaded() const
  493. {
  494. return m_dwState == MD_FILTER_STATE_UNLOADED;
  495. }
  496. inline void CIISFilter::Enable(
  497. IN BOOL fEnabled
  498. )
  499. {
  500. m_fEnabled = fEnabled;
  501. }
  502. inline void CIISFilter::Dirty(
  503. IN BOOL fDirty
  504. )
  505. {
  506. m_fDirty = fDirty;
  507. }
  508. inline void CIISFilter::FlagForDeletion()
  509. {
  510. m_fFlaggedForDeletion = TRUE;
  511. }
  512. inline void CIISFilterList::ResetEnumerator()
  513. {
  514. m_pos = m_oblFilters.GetHeadPosition();
  515. }
  516. inline CIISFilter * CIISFilterList::GetNextFilter()
  517. {
  518. return (CIISFilter *)m_oblFilters.GetNext(m_pos);
  519. }
  520. inline void CIISFilterList::RemoveFilter(int nItem)
  521. {
  522. m_oblFilters.RemoveIndex(nItem);
  523. }
  524. inline void CIISFilterList::AddFilter(CIISFilter * pFilter)
  525. {
  526. m_oblFilters.AddTail(pFilter);
  527. }
  528. inline HRESULT CW3Sheet::QueryInstanceResult() const
  529. {
  530. return m_ppropInst ? m_ppropInst->QueryResult() : S_OK;
  531. }
  532. inline HRESULT CW3Sheet::QueryDirectoryResult() const
  533. {
  534. return m_ppropDir ? m_ppropDir->QueryResult() : S_OK;
  535. }
  536. #define W3SCFG_DLL_NAME _T("W3SCFG.DLL")