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.

1919 lines
44 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. wvdir.cpp
  5. Abstract:
  6. WWW Directory Properties Page
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Sergei Antonov (sergeia)
  10. Project:
  11. Internet Services Manager
  12. Revision History:
  13. 11/15/2000 sergeia Added the mess of application pools for iis6
  14. 03/01/2001 sergeia Split dialog for file system objects. Now this source
  15. works for sites and vdirs only
  16. --*/
  17. #include "stdafx.h"
  18. #include "resource.h"
  19. #include "common.h"
  20. #include "inetprop.h"
  21. #include "InetMgrApp.h"
  22. #include "supdlgs.h"
  23. #include "shts.h"
  24. #include "w3sht.h"
  25. #include "wvdir.h"
  26. #include "dirbrows.h"
  27. #include "iisobj.h"
  28. #include <lmcons.h>
  29. #ifdef _DEBUG
  30. #define new DEBUG_NEW
  31. #undef THIS_FILE
  32. static char THIS_FILE[] = __FILE__;
  33. #endif
  34. //
  35. // Directory Properties Page
  36. //
  37. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  38. LPCTSTR
  39. CvtPathToDosStyle(CString & strPath)
  40. {
  41. //
  42. // Get a pointer to the string data without increasing the buffer
  43. //
  44. for (LPTSTR lp = strPath.GetBuffer(1); *lp; ++lp)
  45. {
  46. if (*lp == _T('/'))
  47. {
  48. *lp = _T('\\');
  49. }
  50. }
  51. strPath.ReleaseBuffer();
  52. return strPath;
  53. }
  54. IMPLEMENT_DYNCREATE(CW3DirectoryPage, CInetPropertyPage)
  55. CW3DirectoryPage::CW3DirectoryPage(
  56. CInetPropertySheet * pSheet,
  57. BOOL fHome,
  58. DWORD dwAttributes
  59. )
  60. /*++
  61. Routine Description:
  62. Constructor for directory property page
  63. Arguments:
  64. CInetPropertySheet * pSheet : Sheet pointer
  65. BOOL fHome : TRUE if this is a home directory
  66. DWORD dwAttributes : Attributes of the directory/file/vroot
  67. Return Value:
  68. N/A
  69. --*/
  70. : CInetPropertyPage(CW3DirectoryPage::IDD, pSheet,
  71. fHome ? IDS_TAB_HOME_DIRECTORY : IDS_TAB_VIRTUAL_DIRECTORY),
  72. //
  73. // Assign the range of bits in m_dwAccessPermissions that
  74. // we manage. This is important, because another page
  75. // manages other bits, and we don't want to screw up
  76. // the master value bits when our changes collide (it
  77. // will mark the original bits as dirty, because we're not
  78. // notified when the change is made...
  79. //
  80. m_dwBitRangePermissions(MD_ACCESS_EXECUTE |
  81. MD_ACCESS_SCRIPT |
  82. MD_ACCESS_WRITE |
  83. MD_ACCESS_SOURCE |
  84. MD_ACCESS_READ),
  85. m_dwBitRangeDirBrowsing(MD_DIRBROW_ENABLED),
  86. m_fHome(fHome),
  87. m_fRecordChanges(TRUE),
  88. m_strMetaRoot(),
  89. m_pApplication(NULL),
  90. m_fOriginallyUNC(FALSE),
  91. m_fCompatibilityMode(FALSE)
  92. {
  93. VERIFY(m_strPrompt[RADIO_DIRECTORY].LoadString(IDS_PROMPT_DIR));
  94. VERIFY(m_strPrompt[RADIO_NETDIRECTORY].LoadString(IDS_PROMPT_UNC));
  95. VERIFY(m_strPrompt[RADIO_REDIRECT].LoadString(IDS_PROMPT_REDIRECT));
  96. VERIFY(m_strRemove.LoadString(IDS_BUTTON_REMOVE));
  97. VERIFY(m_strCreate.LoadString(IDS_BUTTON_CREATE));
  98. VERIFY(m_strEnable.LoadString(IDS_BUTTON_ENABLE));
  99. VERIFY(m_strDisable.LoadString(IDS_BUTTON_DISABLE));
  100. VERIFY(m_strWebFmt.LoadString(IDS_APPROOT_FMT));
  101. }
  102. CW3DirectoryPage::~CW3DirectoryPage()
  103. {
  104. SAFE_DELETE(m_pApplication);
  105. }
  106. void
  107. CW3DirectoryPage::DoDataExchange(CDataExchange * pDX)
  108. {
  109. CInetPropertyPage::DoDataExchange(pDX);
  110. //{{AFX_DATA_MAP(CW3DirectoryPage)
  111. DDX_Radio(pDX, IDC_RADIO_DIR, m_nPathType);
  112. DDX_Control(pDX, IDC_RADIO_DIR, m_radio_Dir);
  113. DDX_Control(pDX, IDC_RADIO_REDIRECT, m_radio_Redirect);
  114. DDX_Control(pDX, IDC_RADIO_UNC, m_radio_Unc);
  115. DDX_Control(pDX, IDC_EDIT_PATH, m_edit_Path);
  116. DDX_Control(pDX, IDC_BUTTON_BROWSE, m_button_Browse);
  117. DDX_Check(pDX, IDC_CHECK_AUTHOR, m_fAuthor);
  118. DDX_Control(pDX, IDC_CHECK_AUTHOR, m_check_Author);
  119. DDX_Check(pDX, IDC_CHECK_READ, m_fRead);
  120. DDX_Control(pDX, IDC_CHECK_READ, m_check_Read);
  121. DDX_Check(pDX, IDC_CHECK_WRITE, m_fWrite);
  122. DDX_Control(pDX, IDC_CHECK_WRITE, m_check_Write);
  123. DDX_Check(pDX, IDC_CHECK_DIRECTORY_BROWSING_ALLOWED, m_fBrowsingAllowed);
  124. DDX_Control(pDX, IDC_CHECK_DIRECTORY_BROWSING_ALLOWED, m_check_DirBrowse);
  125. DDX_Check(pDX, IDC_CHECK_LOG_ACCESS, m_fLogAccess);
  126. DDX_Check(pDX, IDC_CHECK_INDEX, m_fIndexed);
  127. DDX_Control(pDX, IDC_CHECK_INDEX, m_check_Index);
  128. DDX_Control(pDX, IDC_EDIT_REDIRECT, m_edit_Redirect);
  129. DDX_Control(pDX, IDC_BUTTON_CONNECT_AS, m_button_ConnectAs);
  130. DDX_Check(pDX, IDC_CHECK_CHILD, m_fChild);
  131. DDX_Control(pDX, IDC_CHECK_CHILD, m_check_Child);
  132. DDX_Check(pDX, IDC_CHECK_EXACT, m_fExact);
  133. DDX_Check(pDX, IDC_CHECK_PERMANENT, m_fPermanent);
  134. DDX_Control(pDX, IDC_STATIC_PATH_PROMPT, m_static_PathPrompt);
  135. DDX_Control(pDX, IDC_STATIC_PERMISSIONS, m_static_PermissionsPrompt);
  136. DDX_CBIndex(pDX, IDC_COMBO_PERMISSIONS, m_nPermissions);
  137. DDX_Control(pDX, IDC_COMBO_PERMISSIONS, m_combo_Permissions);
  138. DDX_Control(pDX, IDC_STATIC_APP_PROMPT, m_static_AppPrompt);
  139. DDX_Text(pDX, IDC_EDIT_APPLICATION, m_strAppFriendlyName);
  140. DDV_MinMaxChars(pDX, m_strAppFriendlyName, 0, MAX_PATH); /// ?
  141. DDX_Control(pDX, IDC_EDIT_APPLICATION, m_edit_AppFriendlyName);
  142. DDX_Control(pDX, IDC_STATIC_STARTING_POINT, m_static_StartingPoint);
  143. DDX_Control(pDX, IDC_STATIC_PROTECTION, m_static_ProtectionPrompt);
  144. DDX_Control(pDX, IDC_BUTTON_UNLOAD_APP, m_button_Unload);
  145. DDX_Control(pDX, IDC_BUTTON_CREATE_REMOVE_APP, m_button_CreateRemove);
  146. DDX_Control(pDX, IDC_APP_CONFIGURATION, m_button_Configuration);
  147. DDX_Control(pDX, IDC_COMBO_PROCESS, m_combo_Process);
  148. //}}AFX_DATA_MAP
  149. if (pDX->m_bSaveAndValidate)
  150. {
  151. //
  152. // Make sure all field names are correct
  153. //
  154. if (m_nPathType == RADIO_NETDIRECTORY)
  155. {
  156. DDX_Text(pDX, IDC_EDIT_PATH, m_strPath);
  157. m_strPath.TrimLeft();
  158. DDV_MinMaxChars(pDX, m_strPath, 0, MAX_PATH);
  159. if (!PathIsValid(m_strPath) || !PathIsUNC(m_strPath))
  160. {
  161. ::AfxMessageBox(IDS_BAD_UNC_PATH);
  162. pDX->PrepareEditCtrl(IDS_BAD_UNC_PATH);
  163. pDX->Fail();
  164. }
  165. m_strRedirectPath.Empty();
  166. /*
  167. ISSUE: Don't need username/password?
  168. if (m_strUserName.IsEmpty())
  169. {
  170. ::AfxMessageBox(IDS_ERR_NO_USERNAME);
  171. if (!BrowseUser())
  172. {
  173. pDX->Fail();
  174. }
  175. }
  176. */
  177. }
  178. else if (m_nPathType == RADIO_REDIRECT)
  179. {
  180. DDX_Text(pDX, IDC_EDIT_REDIRECT, m_strRedirectPath);
  181. m_strRedirectPath.TrimLeft();
  182. DDV_MinMaxChars(pDX, m_strRedirectPath, 0, 2 * MAX_PATH);
  183. if (!IsRelURLPath(m_strRedirectPath)
  184. && !IsWildcardedRedirectPath(m_strRedirectPath)
  185. && !IsURLName(m_strRedirectPath))
  186. {
  187. ::AfxMessageBox(IDS_BAD_URL_PATH);
  188. pDX->Fail();
  189. }
  190. }
  191. else // Local directory
  192. {
  193. ASSERT(m_nPathType == RADIO_DIRECTORY);
  194. m_strRedirectPath.Empty();
  195. DDX_Text(pDX, IDC_EDIT_PATH, m_strPath);
  196. m_strPath.TrimLeft();
  197. if (!IsMasterInstance())
  198. {
  199. DDV_MinMaxChars(pDX, m_strPath, 1, MAX_PATH);
  200. }
  201. else
  202. {
  203. if (m_strPath.IsEmpty())
  204. {
  205. //
  206. // No additional validation necc. on master
  207. // instance.
  208. //
  209. return;
  210. }
  211. }
  212. if ( !PathIsValid(m_strPath)
  213. || (PathIsRelative(m_strPath) && !IsDevicePath(m_strPath))
  214. )
  215. {
  216. ::AfxMessageBox(IDS_ERR_INVALID_PATH);
  217. pDX->PrepareEditCtrl(IDC_EDIT_PATH);
  218. pDX->Fail();
  219. }
  220. if (IsLocal())
  221. {
  222. if (!PathIsDirectory(m_strPath))
  223. {
  224. ::AfxMessageBox(IDS_ERR_PATH_NOT_FOUND);
  225. pDX->PrepareEditCtrl(IDC_EDIT_PATH);
  226. pDX->Fail();
  227. }
  228. }
  229. }
  230. }
  231. else
  232. {
  233. DDX_Text(pDX, IDC_EDIT_REDIRECT, m_strRedirectPath);
  234. DDX_Text(pDX, IDC_EDIT_PATH, m_strPath);
  235. DDV_MinMaxChars(pDX, m_strPath, 0, MAX_PATH);
  236. }
  237. }
  238. //
  239. // Message Map
  240. //
  241. BEGIN_MESSAGE_MAP(CW3DirectoryPage, CInetPropertyPage)
  242. //{{AFX_MSG_MAP(CW3DirectoryPage)
  243. ON_BN_CLICKED(IDC_CHECK_AUTHOR, OnCheckAuthor)
  244. ON_BN_CLICKED(IDC_CHECK_READ, OnCheckRead)
  245. ON_BN_CLICKED(IDC_CHECK_WRITE, OnCheckWrite)
  246. ON_BN_CLICKED(IDC_RADIO_DIR, OnRadioDir)
  247. ON_BN_CLICKED(IDC_RADIO_REDIRECT, OnRadioRedirect)
  248. ON_BN_CLICKED(IDC_RADIO_UNC, OnRadioUnc)
  249. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  250. ON_BN_CLICKED(IDC_BUTTON_CONNECT_AS, OnButtonConnectAs)
  251. ON_BN_CLICKED(IDC_BUTTON_CREATE_REMOVE_APP, OnButtonCreateRemoveApp)
  252. ON_BN_CLICKED(IDC_BUTTON_UNLOAD_APP, OnButtonUnloadApp)
  253. ON_BN_CLICKED(IDC_APP_CONFIGURATION, OnButtonConfiguration)
  254. ON_CBN_SELCHANGE(IDC_COMBO_PERMISSIONS, OnSelchangeComboPermissions)
  255. ON_CBN_SELCHANGE(IDC_COMBO_PROCESS, OnSelchangeComboProcess)
  256. ON_WM_DESTROY()
  257. //}}AFX_MSG_MAP
  258. ON_EN_CHANGE(IDC_EDIT_PATH, OnItemChanged)
  259. ON_EN_CHANGE(IDC_EDIT_REDIRECT, OnItemChanged)
  260. ON_EN_CHANGE(IDC_EDIT_APPLICATION, OnItemChanged)
  261. ON_BN_CLICKED(IDC_CHECK_DIRECTORY_BROWSING_ALLOWED, OnItemChanged)
  262. ON_BN_CLICKED(IDC_CHECK_LOG_ACCESS, OnItemChanged)
  263. // ON_BN_CLICKED(IDC_CHECK_SCRIPT, OnItemChanged)
  264. ON_BN_CLICKED(IDC_CHECK_CHILD, OnItemChanged)
  265. ON_BN_CLICKED(IDC_CHECK_EXACT, OnItemChanged)
  266. ON_BN_CLICKED(IDC_CHECK_PERMANENT, OnItemChanged)
  267. ON_BN_CLICKED(IDC_CHECK_INDEX, OnItemChanged)
  268. END_MESSAGE_MAP()
  269. void
  270. CW3DirectoryPage::RefreshAppState()
  271. /*++
  272. Routine Description:
  273. Refresh app state parameters
  274. Arguments:
  275. None
  276. Return Value:
  277. None
  278. --*/
  279. {
  280. ASSERT(m_pApplication != NULL);
  281. CError err(m_pApplication->RefreshAppState());
  282. if (err.Failed())
  283. {
  284. m_dwAppState = APPSTATUS_NOTDEFINED;
  285. if (err.Win32Error() == ERROR_PATH_NOT_FOUND)
  286. {
  287. //
  288. // Ignore this error, it really just means the path
  289. // doesn't exist in the metabase, which is true for most
  290. // file and directory properties, and not an error
  291. // condition.
  292. //
  293. err.Reset();
  294. }
  295. }
  296. else
  297. {
  298. m_dwAppState = m_pApplication->QueryAppState();
  299. }
  300. if (err.Succeeded())
  301. {
  302. //
  303. // Get metabase information
  304. //
  305. m_strAppRoot = m_pApplication->m_strAppRoot;
  306. m_dwAppProtection = m_pApplication->m_dwProcessProtection;
  307. m_strAppFriendlyName = m_pApplication->m_strFriendlyName;
  308. m_fIsAppRoot = m_strMetaRoot.CompareNoCase(
  309. CMetabasePath::CleanMetaPath(m_strAppRoot)) == 0;
  310. }
  311. else
  312. {
  313. //
  314. // Display error information
  315. //
  316. err.MessageBoxFormat(IDS_ERR_APP, MB_OK, NO_HELP_CONTEXT);
  317. }
  318. }
  319. CString &
  320. CW3DirectoryPage::FriendlyAppRoot(LPCTSTR lpAppRoot, CString & strFriendly)
  321. /*++
  322. Routine Description:
  323. Convert the metabase app root path to a friendly display name
  324. format.
  325. Arguments:
  326. LPCTSTR lpAppRoot : App root
  327. CString & strFriendly : Output friendly app root format
  328. Return Value:
  329. Reference to the output string
  330. Notes:
  331. App root must have been cleaned from WAM format prior
  332. to calling this function (see first ASSERT below)
  333. --*/
  334. {
  335. if (lpAppRoot != NULL && *lpAppRoot != 0)
  336. {
  337. //
  338. // Make sure we cleaned up WAM format
  339. //
  340. ASSERT(*lpAppRoot != _T('/'));
  341. strFriendly.Empty();
  342. CInstanceProps prop(QueryAuthInfo(), lpAppRoot);
  343. HRESULT hr = prop.LoadData();
  344. if (SUCCEEDED(hr))
  345. {
  346. CString root, tail;
  347. strFriendly.Format(
  348. m_strWebFmt,
  349. prop.GetDisplayText(root)
  350. );
  351. CMetabasePath::GetRootPath(lpAppRoot, root, &tail);
  352. if (!tail.IsEmpty())
  353. {
  354. //
  355. // Add rest of dir path
  356. //
  357. strFriendly += _T("/");
  358. strFriendly += tail;
  359. }
  360. //
  361. // Now change forward slashes in the path to backward slashes
  362. //
  363. CvtPathToDosStyle(strFriendly);
  364. return strFriendly;
  365. }
  366. }
  367. //
  368. // Bogus
  369. //
  370. VERIFY(strFriendly.LoadString(IDS_APPROOT_UNKNOWN));
  371. return strFriendly;
  372. }
  373. int
  374. CW3DirectoryPage::SetComboSelectionFromAppState(DWORD dwAppState)
  375. /*++
  376. Routine Description:
  377. Set the protection combo box current selection from the
  378. app state DWORD
  379. Arguments:
  380. DWORD dwAppState : Application State
  381. Return Value:
  382. Combo selection ID
  383. --*/
  384. {
  385. int nSel = -1;
  386. switch(dwAppState)
  387. {
  388. case CWamInterface::APP_INPROC:
  389. nSel = m_nSelInProc;
  390. break;
  391. case CWamInterface::APP_POOLEDPROC:
  392. ASSERT(m_pApplication->SupportsPooledProc());
  393. nSel = m_nSelPooledProc;
  394. break;
  395. case CWamInterface::APP_OUTOFPROC:
  396. nSel = m_nSelOutOfProc;
  397. break;
  398. default:
  399. ASSERT("Bogus app protection level");
  400. }
  401. ASSERT(nSel >= 0);
  402. m_combo_Process.SetCurSel(nSel);
  403. return nSel;
  404. }
  405. DWORD
  406. CW3DirectoryPage::GetAppStateFromComboSelection() const
  407. /*++
  408. Routine Description:
  409. Get the app state DWORD that coresponds to the current combo
  410. box list selection
  411. Arguments:
  412. None
  413. Return Value:
  414. App state DWORD or 0xffffffff;
  415. --*/
  416. {
  417. int nSel = m_combo_Process.GetCurSel();
  418. if (nSel == m_nSelOutOfProc)
  419. {
  420. return CWamInterface::APP_OUTOFPROC;
  421. }
  422. if (nSel == m_nSelPooledProc)
  423. {
  424. ASSERT(m_pApplication->SupportsPooledProc());
  425. return CWamInterface::APP_POOLEDPROC;
  426. }
  427. if (nSel == m_nSelInProc)
  428. {
  429. return CWamInterface::APP_INPROC;
  430. }
  431. ASSERT(FALSE && "Invalid application state");
  432. return 0xffffffff;
  433. }
  434. void
  435. CW3DirectoryPage::SetApplicationState()
  436. /*++
  437. Routine Description:
  438. Set application control state
  439. Arguments:
  440. None
  441. Return Value:
  442. None
  443. --*/
  444. {
  445. //
  446. // SetWindowText causes a dirty marker
  447. //
  448. BOOL fOld = m_fRecordChanges;
  449. m_fRecordChanges = FALSE;
  450. m_fParentEnabled = !m_strAppRoot.IsEmpty();
  451. m_fAppEnabled = FALSE;
  452. if (m_pApplication != NULL)
  453. {
  454. m_pApplication->RefreshAppState();
  455. m_fAppEnabled = m_fIsAppRoot && m_pApplication->IsEnabledApplication();
  456. }
  457. BOOL fVisible = (
  458. m_nPathType == RADIO_DIRECTORY || m_nPathType == RADIO_NETDIRECTORY);
  459. m_button_CreateRemove.EnableWindow(fVisible && !IsMasterInstance() && HasAdminAccess());
  460. m_button_CreateRemove.SetWindowText(m_fAppEnabled ? m_strRemove : m_strCreate);
  461. m_static_ProtectionPrompt.EnableWindow(fVisible &&
  462. m_fAppEnabled && !IsMasterInstance() && HasAdminAccess());
  463. //
  464. // Set selection in combo box to match current app state
  465. //
  466. if (m_fCompatibilityMode)
  467. {
  468. SetComboSelectionFromAppState(m_dwAppProtection);
  469. }
  470. m_combo_Process.EnableWindow(fVisible &&
  471. m_fAppEnabled && !IsMasterInstance() && HasAdminAccess());
  472. m_static_PermissionsPrompt.EnableWindow(fVisible && HasAdminAccess());
  473. m_combo_Permissions.EnableWindow(fVisible && HasAdminAccess());
  474. m_static_AppPrompt.EnableWindow(fVisible && m_fIsAppRoot && HasAdminAccess());
  475. m_edit_AppFriendlyName.EnableWindow(fVisible && m_fIsAppRoot && HasAdminAccess());
  476. m_button_Configuration.EnableWindow(fVisible && (m_fAppEnabled || IsMasterInstance()));
  477. //
  478. // Write out the verbose starting point.
  479. //
  480. CString str;
  481. if (IsMasterInstance())
  482. {
  483. VERIFY(str.LoadString(IDS_WEB_MASTER));
  484. }
  485. else
  486. {
  487. FriendlyAppRoot(m_strAppRoot, str);
  488. }
  489. FitPathToControl(m_static_StartingPoint, str);
  490. m_edit_AppFriendlyName.SetWindowText(m_strAppFriendlyName);
  491. m_button_Unload.EnableWindow(fVisible && m_dwAppState == APPSTATUS_RUNNING);
  492. //
  493. // Restore (see note on top)
  494. //
  495. m_fRecordChanges = fOld;
  496. }
  497. void
  498. CW3DirectoryPage::ChangeTypeTo(int nNewType)
  499. /*++
  500. Routine Description
  501. Change the directory type
  502. Arguments:
  503. int nNewType : New radio value
  504. Return Value:
  505. None
  506. --*/
  507. {
  508. int nOldType = m_nPathType;
  509. m_nPathType = nNewType;
  510. if (nOldType == m_nPathType)
  511. {
  512. return;
  513. }
  514. OnItemChanged();
  515. SetStateByType();
  516. int nID = -1;
  517. CEdit * pPath = NULL;
  518. LPCTSTR lpKeepPath = NULL;
  519. switch(m_nPathType)
  520. {
  521. case RADIO_DIRECTORY:
  522. if (!PathIsUNC(m_strPath) && (!PathIsRelative(m_strPath) || IsDevicePath(m_strPath)))
  523. {
  524. //
  525. // The old path info is acceptable, propose it
  526. // as a default
  527. //
  528. lpKeepPath = m_strPath;
  529. }
  530. nID = IDS_DIRECTORY_MASK;
  531. pPath = &m_edit_Path;
  532. break;
  533. case RADIO_NETDIRECTORY:
  534. if (PathIsUNC(m_strPath))
  535. {
  536. //
  537. // The old path info is acceptable, propose it
  538. // as a default
  539. //
  540. lpKeepPath = m_strPath;
  541. }
  542. nID = IDS_UNC_MASK;
  543. pPath = &m_edit_Path;
  544. break;
  545. case RADIO_REDIRECT:
  546. if (!m_strRedirectPath.IsEmpty())
  547. {
  548. //
  549. // The old path info is acceptable, propose it
  550. // as a default
  551. //
  552. lpKeepPath = m_strRedirectPath;
  553. }
  554. nID = IDS_REDIRECT_MASK;
  555. pPath = &m_edit_Redirect;
  556. break;
  557. default:
  558. ASSERT(FALSE);
  559. return;
  560. }
  561. //
  562. // Load mask resource, and display
  563. // this in the directory
  564. //
  565. if (pPath != NULL)
  566. {
  567. if (lpKeepPath != NULL)
  568. {
  569. pPath->SetWindowText(lpKeepPath);
  570. }
  571. else
  572. {
  573. CString str;
  574. VERIFY(str.LoadString(nID));
  575. pPath->SetWindowText(str);
  576. }
  577. pPath->SetSel(0,-1);
  578. pPath->SetFocus();
  579. }
  580. }
  581. void
  582. CW3DirectoryPage::ShowControl(CWnd * pWnd, BOOL fShow)
  583. {
  584. ASSERT(pWnd != NULL);
  585. pWnd->EnableWindow(fShow);
  586. pWnd->ShowWindow(fShow ? SW_SHOW : SW_HIDE);
  587. }
  588. int
  589. CW3DirectoryPage::AddStringToComboBox(CComboBox & combo, UINT nID)
  590. {
  591. CString str;
  592. VERIFY(str.LoadString(nID));
  593. return combo.AddString(str);
  594. }
  595. void
  596. CW3DirectoryPage::SetStateByType()
  597. {
  598. BOOL fShowDirFlags;
  599. BOOL fShowLargeDirGroup;
  600. BOOL fShowRedirectFlags;
  601. BOOL fShowApp;
  602. BOOL fShowIndex;
  603. BOOL fShowDirBrowse;
  604. BOOL fShowDAV;
  605. BOOL fEnableChild;
  606. BOOL fEnableBrowse;
  607. switch(m_nPathType)
  608. {
  609. case RADIO_DIRECTORY:
  610. ShowControl(&m_button_ConnectAs, FALSE);
  611. ShowControl(&m_button_Browse, TRUE);
  612. ShowControl(&m_edit_Path, TRUE);
  613. ShowControl(&m_edit_Redirect, FALSE);
  614. fShowDirFlags = TRUE;
  615. fShowLargeDirGroup = TRUE;
  616. fShowRedirectFlags = FALSE;
  617. fShowApp = TRUE;
  618. fShowIndex = TRUE;
  619. fShowDirBrowse = TRUE;
  620. fShowDAV = TRUE;
  621. fEnableChild = FALSE;
  622. fEnableBrowse = IsLocal() && !IsMasterInstance() && HasAdminAccess();
  623. break;
  624. case RADIO_NETDIRECTORY:
  625. ShowControl(&m_button_ConnectAs, TRUE);
  626. ShowControl(&m_button_Browse, FALSE);
  627. ShowControl(&m_edit_Path, TRUE);
  628. ShowControl(&m_edit_Redirect, FALSE);
  629. fShowDirFlags = TRUE;
  630. fShowLargeDirGroup = TRUE;
  631. fShowRedirectFlags = FALSE;
  632. fShowApp = TRUE;
  633. fShowIndex = TRUE;
  634. fShowDirBrowse = TRUE;
  635. fShowDAV = TRUE;
  636. fEnableChild = FALSE;
  637. fEnableBrowse = FALSE;
  638. break;
  639. case RADIO_REDIRECT:
  640. ShowControl(&m_button_ConnectAs, FALSE);
  641. ShowControl(&m_button_Browse, FALSE);
  642. ShowControl(&m_edit_Path, FALSE);
  643. ShowControl(&m_edit_Redirect, TRUE);
  644. fShowDirFlags = FALSE;
  645. fShowRedirectFlags = TRUE;
  646. fShowApp = FALSE;
  647. fShowDAV = FALSE;
  648. fShowIndex = FALSE;
  649. fShowDirBrowse = FALSE;
  650. fEnableChild = TRUE;
  651. fEnableBrowse = FALSE;
  652. break;
  653. default:
  654. ASSERT(FALSE && "Invalid Selection");
  655. return;
  656. }
  657. ShowControl(GetDlgItem(IDC_CHECK_READ), fShowDirFlags);
  658. ShowControl(GetDlgItem(IDC_CHECK_WRITE), fShowDirFlags);
  659. ShowControl(GetDlgItem(IDC_CHECK_LOG_ACCESS), fShowDirFlags);
  660. ShowControl(GetDlgItem(IDC_CHECK_DIRECTORY_BROWSING_ALLOWED), fShowDirFlags);
  661. ShowControl(GetDlgItem(IDC_CHECK_INDEX), fShowDirFlags);
  662. ShowControl(GetDlgItem(IDC_CHECK_AUTHOR), fShowDirFlags);
  663. ShowControl(GetDlgItem(IDC_STATIC_DIRFLAGS_LARGE),
  664. fShowDirFlags && fShowLargeDirGroup);
  665. ShowControl(GetDlgItem(IDC_STATIC_DIRFLAGS_SMALL),
  666. fShowDirFlags && !fShowLargeDirGroup);
  667. ShowControl(IDC_CHECK_EXACT, fShowRedirectFlags);
  668. ShowControl(IDC_CHECK_CHILD, fShowRedirectFlags);
  669. ShowControl(IDC_CHECK_PERMANENT, fShowRedirectFlags);
  670. ShowControl(IDC_STATIC_REDIRECT_PROMPT, fShowRedirectFlags);
  671. ShowControl(IDC_STATIC_REDIRFLAGS, fShowRedirectFlags);
  672. ShowControl(IDC_STATIC_APPLICATIONS, fShowApp);
  673. ShowControl(IDC_STATIC_APP_PROMPT, fShowApp);
  674. ShowControl(IDC_EDIT_APPLICATION, fShowApp);
  675. ShowControl(IDC_STATIC_STARTING_POINT, fShowApp);
  676. ShowControl(IDC_STATIC_SP_PROMPT, fShowApp);
  677. ShowControl(IDC_COMBO_PROCESS, fShowApp);
  678. ShowControl(IDC_STATIC_PERMISSIONS, fShowApp);
  679. ShowControl(IDC_BUTTON_CREATE_REMOVE_APP, fShowApp);
  680. ShowControl(IDC_BUTTON_UNLOAD_APP, fShowApp);
  681. ShowControl(IDC_APP_CONFIGURATION, fShowApp);
  682. ShowControl(IDC_STATIC_APPLICATION_SETTINGS, fShowApp);
  683. ShowControl(IDC_COMBO_PERMISSIONS, fShowApp);
  684. ShowControl(IDC_STATIC_PROTECTION, fShowApp);
  685. ShowControl(&m_check_Author, fShowDAV);
  686. ShowControl(&m_check_DirBrowse, fShowDirBrowse);
  687. ShowControl(&m_check_Index, fShowIndex);
  688. //
  689. // Enable/Disable must come after the showcontrols
  690. //
  691. m_button_Browse.EnableWindow(fEnableBrowse);
  692. m_check_Child.EnableWindow(fEnableChild);
  693. m_static_PathPrompt.SetWindowText(m_strPrompt[m_nPathType]);
  694. SetApplicationState();
  695. }
  696. void
  697. CW3DirectoryPage::SaveAuthoringState()
  698. /*++
  699. Routine Description:
  700. Save authoring state
  701. Arguments:
  702. None
  703. Return Value:
  704. None
  705. --*/
  706. {
  707. if (m_check_Write.m_hWnd)
  708. {
  709. //
  710. // Controls initialized -- store live data
  711. //
  712. m_fOriginalWrite = m_check_Write.GetCheck() > 0;
  713. m_fOriginalRead = m_check_Read.GetCheck() > 0;
  714. }
  715. else
  716. {
  717. //
  718. // Controls not yet initialized, store original data
  719. //
  720. m_fOriginalWrite = m_fWrite;
  721. m_fOriginalRead = m_fRead;
  722. }
  723. }
  724. void
  725. CW3DirectoryPage::RestoreAuthoringState()
  726. /*++
  727. Routine Description:
  728. Restore the authoring state
  729. Arguments:
  730. None
  731. Return Value:
  732. None
  733. --*/
  734. {
  735. m_fWrite = m_fOriginalWrite;
  736. m_fRead = m_fOriginalRead;
  737. }
  738. void
  739. CW3DirectoryPage::SetAuthoringState(
  740. BOOL fAlterReadAndWrite
  741. )
  742. /*++
  743. Routine Description:
  744. Set authoring state
  745. Arguments:
  746. None
  747. Return Value:
  748. None
  749. --*/
  750. {
  751. if (fAlterReadAndWrite)
  752. {
  753. if (m_fAuthor)
  754. {
  755. //
  756. // Remember previous setting to undo
  757. // this thing.
  758. //
  759. SaveAuthoringState();
  760. m_fRead = m_fWrite = TRUE;
  761. }
  762. else
  763. {
  764. //
  765. // Restore previous defaults
  766. //
  767. RestoreAuthoringState();
  768. }
  769. m_check_Read.SetCheck(m_fRead);
  770. m_check_Write.SetCheck(m_fWrite);
  771. }
  772. m_check_Author.EnableWindow(
  773. (m_fRead || m_fWrite) &&
  774. HasAdminAccess() &&
  775. HasDAV()
  776. );
  777. // m_check_Read.EnableWindow(!m_fAuthor && HasAdminAccess());
  778. // m_check_Write.EnableWindow(!m_fAuthor && HasAdminAccess());
  779. }
  780. void
  781. CW3DirectoryPage::SetPathType()
  782. /*++
  783. Routine Description:
  784. Set path type from given path
  785. Arguments:
  786. None
  787. Return Value:
  788. None
  789. --*/
  790. {
  791. if (!m_strRedirectPath.IsEmpty())
  792. {
  793. m_nPathType = RADIO_REDIRECT;
  794. m_radio_Dir.SetCheck(0);
  795. m_radio_Unc.SetCheck(0);
  796. m_radio_Redirect.SetCheck(1);
  797. }
  798. else
  799. {
  800. m_radio_Redirect.SetCheck(0);
  801. SetPathType(m_strPath);
  802. }
  803. m_static_PathPrompt.SetWindowText(m_strPrompt[m_nPathType]);
  804. }
  805. void
  806. CW3DirectoryPage::SetPathType(LPCTSTR lpstrPath)
  807. /*++
  808. Routine Description:
  809. Set path type from given path
  810. Arguments:
  811. LPCTSTR lpstrPath : Path string
  812. Return Value:
  813. None
  814. --*/
  815. {
  816. if (PathIsUNC(lpstrPath))
  817. {
  818. m_nPathType = RADIO_NETDIRECTORY;
  819. m_radio_Dir.SetCheck(0);
  820. m_radio_Unc.SetCheck(1);
  821. }
  822. else
  823. {
  824. m_nPathType = RADIO_DIRECTORY;
  825. m_radio_Unc.SetCheck(0);
  826. m_radio_Dir.SetCheck(1);
  827. }
  828. }
  829. BOOL
  830. CW3DirectoryPage::BrowseUser()
  831. /*++
  832. Routine Description:
  833. Browse for username/password
  834. Arguments:
  835. None
  836. Return Value:
  837. TRUE if one was selected, FALSE otherwise.
  838. --*/
  839. {
  840. CUserAccountDlg dlg(
  841. QueryServerName(),
  842. m_strUserName,
  843. m_strPassword,
  844. this
  845. );
  846. if (dlg.DoModal() == IDOK)
  847. {
  848. m_strUserName = dlg.m_strUserName;
  849. m_strPassword = dlg.m_strPassword;
  850. OnItemChanged();
  851. return TRUE;
  852. }
  853. return FALSE;
  854. }
  855. //
  856. // Message Handlers
  857. //
  858. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  859. void
  860. CW3DirectoryPage::OnItemChanged()
  861. /*++
  862. Routine Description:
  863. Handle change in data on the item
  864. Arguments:
  865. None
  866. Return Value:
  867. None
  868. --*/
  869. {
  870. if (m_fRecordChanges)
  871. {
  872. SetModified(TRUE);
  873. }
  874. }
  875. static int CALLBACK
  876. FileChooserCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
  877. {
  878. CW3DirectoryPage * pThis = (CW3DirectoryPage *)lpData;
  879. ASSERT(pThis != NULL);
  880. return pThis->BrowseForFolderCallback(hwnd, uMsg, lParam);
  881. }
  882. int
  883. CW3DirectoryPage::BrowseForFolderCallback(HWND hwnd, UINT uMsg, LPARAM lParam)
  884. {
  885. switch (uMsg)
  886. {
  887. case BFFM_INITIALIZED:
  888. ASSERT(m_pPathTemp != NULL);
  889. if (::PathIsNetworkPath(m_pPathTemp))
  890. return 0;
  891. while (!::PathIsDirectory(m_pPathTemp))
  892. {
  893. if (0 == ::PathRemoveFileSpec(m_pPathTemp) && !::PathIsRoot(m_pPathTemp))
  894. {
  895. return 0;
  896. }
  897. DWORD attr = GetFileAttributes(m_pPathTemp);
  898. if ((attr & FILE_ATTRIBUTE_READONLY) == 0)
  899. break;
  900. }
  901. ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)m_pPathTemp);
  902. break;
  903. case BFFM_SELCHANGED:
  904. {
  905. LPITEMIDLIST pidl = (LPITEMIDLIST)lParam;
  906. TCHAR path[MAX_PATH];
  907. if (SHGetPathFromIDList(pidl, path))
  908. {
  909. ::SendMessage(hwnd, BFFM_ENABLEOK, 0, !PathIsNetworkPath(path));
  910. }
  911. }
  912. break;
  913. case BFFM_VALIDATEFAILED:
  914. break;
  915. }
  916. return 0;
  917. }
  918. void
  919. CW3DirectoryPage::OnButtonBrowse()
  920. /*++
  921. Routine Description:
  922. "Browse" button handler
  923. Arguments:
  924. None
  925. Return Value:
  926. None
  927. --*/
  928. {
  929. ASSERT(IsLocal());
  930. BOOL bRes = FALSE;
  931. HRESULT hr;
  932. CString str;
  933. m_edit_Path.GetWindowText(str);
  934. if (SUCCEEDED(hr = CoInitialize(NULL)))
  935. {
  936. LPITEMIDLIST pidl = NULL;
  937. if (SUCCEEDED(SHGetFolderLocation(NULL, CSIDL_DRIVES, NULL, 0, &pidl)))
  938. {
  939. LPITEMIDLIST pidList = NULL;
  940. BROWSEINFO bi;
  941. TCHAR buf[MAX_PATH];
  942. ZeroMemory(&bi, sizeof(bi));
  943. int drive = PathGetDriveNumber(str);
  944. if (GetDriveType(PathBuildRoot(buf, drive)) == DRIVE_FIXED)
  945. {
  946. StrCpy(buf, str);
  947. }
  948. else
  949. {
  950. buf[0] = 0;
  951. }
  952. m_strBrowseTitle.LoadString(IsHome() ?
  953. IDS_TAB_HOME_DIRECTORY : IDS_TAB_VIRTUAL_DIRECTORY);
  954. bi.hwndOwner = m_hWnd;
  955. bi.pidlRoot = pidl;
  956. bi.pszDisplayName = m_pPathTemp = buf;
  957. bi.lpszTitle = m_strBrowseTitle;
  958. bi.ulFlags |= BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS/* | BIF_EDITBOX*/;
  959. bi.lpfn = FileChooserCallback;
  960. bi.lParam = (LPARAM)this;
  961. pidList = SHBrowseForFolder(&bi);
  962. if ( pidList != NULL
  963. && SHGetPathFromIDList(pidList, buf)
  964. )
  965. {
  966. str = buf;
  967. bRes = TRUE;
  968. }
  969. IMalloc * pMalloc;
  970. VERIFY(SUCCEEDED(SHGetMalloc(&pMalloc)));
  971. if (pidl != NULL)
  972. pMalloc->Free(pidl);
  973. pMalloc->Release();
  974. }
  975. CoUninitialize();
  976. }
  977. if (bRes)
  978. {
  979. m_edit_Path.SetWindowText(str);
  980. m_strPath = str;
  981. SetPathType();
  982. OnItemChanged();
  983. }
  984. }
  985. BOOL
  986. CW3DirectoryPage::OnSetActive()
  987. /*++
  988. Routine Description:
  989. Page has become active. Dismiss if we're in an inconsistent state
  990. Arguments:
  991. None
  992. Return Value:
  993. TRUE to proceed, FALSE to dismiss.
  994. --*/
  995. {
  996. if (m_pApplication == NULL)
  997. {
  998. return FALSE;
  999. }
  1000. return CInetPropertyPage::OnSetActive();
  1001. }
  1002. BOOL
  1003. CW3DirectoryPage::OnInitDialog()
  1004. {
  1005. CInetPropertyPage::OnInitDialog();
  1006. m_fCompatibilityMode = ((CW3Sheet *)GetSheet())->InCompatibilityMode();
  1007. CString str;
  1008. VERIFY(str.LoadString(IDS_RADIO_VDIR));
  1009. m_radio_Dir.SetWindowText(str);
  1010. //
  1011. // Fill permissions combo box.
  1012. //
  1013. AddStringToComboBox(m_combo_Permissions, IDS_PERMISSIONS_NONE);
  1014. AddStringToComboBox(m_combo_Permissions, IDS_PERMISSIONS_SCRIPT);
  1015. AddStringToComboBox(m_combo_Permissions, IDS_PERMISSIONS_EXECUTE);
  1016. m_combo_Permissions.SetCurSel(m_nPermissions);
  1017. if (m_fCompatibilityMode)
  1018. {
  1019. m_nSelInProc = AddStringToComboBox(m_combo_Process, IDS_COMBO_INPROC);
  1020. if (m_pApplication->SupportsPooledProc())
  1021. {
  1022. m_nSelPooledProc = AddStringToComboBox(m_combo_Process, IDS_COMBO_POOLEDPROC);
  1023. }
  1024. else
  1025. {
  1026. m_nSelPooledProc = -1; // N/A
  1027. }
  1028. m_nSelOutOfProc = AddStringToComboBox(m_combo_Process, IDS_COMBO_OUTPROC);
  1029. }
  1030. else
  1031. {
  1032. CString buf;
  1033. buf.LoadString(IDS_APPLICATION_POOL);
  1034. m_static_ProtectionPrompt.SetWindowText(buf);
  1035. CMapStringToString pools;
  1036. CError err = ((CW3Sheet *)GetSheet())->EnumAppPools(pools);
  1037. int idx_sel = CB_ERR;
  1038. int idx_def = CB_ERR;
  1039. err = ((CW3Sheet *)GetSheet())->QueryDefaultPoolId(buf);
  1040. if (err.Succeeded())
  1041. {
  1042. ASSERT(pools.GetCount() > 0);
  1043. POSITION pos = pools.GetStartPosition();
  1044. CString pool_id, pool_name;
  1045. while (pos != NULL)
  1046. {
  1047. pools.GetNextAssoc(pos, pool_name, pool_id);
  1048. int idx = m_combo_Process.AddString(pool_name);
  1049. m_combo_Process.SetItemDataPtr(idx, StrDup(pool_id));
  1050. if (0 == m_pApplication->m_strAppPoolId.CompareNoCase(pool_id))
  1051. {
  1052. idx_sel = idx;
  1053. }
  1054. if (0 == buf.CompareNoCase(pool_id))
  1055. {
  1056. idx_def = idx;
  1057. }
  1058. }
  1059. }
  1060. // select the app pool which has an id the same as in current application
  1061. // It could be new app created in compatibility mode, no app pool is default app pool
  1062. if (CB_ERR == idx_sel)
  1063. {
  1064. idx_sel = idx_def;
  1065. }
  1066. m_combo_Process.SetCurSel(idx_sel);
  1067. }
  1068. //
  1069. // Selection will be set later...
  1070. //
  1071. SetPathType();
  1072. SetStateByType();
  1073. SetAuthoringState(FALSE);
  1074. TRACEEOLID(m_strMetaRoot);
  1075. //
  1076. // Some items not available on master instance, or if no admin
  1077. // access exists
  1078. //
  1079. BOOL fOkToDIR = TRUE;
  1080. BOOL fOkToUNC = TRUE;
  1081. if (!HasAdminAccess())
  1082. {
  1083. //
  1084. // If not an admin, operator cannot change
  1085. // the path, he can only cancel a redirect
  1086. // by going back to the path it had before.
  1087. //
  1088. fOkToDIR = !PathIsRelative(m_strPath) || IsDevicePath(m_strPath);
  1089. fOkToUNC = PathIsUNC(m_strPath);
  1090. }
  1091. GetDlgItem(IDC_STATIC_PATH_TYPE)->EnableWindow(!IsMasterInstance());
  1092. GetDlgItem(IDC_RADIO_DIR)->EnableWindow(!IsMasterInstance() && fOkToDIR);
  1093. GetDlgItem(IDC_RADIO_UNC)->EnableWindow(!IsMasterInstance() && fOkToUNC);
  1094. GetDlgItem(IDC_RADIO_REDIRECT)->EnableWindow(!IsMasterInstance());
  1095. GetDlgItem(IDC_STATIC_PATH_PROMPT)->EnableWindow(!IsMasterInstance());
  1096. GetDlgItem(IDC_EDIT_PATH)->EnableWindow(!IsMasterInstance() && HasAdminAccess());
  1097. // GetDlgItem(IDC_BUTTON_EDIT_PATH_TYPE)->EnableWindow(!IsMasterInstance());
  1098. //SetApplicationState();
  1099. m_fOriginallyUNC = (m_nPathType == RADIO_NETDIRECTORY);
  1100. //
  1101. // All changes from here on out need to be reflected.
  1102. //
  1103. m_fRecordChanges = TRUE;
  1104. return TRUE;
  1105. }
  1106. void
  1107. CW3DirectoryPage::OnDestroy()
  1108. {
  1109. int count = m_combo_Process.GetCount();
  1110. if (count != CB_ERR)
  1111. {
  1112. for (int i = 0; i < count; i++)
  1113. {
  1114. void * p = m_combo_Process.GetItemDataPtr(i);
  1115. LocalFree(p);
  1116. m_combo_Process.SetItemDataPtr(i, NULL);
  1117. }
  1118. }
  1119. }
  1120. /* virtual */
  1121. HRESULT
  1122. CW3DirectoryPage::FetchLoadedValues()
  1123. /*++
  1124. Routine Description:
  1125. Move configuration data from sheet to dialog controls
  1126. Arguments:
  1127. None
  1128. Return Value:
  1129. HRESULT
  1130. --*/
  1131. {
  1132. CError err;
  1133. m_strMetaRoot = QueryMetaPath();
  1134. BEGIN_META_DIR_READ(CW3Sheet)
  1135. //
  1136. // Use m_ notation because the message crackers require it
  1137. //
  1138. BOOL m_fDontLog;
  1139. FETCH_DIR_DATA_FROM_SHEET(m_strAlias);
  1140. FETCH_DIR_DATA_FROM_SHEET(m_strUserName);
  1141. FETCH_DIR_DATA_FROM_SHEET(m_strPassword);
  1142. FETCH_DIR_DATA_FROM_SHEET(m_strPath);
  1143. FETCH_DIR_DATA_FROM_SHEET(m_strRedirectPath);
  1144. FETCH_DIR_DATA_FROM_SHEET(m_dwAccessPerms);
  1145. FETCH_DIR_DATA_FROM_SHEET(m_dwDirBrowsing);
  1146. FETCH_DIR_DATA_FROM_SHEET(m_fDontLog);
  1147. FETCH_DIR_DATA_FROM_SHEET(m_fIndexed);
  1148. FETCH_DIR_DATA_FROM_SHEET(m_fExact);
  1149. FETCH_DIR_DATA_FROM_SHEET(m_fChild);
  1150. FETCH_DIR_DATA_FROM_SHEET(m_fPermanent);
  1151. m_fBrowsingAllowed = IS_FLAG_SET(m_dwDirBrowsing, MD_DIRBROW_ENABLED);
  1152. m_fRead = IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_READ);
  1153. m_fWrite = IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_WRITE);
  1154. m_fAuthor = IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_SOURCE);
  1155. m_fLogAccess = !m_fDontLog;
  1156. SaveAuthoringState();
  1157. if (!m_fIsAppRoot)
  1158. {
  1159. m_dwAppState = APPSTATUS_NOTDEFINED;
  1160. }
  1161. END_META_DIR_READ(err)
  1162. m_nPermissions = IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_EXECUTE)
  1163. ? COMBO_EXECUTE : IS_FLAG_SET(m_dwAccessPerms, MD_ACCESS_SCRIPT)
  1164. ? COMBO_SCRIPT : COMBO_NONE;
  1165. //
  1166. // Make sure we were passed the right home directory
  1167. // flag
  1168. //
  1169. ASSERT(IsMasterInstance()
  1170. || (m_fHome && !::lstrcmp(m_strAlias, g_cszRoot))
  1171. || (!m_fHome && ::lstrcmp(m_strAlias, g_cszRoot))
  1172. );
  1173. TRACEEOLID(QueryMetaPath());
  1174. BeginWaitCursor();
  1175. m_pApplication = new CIISApplication(QueryAuthInfo(), QueryMetaPath());
  1176. err = m_pApplication != NULL
  1177. ? m_pApplication->QueryResult() : ERROR_NOT_ENOUGH_MEMORY;
  1178. if (err.Win32Error() == ERROR_PATH_NOT_FOUND)
  1179. {
  1180. //
  1181. // No app information; that's ok in cases of file system directories
  1182. // that don't exist in the metabase yet.
  1183. //
  1184. err.Reset();
  1185. }
  1186. EndWaitCursor();
  1187. if (err.Succeeded())
  1188. {
  1189. //
  1190. // CODEWORK: RefreshAppState should be split up into two
  1191. // different methods: one that fetches the data, and one
  1192. // that moves the data to the UI controls on this page.
  1193. //
  1194. RefreshAppState();
  1195. }
  1196. return err;
  1197. }
  1198. /* virtual */
  1199. HRESULT
  1200. CW3DirectoryPage::SaveInfo()
  1201. /*++
  1202. Routine Description:
  1203. Save the information on this property page
  1204. Arguments:
  1205. None
  1206. Return Value:
  1207. Error return code
  1208. --*/
  1209. {
  1210. ASSERT(IsDirty());
  1211. TRACEEOLID("Saving W3 virtual directory page now...");
  1212. CError err;
  1213. SET_FLAG_IF(m_fBrowsingAllowed, m_dwDirBrowsing, MD_DIRBROW_ENABLED);
  1214. SET_FLAG_IF(m_fRead, m_dwAccessPerms, MD_ACCESS_READ);
  1215. SET_FLAG_IF(m_fWrite, m_dwAccessPerms, MD_ACCESS_WRITE);
  1216. SET_FLAG_IF(m_fAuthor, m_dwAccessPerms, MD_ACCESS_SOURCE);
  1217. SET_FLAG_IF((m_nPermissions == COMBO_EXECUTE), m_dwAccessPerms, MD_ACCESS_EXECUTE);
  1218. //
  1219. // script is set on EXECUTE as well "Execute (including script)"
  1220. //
  1221. SET_FLAG_IF(((m_nPermissions == COMBO_SCRIPT) || (m_nPermissions == COMBO_EXECUTE)),
  1222. m_dwAccessPerms, MD_ACCESS_SCRIPT);
  1223. BOOL m_fDontLog = !m_fLogAccess;
  1224. BOOL fUNC = (m_nPathType == RADIO_NETDIRECTORY);
  1225. if (m_fCompatibilityMode)
  1226. {
  1227. DWORD dwAppProtection = GetAppStateFromComboSelection();
  1228. if (dwAppProtection != m_dwAppProtection && m_fAppEnabled)
  1229. {
  1230. //
  1231. // Isolation state has changed; recreate the application
  1232. //
  1233. CError err2(m_pApplication->RefreshAppState());
  1234. if (err2.Succeeded())
  1235. {
  1236. err2 = m_pApplication->Create(m_strAppFriendlyName, dwAppProtection);
  1237. //
  1238. // Remember the new state, so we don't do this again
  1239. // the next time the guy hits "apply"
  1240. //
  1241. if (err2.Succeeded())
  1242. {
  1243. m_dwAppProtection = dwAppProtection;
  1244. }
  1245. }
  1246. err2.MessageBoxOnFailure();
  1247. }
  1248. }
  1249. BOOL fUserNameWritten = FALSE;
  1250. BeginWaitCursor();
  1251. BEGIN_META_DIR_WRITE(CW3Sheet)
  1252. INIT_DIR_DATA_MASK(m_dwAccessPerms, m_dwBitRangePermissions)
  1253. INIT_DIR_DATA_MASK(m_dwDirBrowsing, m_dwBitRangeDirBrowsing)
  1254. if (fUNC)
  1255. {
  1256. STORE_DIR_DATA_ON_SHEET(m_strUserName);
  1257. STORE_DIR_DATA_ON_SHEET(m_strPassword);
  1258. }
  1259. else
  1260. {
  1261. if (m_fOriginallyUNC)
  1262. {
  1263. FLAG_DIR_DATA_FOR_DELETION(MD_VR_USERNAME)
  1264. FLAG_DIR_DATA_FOR_DELETION(MD_VR_PASSWORD)
  1265. }
  1266. }
  1267. STORE_DIR_DATA_ON_SHEET(m_strPath)
  1268. STORE_DIR_DATA_ON_SHEET(m_fDontLog)
  1269. STORE_DIR_DATA_ON_SHEET(m_fIndexed)
  1270. STORE_DIR_DATA_ON_SHEET(m_fChild);
  1271. STORE_DIR_DATA_ON_SHEET(m_fExact);
  1272. STORE_DIR_DATA_ON_SHEET(m_fPermanent);
  1273. //
  1274. // CODEWORK: Not an elegant solution
  1275. //
  1276. if (m_nPathType == RADIO_REDIRECT)
  1277. {
  1278. pSheet->GetDirectoryProperties().MarkRedirAsInherit(!m_fChild);
  1279. STORE_DIR_DATA_ON_SHEET(m_strRedirectPath)
  1280. }
  1281. else
  1282. {
  1283. CString buf = m_strRedirectPath;
  1284. m_strRedirectPath.Empty();
  1285. STORE_DIR_DATA_ON_SHEET(m_strRedirectPath)
  1286. m_strRedirectPath = buf;
  1287. }
  1288. STORE_DIR_DATA_ON_SHEET(m_dwAccessPerms)
  1289. STORE_DIR_DATA_ON_SHEET(m_dwDirBrowsing)
  1290. END_META_DIR_WRITE(err)
  1291. if (err.Succeeded() && m_pApplication->IsEnabledApplication())
  1292. {
  1293. err = m_pApplication->WriteFriendlyName(m_strAppFriendlyName);
  1294. if (!m_fCompatibilityMode)
  1295. {
  1296. // get app pool id from the combo,
  1297. // check if it was changed and reassign to application
  1298. CString id;
  1299. int idx = m_combo_Process.GetCurSel();
  1300. ASSERT(idx != CB_ERR);
  1301. id = (LPCTSTR)m_combo_Process.GetItemDataPtr(idx);
  1302. m_pApplication->WritePoolId(id);
  1303. }
  1304. }
  1305. if (err.Succeeded())
  1306. {
  1307. //
  1308. // Save Defaults
  1309. //
  1310. SaveAuthoringState();
  1311. err = ((CW3Sheet *)GetSheet())->SetKeyType();
  1312. NotifyMMC();
  1313. }
  1314. EndWaitCursor();
  1315. return err;
  1316. }
  1317. BOOL
  1318. CW3DirectoryPage::CheckWriteAndExecWarning()
  1319. {
  1320. if (m_nPermissions == COMBO_EXECUTE && m_fWrite)
  1321. {
  1322. if (::AfxMessageBox(IDS_WRN_WRITE_EXEC, MB_YESNO | MB_DEFBUTTON2 ) != IDYES)
  1323. {
  1324. return FALSE;
  1325. }
  1326. }
  1327. OnItemChanged();
  1328. return TRUE;
  1329. }
  1330. void
  1331. CW3DirectoryPage::OnCheckRead()
  1332. {
  1333. m_fRead = !m_fRead;
  1334. SetAuthoringState(FALSE);
  1335. OnItemChanged();
  1336. }
  1337. void
  1338. CW3DirectoryPage::OnCheckWrite()
  1339. {
  1340. m_fWrite = !m_fWrite;
  1341. if (!CheckWriteAndExecWarning())
  1342. {
  1343. //
  1344. // Undo
  1345. //
  1346. m_fWrite = FALSE;
  1347. m_check_Write.SetCheck(m_fWrite);
  1348. }
  1349. else
  1350. {
  1351. SetAuthoringState(FALSE);
  1352. OnItemChanged();
  1353. }
  1354. }
  1355. void
  1356. CW3DirectoryPage::OnCheckAuthor()
  1357. {
  1358. m_fAuthor = !m_fAuthor;
  1359. SetAuthoringState(FALSE);
  1360. if (!CheckWriteAndExecWarning())
  1361. {
  1362. //
  1363. // Undo -- set script instead
  1364. //
  1365. m_combo_Permissions.SetCurSel(m_nPermissions = COMBO_SCRIPT);
  1366. }
  1367. OnItemChanged();
  1368. }
  1369. void
  1370. CW3DirectoryPage::OnSelchangeComboPermissions()
  1371. {
  1372. m_nPermissions = m_combo_Permissions.GetCurSel();
  1373. ASSERT(m_nPermissions >= COMBO_NONE && m_nPermissions <= COMBO_EXECUTE);
  1374. if (!CheckWriteAndExecWarning())
  1375. {
  1376. //
  1377. // Undo -- set script instead
  1378. //
  1379. m_combo_Permissions.SetCurSel(m_nPermissions = COMBO_SCRIPT);
  1380. }
  1381. OnItemChanged();
  1382. }
  1383. void
  1384. CW3DirectoryPage::OnButtonConnectAs()
  1385. {
  1386. BrowseUser();
  1387. }
  1388. void
  1389. CW3DirectoryPage::OnRadioDir()
  1390. {
  1391. ChangeTypeTo(RADIO_DIRECTORY);
  1392. }
  1393. void
  1394. CW3DirectoryPage::OnRadioUnc()
  1395. {
  1396. ChangeTypeTo(RADIO_NETDIRECTORY);
  1397. }
  1398. void
  1399. CW3DirectoryPage::OnRadioRedirect()
  1400. {
  1401. ChangeTypeTo(RADIO_REDIRECT);
  1402. }
  1403. void
  1404. CW3DirectoryPage::OnButtonCreateRemoveApp()
  1405. {
  1406. BeginWaitCursor();
  1407. CError err(m_pApplication->RefreshAppState());
  1408. if (m_fAppEnabled)
  1409. {
  1410. //
  1411. // App currently exists -- delete it
  1412. //
  1413. err = m_pApplication->Delete();
  1414. }
  1415. else
  1416. {
  1417. //
  1418. // Create new app in-proc
  1419. //
  1420. CString strAppName;
  1421. if (m_fHome)
  1422. {
  1423. //
  1424. // Use default name for application name
  1425. //
  1426. VERIFY(strAppName.LoadString(IDS_DEF_APP));
  1427. }
  1428. else
  1429. {
  1430. //
  1431. // Use name of the virtual directory for the
  1432. // application name
  1433. //
  1434. strAppName = m_strAlias;
  1435. }
  1436. //
  1437. // Attempt to create a pooled-proc by default; failing
  1438. // that if it's not supported, create it in proc
  1439. //
  1440. DWORD dwAppProtState =
  1441. m_pApplication->SupportsPooledProc() ?
  1442. CWamInterface::APP_POOLEDPROC : CWamInterface::APP_INPROC;
  1443. err = m_pApplication->Create(strAppName, dwAppProtState);
  1444. }
  1445. if (err.Succeeded())
  1446. {
  1447. RefreshAppState();
  1448. NotifyMMC();
  1449. }
  1450. //
  1451. // Move app data to the controls
  1452. //
  1453. UpdateData(FALSE);
  1454. EndWaitCursor();
  1455. err.MessageBoxOnFailure();
  1456. SetApplicationState();
  1457. }
  1458. void
  1459. CW3DirectoryPage::OnButtonUnloadApp()
  1460. {
  1461. ASSERT(m_dwAppState == APPSTATUS_RUNNING);
  1462. BeginWaitCursor();
  1463. CError err(m_pApplication->RefreshAppState());
  1464. if (err.Succeeded())
  1465. {
  1466. if (m_dwAppProtection == CWamInterface::APP_POOLEDPROC)
  1467. {
  1468. //
  1469. // Warn that everything in its process will get unloaded
  1470. //
  1471. if (!NoYesMessageBox(IDS_WRN_UNLOAD_POOP))
  1472. {
  1473. //
  1474. // Chickened out
  1475. //
  1476. return;
  1477. }
  1478. }
  1479. err = m_pApplication->Unload();
  1480. }
  1481. err.MessageBoxOnFailure();
  1482. RefreshAppState();
  1483. EndWaitCursor();
  1484. //
  1485. // Ensure that an enabled button will have focus.
  1486. //
  1487. m_button_CreateRemove.SetFocus();
  1488. SetApplicationState();
  1489. }
  1490. #include "..\AppConfig\AppConfig.h"
  1491. extern CInetmgrApp theApp;
  1492. void
  1493. CW3DirectoryPage::OnButtonConfiguration()
  1494. {
  1495. IIISAppConfig * pAppConfig = NULL;
  1496. CLSID clsID;
  1497. HRESULT hr;
  1498. if ( SUCCEEDED(hr = CLSIDFromProgID(OLESTR("AppConfig.IISAppConfig"), &clsID))
  1499. && SUCCEEDED(hr = ::CoCreateInstance(clsID, NULL, CLSCTX_ALL,
  1500. __uuidof(IIISAppConfig), (void **)&pAppConfig)))
  1501. {
  1502. CComAuthInfo * pAuth = QueryAuthInfo();
  1503. ASSERT(pAuth != NULL);
  1504. pAppConfig->put_ComputerName(pAuth->QueryServerName());
  1505. pAppConfig->put_MetaPath((LPTSTR)QueryMetaPath());
  1506. pAppConfig->put_HelpPath((LPTSTR)theApp.m_pszHelpFilePath);
  1507. pAppConfig->put_UserName(pAuth->QueryUserName());
  1508. pAppConfig->put_UserPassword(pAuth->QueryPassword());
  1509. DWORD version = MAKELONG(
  1510. GetSheet()->QueryMajorVersion(),
  1511. GetSheet()->QueryMinorVersion());
  1512. pAppConfig->put_ServiceVersion(version);
  1513. BOOL mode = ((CW3Sheet *)GetSheet())->InCompatibilityMode();
  1514. pAppConfig->put_ServiceCompatMode(mode);
  1515. pAppConfig->Run();
  1516. pAppConfig->Release();
  1517. }
  1518. }
  1519. void
  1520. CW3DirectoryPage::OnSelchangeComboProcess()
  1521. {
  1522. OnItemChanged();
  1523. }