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.

485 lines
9.0 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. pwiz.h
  5. Abstract:
  6. IIS Security Wizard
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager
  12. Revision History:
  13. --*/
  14. #ifndef __IISPWIZ_H__
  15. #define __IISPWIZ_H__
  16. class CBlob;
  17. #define NUM_ACCESS_RECORDS (2)
  18. typedef CList<DWORD, DWORD> CDWORDList;
  19. //
  20. // Structure to map a flag to a string ID
  21. //
  22. typedef struct tagFLAGTOSTRING
  23. {
  24. DWORD dwFlag;
  25. UINT nID;
  26. BOOL fSet;
  27. } FLAGTOSTRING;
  28. class CIISSecurityTemplate : public CMetaProperties
  29. /*++
  30. Class Description:
  31. Security template info
  32. Public Interface:
  33. CIISSecurityTemplate : Constructor
  34. ApplySettings : Apply template to destination path
  35. ClearSummary : Clear the text summary
  36. GenerateSummary : Generate the text summary
  37. --*/
  38. {
  39. public:
  40. CIISSecurityTemplate(
  41. CMetaKey * pKey,
  42. LPCTSTR lpszMDPath,
  43. BOOL fInherit
  44. );
  45. public:
  46. //
  47. // Apply settings to destination path
  48. //
  49. virtual HRESULT ApplySettings(
  50. BOOL fUseTemplates,
  51. CComAuthInfo * pAuthInfo,
  52. LPCTSTR lpszMDPath
  53. );
  54. //
  55. // Build summary strings from security settings. Clear summary
  56. // before calling GenerateSummary().
  57. //
  58. virtual void GenerateSummary(
  59. BOOL fUseTemplates,
  60. CComAuthInfo * pAuthInfo,
  61. LPCTSTR lpszMDPath
  62. );
  63. void ClearSummary() { m_strlSummary.RemoveAll(); }
  64. POSITION GetHeadPosition() { return m_strlSummary.GetHeadPosition(); }
  65. CString & GetNext(POSITION & pos) { return m_strlSummary.GetNext(pos); }
  66. void AddSummaryString(
  67. LPCTSTR szTextItem,
  68. int cIndentLevel = 0
  69. );
  70. void AddSummaryString(
  71. UINT nID,
  72. int cIndentLevel = 0
  73. );
  74. protected:
  75. //
  76. // Break out GetAllData() data to data fields
  77. //
  78. virtual void ParseFields();
  79. public:
  80. MP_DWORD m_dwAccessPerms;
  81. MP_CBlob m_ipl;
  82. protected:
  83. //
  84. // The derived class is expected to add its managed properties
  85. // to this list in its constructor
  86. //
  87. CDWORDList m_dlProperties;
  88. CStringList m_strlSummary;
  89. };
  90. class CFTPSecurityTemplate : public CIISSecurityTemplate
  91. {
  92. public:
  93. CFTPSecurityTemplate(
  94. CMetaKey * pKey, LPCTSTR lpszMDPath, BOOL fInherit);
  95. public:
  96. virtual HRESULT ApplySettings(
  97. BOOL fUseTemplates,
  98. CComAuthInfo * pAuthInfo,
  99. LPCTSTR lpszMDPath
  100. );
  101. virtual HRESULT LoadData();
  102. virtual void GenerateSummary(
  103. BOOL fUseTemplates,
  104. CComAuthInfo * pAuthInfo,
  105. LPCTSTR lpszMDPath
  106. );
  107. protected:
  108. virtual void ParseFields();
  109. public:
  110. MP_BOOL m_fAllowAnonymous;
  111. MP_BOOL m_fAnonymousOnly;
  112. };
  113. class CWebSecurityTemplate : public CIISSecurityTemplate
  114. {
  115. public:
  116. CWebSecurityTemplate(
  117. CMetaKey * pKey, LPCTSTR lpszMDPath, BOOL fInherit);
  118. public:
  119. virtual HRESULT ApplySettings(
  120. BOOL fUseTemplates,
  121. CComAuthInfo * pAuthInfo,
  122. LPCTSTR lpszMDPath
  123. );
  124. virtual HRESULT LoadData();
  125. virtual void GenerateSummary(
  126. BOOL fUseTemplates,
  127. CComAuthInfo * pAuthInfo,
  128. LPCTSTR lpszMDPath
  129. );
  130. protected:
  131. virtual void ParseFields();
  132. public:
  133. MP_DWORD m_dwAuthentication;
  134. MP_DWORD m_dwDirBrowsing;
  135. };
  136. //
  137. // Launch security wizard
  138. //
  139. HRESULT
  140. RunSecurityWizard(
  141. CComAuthInfo * pAuthInfo,
  142. CMetaInterface * pInterface,
  143. CString& meta_path,
  144. UINT nLeftBmpId,
  145. UINT nHeadBmpId
  146. );
  147. class CIISSecWizSettings : public CObjectPlus
  148. /*++
  149. Class Description:
  150. Security wizard settings -- passed around from page
  151. to page.
  152. Public Interface:
  153. CIISSecWizSettings : Constructor
  154. --*/
  155. {
  156. //
  157. // Constructor/Destructor
  158. //
  159. public:
  160. CIISSecWizSettings(
  161. IN CComAuthInfo * pAuthInfo,
  162. IN LPCTSTR lpszMDPath
  163. );
  164. ~CIISSecWizSettings();
  165. public:
  166. //
  167. // Fetch the metabase properties from the open key
  168. // (could be template or another vroot)
  169. //
  170. HRESULT FetchProperties(
  171. IN CMetaKey & mk,
  172. IN LPCTSTR lpszPath = NULL,
  173. IN BOOL fInherit = FALSE
  174. );
  175. //
  176. // Data Members
  177. //
  178. public:
  179. BOOL m_fSetAcls;
  180. BOOL m_fReplaceAcls;
  181. BOOL m_fRedirected;
  182. BOOL m_fUseTemplate;
  183. DWORD m_dwInstance;
  184. DWORD m_AccessMaskAdmin;
  185. DWORD m_AccessMaskEveryone;
  186. DWORD m_AccessMaskDefault;
  187. HRESULT m_hResult;
  188. CString m_strPath;
  189. CComAuthInfo * m_auth;
  190. CString m_strMDPath;
  191. CIISSecurityTemplate * m_pist;
  192. EXPLICIT_ACCESS m_rgaae[NUM_ACCESS_RECORDS];
  193. };
  194. //
  195. // Permissions Wizard Source Page
  196. //
  197. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  198. class CPWSource : public CIISWizardPage
  199. {
  200. DECLARE_DYNCREATE(CPWSource)
  201. //
  202. // Construction
  203. //
  204. public:
  205. CPWSource(IN CIISSecWizSettings * pSettings = NULL);
  206. ~CPWSource();
  207. //
  208. // Dialog Data
  209. //
  210. protected:
  211. enum { RADIO_INHERITANCE, RADIO_TEMPLATE, };
  212. //{{AFX_DATA(CPWSource)
  213. enum { IDD = IDD_PERMWIZ_SOURCE };
  214. int m_nSource;
  215. //}}AFX_DATA
  216. //
  217. // Overrides
  218. //
  219. protected:
  220. // ClassWizard generate virtual function overrides
  221. //{{AFX_VIRTUAL(CPWSource)
  222. public:
  223. virtual BOOL OnSetActive();
  224. virtual LRESULT OnWizardNext();
  225. protected:
  226. virtual void DoDataExchange(CDataExchange * pDX);
  227. //}}AFX_VIRTUAL
  228. //
  229. // Implementation
  230. //
  231. protected:
  232. // Generated message map functions
  233. //{{AFX_MSG(CPWSource)
  234. //}}AFX_MSG
  235. DECLARE_MESSAGE_MAP()
  236. void SetControlStates();
  237. private:
  238. CIISSecWizSettings * m_pSettings;
  239. };
  240. //
  241. // Permissions Wizard Template Page
  242. //
  243. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  244. class CPWTemplate : public CIISWizardPage
  245. {
  246. DECLARE_DYNCREATE(CPWTemplate)
  247. //
  248. // Construction
  249. //
  250. public:
  251. CPWTemplate(IN CIISSecWizSettings * pSettings = NULL);
  252. ~CPWTemplate();
  253. //
  254. // Dialog Data
  255. //
  256. protected:
  257. //{{AFX_DATA(CPWTemplate)
  258. enum { IDD = IDD_PERMWIZ_TEMPLATE };
  259. CListBox m_list_Templates;
  260. CEdit m_edit_Description;
  261. //}}AFX_DATA
  262. //
  263. // Overrides
  264. //
  265. protected:
  266. // ClassWizard generate virtual function overrides
  267. //{{AFX_VIRTUAL(CPWTemplate)
  268. public:
  269. virtual BOOL OnSetActive();
  270. virtual LRESULT OnWizardNext();
  271. protected:
  272. virtual void DoDataExchange(CDataExchange * pDX);
  273. //}}AFX_VIRTUAL
  274. //
  275. // Implementation
  276. //
  277. protected:
  278. // Generated message map functions
  279. //{{AFX_MSG(CPWTemplate)
  280. virtual BOOL OnInitDialog();
  281. afx_msg void OnSelchangeListTemplates();
  282. //}}AFX_MSG
  283. DECLARE_MESSAGE_MAP()
  284. void SetControlStates();
  285. private:
  286. CIISSecWizSettings * m_pSettings;
  287. };
  288. //
  289. // Permissions Wizard ACL Page
  290. //
  291. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  292. class CPWACL : public CIISWizardPage
  293. {
  294. DECLARE_DYNCREATE(CPWACL)
  295. //
  296. // Construction
  297. //
  298. public:
  299. CPWACL(IN CIISSecWizSettings * pSettings = NULL);
  300. ~CPWACL();
  301. //
  302. // Dialog Data
  303. //
  304. protected:
  305. enum { RADIO_MAXIMUM, RADIO_MINIMUM, RADIO_NONE, };
  306. //{{AFX_DATA(CPWACL)
  307. enum { IDD = IDD_PERMWIZ_ACL };
  308. CStatic m_static_Line4;
  309. CStatic m_static_Line3;
  310. CStatic m_static_Line2;
  311. CStatic m_static_Line1;
  312. int m_nRadioAclType;
  313. //}}AFX_DATA
  314. //
  315. // Overrides
  316. //
  317. protected:
  318. // ClassWizard generate virtual function overrides
  319. //{{AFX_VIRTUAL(CPWACL)
  320. public:
  321. virtual BOOL OnSetActive();
  322. virtual LRESULT OnWizardNext();
  323. protected:
  324. virtual void DoDataExchange(CDataExchange * pDX);
  325. //}}AFX_VIRTUAL
  326. //
  327. // Implementation
  328. //
  329. protected:
  330. // Generated message map functions
  331. //{{AFX_MSG(CPWACL)
  332. //}}AFX_MSG
  333. DECLARE_MESSAGE_MAP()
  334. void SetControlStates();
  335. private:
  336. CIISSecWizSettings * m_pSettings;
  337. };
  338. //
  339. // Permissions Wizard Summary Page
  340. //
  341. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  342. class CPWSummary : public CIISWizardPage
  343. {
  344. DECLARE_DYNCREATE(CPWSummary)
  345. //
  346. // Construction
  347. //
  348. public:
  349. CPWSummary(IN CIISSecWizSettings * pSettings = NULL);
  350. ~CPWSummary();
  351. //
  352. // Dialog Data
  353. //
  354. protected:
  355. //{{AFX_DATA(CPWSummary)
  356. enum { IDD = IDD_PERMWIZ_SUMMARY };
  357. CListBox m_list_Summary;
  358. //}}AFX_DATA
  359. //
  360. // Overrides
  361. //
  362. protected:
  363. // ClassWizard generate virtual function overrides
  364. //{{AFX_VIRTUAL(CPWSummary)
  365. public:
  366. virtual BOOL OnSetActive();
  367. virtual LRESULT OnWizardNext();
  368. protected:
  369. virtual void DoDataExchange(CDataExchange * pDX);
  370. //}}AFX_VIRTUAL
  371. //
  372. // Implementation
  373. //
  374. protected:
  375. // Generated message map functions
  376. //{{AFX_MSG(CPWSummary)
  377. virtual BOOL OnInitDialog();
  378. //}}AFX_MSG
  379. DECLARE_MESSAGE_MAP()
  380. void SetControlStates();
  381. void GenerateAclSummary();
  382. void DisplaySummary();
  383. HRESULT ApplyACLSToFiles();
  384. HRESULT
  385. SetPermToChildren(
  386. IN CString& FileName,
  387. IN SECURITY_INFORMATION si,
  388. IN PACL pDacl,
  389. IN PACL pSacl
  390. );
  391. private:
  392. CIISSecWizSettings * m_pSettings;
  393. };
  394. #endif // __IISPWIZ_H__