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.

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