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.

602 lines
12 KiB

  1. /*++
  2. Copyright (c) 1994-2001 Microsoft Corporation
  3. Module Name :
  4. machsht.cpp
  5. Abstract:
  6. IIS Machine Property sheet classes
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager (cluster edition)
  12. Revision History:
  13. --*/
  14. #include "stdafx.h"
  15. #include "common.h"
  16. #include "inetprop.h"
  17. #include "InetMgrApp.h"
  18. #include "shts.h"
  19. #include "ftpsht.h"
  20. //
  21. // Help IDs. Home directory gets substituted.
  22. //
  23. #define HIDD_FTP_DIRECTORY_PROPERTIES (IDD_FTP_DIRECTORY_PROPERTIES + 0x20000)
  24. #define HIDD_FTP_HOME_DIRECTORY_PROPERTIES (HIDD_FTP_DIRECTORY_PROPERTIES + 0x20000)
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char BASED_CODE THIS_FILE[] = __FILE__;
  28. #endif
  29. #define new DEBUG_NEW
  30. CFTPInstanceProps::CFTPInstanceProps(
  31. IN CComAuthInfo * pAuthInfo,
  32. IN LPCTSTR lpszMDPath
  33. )
  34. /*++
  35. Routine Description:
  36. Constructor for FTP instance properties
  37. Arguments:
  38. CComAuthInfo * pAuthInfo : COM Authentication info
  39. LPCTSTR lpszMDPath : MD Path
  40. Return Value:
  41. N/A
  42. --*/
  43. : CInstanceProps(pAuthInfo, lpszMDPath, 21U),
  44. m_nMaxConnections((LONG)0L),
  45. m_nConnectionTimeOut((LONG)0L),
  46. m_dwLogType(MD_LOG_TYPE_DISABLED),
  47. /**/
  48. m_strUserName(),
  49. m_strPassword(),
  50. m_fAllowAnonymous(FALSE),
  51. m_fOnlyAnonymous(FALSE),
  52. m_fPasswordSync(TRUE),
  53. m_acl(),
  54. /**/
  55. m_strExitMessage(),
  56. m_strMaxConMsg(),
  57. m_strlWelcome(),
  58. m_strlBanner(),
  59. /**/
  60. m_fDosDirOutput(TRUE),
  61. /**/
  62. m_dwDownlevelInstance(1)
  63. {
  64. //
  65. // Fetch everything
  66. //
  67. m_dwMDUserType = ALL_METADATA;
  68. m_dwMDDataType = ALL_METADATA;
  69. m_UserIsolation = 0;
  70. }
  71. /* virtual */
  72. void
  73. CFTPInstanceProps::ParseFields()
  74. /*++
  75. Routine Description:
  76. Break into fields.
  77. Arguments:
  78. None.
  79. Return Value:
  80. None.
  81. --*/
  82. {
  83. //
  84. // Fetch base properties
  85. //
  86. CInstanceProps::ParseFields();
  87. BEGIN_PARSE_META_RECORDS(m_dwNumEntries, m_pbMDData)
  88. //
  89. // Service Page
  90. //
  91. HANDLE_META_RECORD(MD_MAX_CONNECTIONS, m_nMaxConnections)
  92. HANDLE_META_RECORD(MD_CONNECTION_TIMEOUT, m_nConnectionTimeOut)
  93. HANDLE_META_RECORD(MD_LOG_TYPE, m_dwLogType)
  94. //
  95. // Accounts Page
  96. //
  97. HANDLE_META_RECORD(MD_ANONYMOUS_USER_NAME, m_strUserName)
  98. HANDLE_META_RECORD(MD_ANONYMOUS_PWD, m_strPassword)
  99. HANDLE_META_RECORD(MD_ANONYMOUS_ONLY, m_fOnlyAnonymous)
  100. HANDLE_META_RECORD(MD_ALLOW_ANONYMOUS, m_fAllowAnonymous)
  101. // if (QueryMajorVersion() < 6)
  102. {
  103. HANDLE_META_RECORD(MD_ANONYMOUS_USE_SUBAUTH, m_fPasswordSync)
  104. }
  105. HANDLE_META_RECORD(MD_ADMIN_ACL, m_acl)
  106. //
  107. // Message Page
  108. //
  109. HANDLE_META_RECORD(MD_EXIT_MESSAGE, m_strExitMessage)
  110. HANDLE_META_RECORD(MD_MAX_CLIENTS_MESSAGE, m_strMaxConMsg)
  111. HANDLE_META_RECORD(MD_GREETING_MESSAGE, m_strlWelcome)
  112. HANDLE_META_RECORD(MD_BANNER_MESSAGE, m_strlBanner)
  113. //
  114. // Directory Properties Page
  115. //
  116. HANDLE_META_RECORD(MD_MSDOS_DIR_OUTPUT, m_fDosDirOutput);
  117. //
  118. // Default Site
  119. //
  120. HANDLE_META_RECORD(MD_DOWNLEVEL_ADMIN_INSTANCE, m_dwDownlevelInstance)
  121. HANDLE_META_RECORD(MD_MAX_BANDWIDTH, m_dwMaxBandwidth)
  122. //
  123. HANDLE_META_RECORD(MD_USER_ISOLATION, m_UserIsolation);
  124. END_PARSE_META_RECORDS
  125. }
  126. /* virtual */
  127. HRESULT
  128. CFTPInstanceProps::WriteDirtyProps()
  129. /*++
  130. Routine Description:
  131. Write the dirty properties to the metabase
  132. Arguments:
  133. None
  134. Return Value:
  135. HRESULT
  136. --*/
  137. {
  138. CError err(CInstanceProps::WriteDirtyProps());
  139. if (err.Failed())
  140. {
  141. return err;
  142. }
  143. BEGIN_META_WRITE()
  144. //
  145. // Service Page
  146. //
  147. META_WRITE(MD_MAX_CONNECTIONS, m_nMaxConnections)
  148. META_WRITE(MD_CONNECTION_TIMEOUT, m_nConnectionTimeOut)
  149. META_WRITE(MD_LOG_TYPE, m_dwLogType)
  150. //
  151. // Accounts Page
  152. //
  153. META_WRITE(MD_ANONYMOUS_USER_NAME, m_strUserName)
  154. META_WRITE(MD_ANONYMOUS_PWD, m_strPassword)
  155. META_WRITE(MD_ANONYMOUS_ONLY, m_fOnlyAnonymous)
  156. META_WRITE(MD_ALLOW_ANONYMOUS, m_fAllowAnonymous)
  157. // if (QueryMajorVersion() < 6)
  158. {
  159. META_WRITE(MD_ANONYMOUS_USE_SUBAUTH, m_fPasswordSync)
  160. }
  161. META_WRITE(MD_ADMIN_ACL, m_acl)
  162. //
  163. // Message Page
  164. //
  165. META_WRITE(MD_EXIT_MESSAGE, m_strExitMessage)
  166. META_WRITE(MD_MAX_CLIENTS_MESSAGE, m_strMaxConMsg)
  167. META_WRITE(MD_GREETING_MESSAGE, m_strlWelcome)
  168. META_WRITE(MD_BANNER_MESSAGE, m_strlBanner)
  169. //
  170. // Directory Properties Page
  171. //
  172. META_WRITE(MD_MSDOS_DIR_OUTPUT, m_fDosDirOutput);
  173. //
  174. // Default Site
  175. //
  176. META_WRITE(MD_DOWNLEVEL_ADMIN_INSTANCE, m_dwDownlevelInstance)
  177. META_WRITE(MD_MAX_BANDWIDTH, m_dwMaxBandwidth)
  178. END_META_WRITE(err);
  179. return err;
  180. }
  181. CFTPDirProps::CFTPDirProps(
  182. IN CComAuthInfo * pAuthInfo,
  183. IN LPCTSTR lpszMDPath
  184. )
  185. /*++
  186. Routine Description:
  187. FTP Directory properties object
  188. Arguments:
  189. CComAuthInfo * pAuthInfo : COM Authentication info
  190. LPCTSTR lpszMDPath : MD Path
  191. Return Value:
  192. N/A.
  193. --*/
  194. : CChildNodeProps(
  195. pAuthInfo,
  196. lpszMDPath,
  197. WITH_INHERITANCE,
  198. FALSE // Complete information
  199. ),
  200. /**/
  201. m_fDontLog(FALSE),
  202. m_ipl()
  203. {
  204. //
  205. // Fetch everything
  206. //
  207. m_dwMDUserType = ALL_METADATA;
  208. m_dwMDDataType = ALL_METADATA;
  209. }
  210. /* virtual */
  211. void
  212. CFTPDirProps::ParseFields()
  213. /*++
  214. Routine Description:
  215. Break into fields.
  216. Arguments:
  217. None.
  218. Return Value:
  219. None.
  220. --*/
  221. {
  222. //
  223. // Fetch base properties
  224. //
  225. CChildNodeProps::ParseFields();
  226. BEGIN_PARSE_META_RECORDS(m_dwNumEntries, m_pbMDData)
  227. HANDLE_META_RECORD(MD_VR_USERNAME, m_strUserName)
  228. HANDLE_META_RECORD(MD_VR_PASSWORD, m_strPassword)
  229. HANDLE_META_RECORD(MD_DONT_LOG, m_fDontLog);
  230. HANDLE_META_RECORD(MD_IP_SEC, m_ipl);
  231. END_PARSE_META_RECORDS
  232. }
  233. /* virtual */
  234. HRESULT
  235. CFTPDirProps::WriteDirtyProps()
  236. /*++
  237. Routine Description:
  238. Write the dirty properties to the metabase
  239. Arguments:
  240. None
  241. Return Value:
  242. HRESULT
  243. --*/
  244. {
  245. CError err(CChildNodeProps::WriteDirtyProps());
  246. if (err.Failed())
  247. {
  248. return err;
  249. }
  250. //
  251. // CODEWORK: Consider DDX/DDV like methods which do both
  252. // ParseFields and WriteDirtyProps in a single method. Must
  253. // take care not to write data which should only be read, not
  254. // written
  255. //
  256. BEGIN_META_WRITE()
  257. META_WRITE(MD_VR_USERNAME, m_strUserName)
  258. META_WRITE(MD_VR_PASSWORD, m_strPassword)
  259. META_WRITE(MD_DONT_LOG, m_fDontLog);
  260. META_WRITE(MD_IP_SEC, m_ipl);
  261. END_META_WRITE(err);
  262. return err;
  263. }
  264. //
  265. // FTP Property Sheet Implementation
  266. //
  267. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  268. CFtpSheet::CFtpSheet(
  269. CComAuthInfo * pAuthInfo,
  270. LPCTSTR lpszMetaPath,
  271. CWnd * pParentWnd,
  272. LPARAM lParam,
  273. LPARAM lParamParent,
  274. UINT iSelectPage
  275. )
  276. /*++
  277. Routine Description:
  278. FTP Property sheet constructor
  279. Arguments:
  280. CComAuthInfo * pAuthInfo : Authentication information
  281. LPCTSTR lpszMetPath : Metabase path
  282. CWnd * pParentWnd : Optional parent window
  283. LPARAM lParam : MMC Console parameter
  284. UINT iSelectPage : Initial page to be selected
  285. Return Value:
  286. N/A
  287. --*/
  288. : CInetPropertySheet(
  289. pAuthInfo,
  290. lpszMetaPath,
  291. pParentWnd,
  292. lParam,
  293. lParamParent,
  294. iSelectPage
  295. ),
  296. m_ppropInst(NULL),
  297. m_ppropDir(NULL)
  298. {
  299. }
  300. CFtpSheet::~CFtpSheet()
  301. /*++
  302. Routine Description:
  303. FTP Sheet destructor
  304. Arguments:
  305. N/A
  306. Return Value:
  307. N/A
  308. --*/
  309. {
  310. FreeConfigurationParameters();
  311. }
  312. HRESULT
  313. CFtpSheet::SetSheetType(int fSheetType)
  314. {
  315. m_fSheetType = fSheetType;
  316. return S_OK;
  317. }
  318. void
  319. CFtpSheet::WinHelp(
  320. IN DWORD dwData,
  321. IN UINT nCmd
  322. )
  323. /*++
  324. Routine Description:
  325. FTP Property sheet help handler
  326. Arguments:
  327. DWORD dwData : WinHelp data (dialog ID)
  328. UINT nCmd : WinHelp command
  329. Return Value:
  330. None
  331. Notes:
  332. Replace the dialog ID if this is the directory tab. We have
  333. different help depending on virtual directory, home, file, directory.
  334. --*/
  335. {
  336. ASSERT(m_ppropDir != NULL);
  337. if (dwData == HIDD_FTP_DIRECTORY_PROPERTIES)
  338. {
  339. if (m_fSheetType == SHEET_TYPE_FILE)
  340. {
  341. // do nothing...
  342. }
  343. else if (m_fSheetType == SHEET_TYPE_DIR)
  344. {
  345. // do nothing...
  346. }
  347. else if (m_fSheetType == SHEET_TYPE_VDIR)
  348. {
  349. dwData = HIDD_FTP_DIRECTORY_PROPERTIES;
  350. }
  351. else if (m_fSheetType == SHEET_TYPE_SERVER)
  352. {
  353. dwData = HIDD_FTP_HOME_DIRECTORY_PROPERTIES;
  354. }
  355. else if (m_fSheetType == SHEET_TYPE_SITE)
  356. {
  357. dwData = HIDD_FTP_HOME_DIRECTORY_PROPERTIES;
  358. }
  359. else
  360. {
  361. ASSERT(m_ppropDir != NULL);
  362. if (!::lstrcmpi(m_ppropDir->m_strAlias, g_cszRoot))
  363. {
  364. //
  365. // It's a home virtual directory -- change the ID
  366. //
  367. dwData = HIDD_FTP_HOME_DIRECTORY_PROPERTIES;
  368. }
  369. }
  370. }
  371. WinHelpDebug(dwData);
  372. CInetPropertySheet::WinHelp(dwData, nCmd);
  373. }
  374. /* virtual */
  375. HRESULT
  376. CFtpSheet::LoadConfigurationParameters()
  377. /*++
  378. Routine Description:
  379. Load configuration parameters information
  380. Arguments:
  381. None
  382. Return Value:
  383. HRESULT
  384. --*/
  385. {
  386. //
  387. // Load base properties
  388. //
  389. CError err(CInetPropertySheet::LoadConfigurationParameters());
  390. if (err.Failed())
  391. {
  392. return err;
  393. }
  394. if (m_ppropInst == NULL)
  395. {
  396. //
  397. // First call -- load values
  398. //
  399. ASSERT(m_ppropDir == NULL);
  400. m_ppropInst = new CFTPInstanceProps(QueryAuthInfo(), QueryInstancePath());
  401. m_ppropDir = new CFTPDirProps(QueryAuthInfo(), QueryDirectoryPath());
  402. if (!m_ppropInst || !m_ppropDir)
  403. {
  404. TRACEEOLID("LoadConfigurationParameters: OOM");
  405. SAFE_DELETE(m_ppropDir);
  406. SAFE_DELETE(m_ppropInst);
  407. err = ERROR_NOT_ENOUGH_MEMORY;
  408. return err;
  409. }
  410. err = m_ppropInst->LoadData();
  411. if (err.Succeeded())
  412. {
  413. err = m_ppropDir->LoadData();
  414. }
  415. }
  416. return err;
  417. }
  418. /* virtual */
  419. void
  420. CFtpSheet::FreeConfigurationParameters()
  421. /*++
  422. Routine Description:
  423. Clean up configuration data
  424. Arguments:
  425. None
  426. Return Value:
  427. None
  428. --*/
  429. {
  430. //
  431. // Base class
  432. //
  433. CInetPropertySheet::FreeConfigurationParameters();
  434. ASSERT(m_ppropInst != NULL);
  435. ASSERT(m_ppropDir != NULL);
  436. SAFE_DELETE(m_ppropInst);
  437. SAFE_DELETE(m_ppropDir);
  438. }
  439. //
  440. // Message Map
  441. //
  442. BEGIN_MESSAGE_MAP(CFtpSheet, CInetPropertySheet)
  443. //{{AFX_MSG_MAP(CInetPropertySheet)
  444. //}}AFX_MSG_MAP
  445. END_MESSAGE_MAP()