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.

2123 lines
44 KiB

  1. /*++
  2. Copyright (c) 1994-2000 Microsoft Corporation
  3. Module Name :
  4. WebAddNew.cpp
  5. Abstract:
  6. Implementation for classes used in creation of new Web site and virtual directory
  7. Author:
  8. Sergei Antonov (sergeia)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. 12/12/2000 sergeia Initial creation
  13. --*/
  14. #include "stdafx.h"
  15. #include "common.h"
  16. #include "inetprop.h"
  17. #include "InetMgrApp.h"
  18. #include "iisobj.h"
  19. #include "wizard.h"
  20. #include "w3sht.h"
  21. #include "WebAddNew.h"
  22. #include <shlobjp.h>
  23. #ifdef _DEBUG
  24. #undef THIS_FILE
  25. static char BASED_CODE THIS_FILE[] = __FILE__;
  26. #endif
  27. #define new DEBUG_NEW
  28. #define DEF_PORT (80)
  29. #define DEF_SSL_PORT (443)
  30. #define MAX_ALIAS_NAME (240) // Ref Bug 241148
  31. extern CInetmgrApp theApp;
  32. HRESULT
  33. RebindInterface(OUT IN CMetaInterface * pInterface,
  34. OUT BOOL * pfContinue, IN DWORD dwCancelError);
  35. static TCHAR g_InvalidCharsHostHeader[] = _T(" ~`!@#$%^&*()_+={}[]|/\\?*:;\"\'<>,");
  36. static TCHAR g_InvalidCharsAlias[] = _T("/\\?*");
  37. static TCHAR g_InvalidCharsPath[] = _T("|<>/*?\"");
  38. HRESULT
  39. CIISMBNode::AddWebSite(
  40. const CSnapInObjectRootBase * pObj,
  41. DATA_OBJECT_TYPES type,
  42. DWORD * inst,
  43. DWORD verMajor,
  44. DWORD verMinor
  45. )
  46. {
  47. CWebWizSettings ws(
  48. dynamic_cast<CMetaKey *>(QueryInterface()),
  49. QueryMachineName()
  50. );
  51. ws.m_fNewSite = TRUE;
  52. ws.m_dwVersionMajor = verMajor;
  53. ws.m_dwVersionMinor = verMinor;
  54. CIISWizardSheet sheet(
  55. IDB_WIZ_WEB_LEFT, IDB_WIZ_WEB_HEAD);
  56. CIISWizardBookEnd pgWelcome(
  57. IDS_WEB_NEW_SITE_WELCOME,
  58. IDS_WEB_NEW_SITE_WIZARD,
  59. IDS_WEB_NEW_SITE_BODY
  60. );
  61. CWebWizDescription pgDescr(&ws);
  62. CWebWizBindings pgBindings(&ws);
  63. CWebWizPath pgHome(&ws, FALSE);
  64. CWebWizUserName pgUserName(&ws, FALSE);
  65. CWebWizPermissions pgPerms(&ws, FALSE);
  66. CIISWizardBookEnd pgCompletion(
  67. &ws.m_hrResult,
  68. IDS_WEB_NEW_SITE_SUCCESS,
  69. IDS_WEB_NEW_SITE_FAILURE,
  70. IDS_WEB_NEW_SITE_WIZARD
  71. );
  72. sheet.AddPage(&pgWelcome);
  73. sheet.AddPage(&pgDescr);
  74. sheet.AddPage(&pgBindings);
  75. sheet.AddPage(&pgHome);
  76. sheet.AddPage(&pgUserName);
  77. sheet.AddPage(&pgPerms);
  78. sheet.AddPage(&pgCompletion);
  79. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  80. if (sheet.DoModal() == IDCANCEL)
  81. {
  82. return CError::HResult(ERROR_CANCELLED);
  83. }
  84. if (inst != NULL /*&& SUCCEEDED(ws.m_hrResult)*/)
  85. {
  86. *inst = ws.m_dwInstance;
  87. }
  88. return ws.m_hrResult;
  89. }
  90. HRESULT
  91. CIISMBNode::AddWebVDir(
  92. const CSnapInObjectRootBase * pObj,
  93. DATA_OBJECT_TYPES type,
  94. CString& alias,
  95. DWORD verMajor,
  96. DWORD verMinor
  97. )
  98. {
  99. CWebWizSettings ws(
  100. dynamic_cast<CMetaKey *>(QueryInterface()),
  101. QueryMachineName()
  102. );
  103. CComBSTR path;
  104. BuildMetaPath(path);
  105. ws.m_strParent = path;
  106. ws.m_fNewSite = FALSE;
  107. ws.m_dwVersionMajor = verMajor;
  108. ws.m_dwVersionMinor = verMinor;
  109. CIISWizardSheet sheet(
  110. IDB_WIZ_WEB_LEFT, IDB_WIZ_WEB_HEAD);
  111. CIISWizardBookEnd pgWelcome(
  112. IDS_WEB_NEW_VDIR_WELCOME,
  113. IDS_WEB_NEW_VDIR_WIZARD,
  114. IDS_WEB_NEW_VDIR_BODY
  115. );
  116. CWebWizAlias pgAlias(&ws);
  117. CWebWizPath pgHome(&ws, TRUE);
  118. CWebWizUserName pgUserName(&ws, TRUE);
  119. CWebWizPermissions pgPerms(&ws, TRUE);
  120. CIISWizardBookEnd pgCompletion(
  121. &ws.m_hrResult,
  122. IDS_WEB_NEW_VDIR_SUCCESS,
  123. IDS_WEB_NEW_VDIR_FAILURE,
  124. IDS_WEB_NEW_VDIR_WIZARD
  125. );
  126. sheet.AddPage(&pgWelcome);
  127. sheet.AddPage(&pgAlias);
  128. sheet.AddPage(&pgHome);
  129. sheet.AddPage(&pgUserName);
  130. sheet.AddPage(&pgPerms);
  131. sheet.AddPage(&pgCompletion);
  132. CThemeContextActivator activator(theApp.GetFusionInitHandle());
  133. if (sheet.DoModal() == IDCANCEL)
  134. {
  135. return CError::HResult(ERROR_CANCELLED);
  136. }
  137. // if (SUCCEEDED(ws.m_hrResult))
  138. // {
  139. alias = ws.m_strAlias;
  140. // }
  141. return ws.m_hrResult;
  142. }
  143. CWebWizSettings::CWebWizSettings(
  144. IN CMetaKey * pMetaKey,
  145. IN LPCTSTR lpszServerName,
  146. IN DWORD dwInstance,
  147. IN LPCTSTR lpszParent
  148. )
  149. /*++
  150. Routine Description:
  151. Web Wizard Constructor
  152. Arguments:
  153. HANDLE hServer : Server handle
  154. LPCTSTR lpszService : Service name
  155. DWORD dwInstance : Instance number
  156. LPCTSTR lpszParent : Parent path
  157. Return Value:
  158. N/A
  159. --*/
  160. : m_hrResult(S_OK),
  161. m_pKey(pMetaKey),
  162. m_fUNC(FALSE),
  163. m_fRead(FALSE),
  164. m_fWrite(FALSE),
  165. m_fAllowAnonymous(TRUE),
  166. m_fDirBrowsing(FALSE),
  167. m_fScript(FALSE),
  168. m_fExecute(FALSE),
  169. m_fDelegation(TRUE), // on by default
  170. m_dwInstance(dwInstance)
  171. {
  172. ASSERT(lpszServerName != NULL);
  173. m_strServerName = lpszServerName;
  174. m_fLocal = IsServerLocal(m_strServerName);
  175. m_strService = SZ_MBN_WEB;
  176. if (lpszParent)
  177. {
  178. m_strParent = lpszParent;
  179. }
  180. }
  181. //
  182. // New Virtual Server Wizard Description Page
  183. //
  184. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  185. IMPLEMENT_DYNCREATE(CWebWizDescription, CIISWizardPage)
  186. CWebWizDescription::CWebWizDescription(
  187. IN OUT CWebWizSettings * pwsSettings
  188. )
  189. /*++
  190. Routine Description:
  191. Constructor
  192. Arguments:
  193. CString & strServerName : Server name
  194. Return Value:
  195. None
  196. --*/
  197. : CIISWizardPage(
  198. CWebWizDescription::IDD,
  199. IDS_WEB_NEW_SITE_WIZARD,
  200. HEADER_PAGE
  201. ),
  202. m_pSettings(pwsSettings)
  203. {
  204. #if 0 // Keep Class Wizard Happy
  205. //{{AFX_DATA_INIT(CWebWizDescription)
  206. m_strDescription = _T("");
  207. //}}AFX_DATA_INIT
  208. #endif // 0
  209. }
  210. CWebWizDescription::~CWebWizDescription()
  211. /*++
  212. Routine Description:
  213. Destructor
  214. Arguments:
  215. N/A
  216. Return Value:
  217. N/A
  218. --*/
  219. {
  220. }
  221. void
  222. CWebWizDescription::DoDataExchange(
  223. IN CDataExchange * pDX
  224. )
  225. /*++
  226. Routine Description:
  227. Initialise/Store control data
  228. Arguments:
  229. CDataExchange * pDX - DDX/DDV control structure
  230. Return Value:
  231. None
  232. --*/
  233. {
  234. CIISWizardPage::DoDataExchange(pDX);
  235. //{{AFX_DATA_MAP(CWebWizDescription)
  236. DDX_Control(pDX, IDC_EDIT_DESCRIPTION, m_edit_Description);
  237. //}}AFX_DATA_MAP
  238. }
  239. void
  240. CWebWizDescription::SetControlStates()
  241. /*++
  242. Routine Description:
  243. Set the state of the control data
  244. Arguments:
  245. None
  246. Return Value:
  247. None
  248. --*/
  249. {
  250. DWORD dwFlags = PSWIZB_BACK;
  251. if (m_edit_Description.GetWindowTextLength() > 0)
  252. {
  253. dwFlags |= PSWIZB_NEXT;
  254. }
  255. // for some reason, bug:206328 happens when we use SetWizardButtons, use SendMessage instead.
  256. //SetWizardButtons(dwFlags);
  257. ::SendMessage(::GetParent(m_hWnd), PSM_SETWIZBUTTONS, 0, dwFlags);
  258. }
  259. LRESULT
  260. CWebWizDescription::OnWizardNext()
  261. /*++
  262. Routine Description:
  263. 'next' handler. This is where validation is done,
  264. because DoDataExchange() gets called every time
  265. the dialog is exited, and this is not valid for
  266. wizards
  267. Arguments:
  268. None
  269. Return Value:
  270. 0 to proceed, -1 to fail
  271. --*/
  272. {
  273. if (!ValidateString(
  274. m_edit_Description,
  275. m_pSettings->m_strDescription,
  276. 1,
  277. MAX_PATH
  278. ))
  279. {
  280. return -1;
  281. }
  282. return CIISWizardPage::OnWizardNext();
  283. }
  284. //
  285. // Message Map
  286. //
  287. BEGIN_MESSAGE_MAP(CWebWizDescription, CIISWizardPage)
  288. //{{AFX_MSG_MAP(CWebWizDescription)
  289. ON_EN_CHANGE(IDC_EDIT_DESCRIPTION, OnChangeEditDescription)
  290. //}}AFX_MSG_MAP
  291. END_MESSAGE_MAP()
  292. //
  293. // Message Handlers
  294. //
  295. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  296. BOOL
  297. CWebWizDescription::OnSetActive()
  298. /*++
  299. Routine Description:
  300. Activation handler
  301. Arguments:
  302. None
  303. Return Value:
  304. TRUE for success, FALSE for failure
  305. --*/
  306. {
  307. SetControlStates();
  308. return CIISWizardPage::OnSetActive();
  309. }
  310. void
  311. CWebWizDescription::OnChangeEditDescription()
  312. /*++
  313. Routine Description:
  314. 'edit change' handler
  315. Arguments:
  316. None
  317. Return Value:
  318. None
  319. --*/
  320. {
  321. SetControlStates();
  322. }
  323. //
  324. // New Virtual Server Wizard Bindings Page
  325. //
  326. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  327. IMPLEMENT_DYNCREATE(CWebWizBindings, CIISWizardPage)
  328. CWebWizBindings::CWebWizBindings(
  329. IN OUT CWebWizSettings * pwsSettings,
  330. IN DWORD dwInstance
  331. )
  332. /*++
  333. Routine Description:
  334. Constructor
  335. Arguments:
  336. CString & strServerName : Server name
  337. Return Value:
  338. None
  339. --*/
  340. : CIISWizardPage(
  341. CWebWizBindings::IDD, IDS_WEB_NEW_SITE_WIZARD, HEADER_PAGE
  342. ),
  343. m_pSettings(pwsSettings),
  344. m_iaIpAddress(),
  345. m_oblIpAddresses(),
  346. m_dwInstance(dwInstance),
  347. m_bNextPage(FALSE)
  348. {
  349. //{{AFX_DATA_INIT(CWebWizBindings)
  350. m_nIpAddressSel = -1;
  351. m_nTCPPort = DEF_PORT;
  352. m_nSSLPort = DEF_SSL_PORT;
  353. m_strDomainName = _T("");
  354. //}}AFX_DATA_INIT
  355. BeginWaitCursor();
  356. m_fCertInstalled = ::IsCertInstalledOnServer(
  357. m_pSettings->m_pKey->QueryAuthInfo(),
  358. CMetabasePath(
  359. m_pSettings->m_strService,
  360. m_pSettings->m_dwInstance,
  361. m_pSettings->m_strParent,
  362. m_pSettings->m_strAlias
  363. )
  364. );
  365. EndWaitCursor();
  366. }
  367. CWebWizBindings::~CWebWizBindings()
  368. /*++
  369. Routine Description:
  370. Destructor
  371. Arguments:
  372. N/A
  373. Return Value:
  374. N/A
  375. --*/
  376. {
  377. }
  378. void
  379. CWebWizBindings::DoDataExchange(
  380. IN CDataExchange * pDX
  381. )
  382. /*++
  383. Routine Description:
  384. Initialise/Store control data
  385. Arguments:
  386. CDataExchange * pDX - DDX/DDV control structure
  387. Return Value:
  388. None
  389. --*/
  390. {
  391. CIISWizardPage::DoDataExchange(pDX);
  392. //{{AFX_DATA_MAP(CWebWizBindings)
  393. // This Needs to come before DDX_Text which will try to put text big number into small number
  394. DDV_MinMaxBalloon(pDX, IDC_EDIT_TCP_PORT, 1, 65535);
  395. DDX_TextBalloon(pDX, IDC_EDIT_TCP_PORT, m_nTCPPort);
  396. DDX_Control(pDX, IDC_COMBO_IP_ADDRESSES, m_combo_IpAddresses);
  397. DDX_Text(pDX, IDC_EDIT_DOMAIN_NAME, m_strDomainName);
  398. DDV_MaxCharsBalloon(pDX, m_strDomainName, MAX_PATH);
  399. if (pDX->m_bSaveAndValidate && m_bNextPage)
  400. {
  401. //
  402. // This code should be the same as in CMMMEditDlg::DoDataExchange
  403. //
  404. LPCTSTR p = m_strDomainName;
  405. while (p != NULL && *p != 0)
  406. {
  407. TCHAR c = towupper(*p);
  408. if ( (c >= _T('A') && c <= _T('Z'))
  409. || (c >= _T('0') && c <= _T('9'))
  410. || (c == _T('.') || c == _T('-'))
  411. )
  412. {
  413. p++;
  414. continue;
  415. }
  416. else
  417. {
  418. pDX->PrepareEditCtrl(IDC_EDIT_DOMAIN_NAME);
  419. DDV_ShowBalloonAndFail(pDX, IDS_WARNING_DOMAIN_NAME);
  420. }
  421. }
  422. // if (m_strDomainName.FindOneOf(g_InvalidCharsHostHeader) >= 0)
  423. // {
  424. // DDV_ShowBalloonAndFail(pDX, IDS_ERR_INVALID_HOSTHEADER_CHARS);
  425. // }
  426. // Check if the host header is valid
  427. if (!m_strDomainName.IsEmpty())
  428. {
  429. if (FAILED(IsValidHostHeader(m_strDomainName)))
  430. {
  431. pDX->PrepareEditCtrl(IDC_EDIT_DOMAIN_NAME);
  432. DDV_ShowBalloonAndFail(pDX, IDS_ERR_DOMAIN_NAME_INVALID);
  433. }
  434. }
  435. }
  436. //}}AFX_DATA_MAP
  437. if (m_fCertInstalled)
  438. {
  439. // This Needs to come before DDX_Text which will try to put text big number into small number
  440. DDV_MinMaxBalloon(pDX, IDC_EDIT_SSL_PORT, 1, 65535);
  441. DDX_TextBalloon(pDX, IDC_EDIT_SSL_PORT, m_nSSLPort);
  442. }
  443. if (pDX->m_bSaveAndValidate && m_nTCPPort == m_nSSLPort)
  444. {
  445. DDV_ShowBalloonAndFail(pDX, IDS_TCP_SSL_PART);
  446. }
  447. DDX_CBIndex(pDX, IDC_COMBO_IP_ADDRESSES, m_nIpAddressSel);
  448. if (pDX->m_bSaveAndValidate)
  449. {
  450. if (!FetchIpAddressFromCombo(m_combo_IpAddresses, m_oblIpAddresses, m_iaIpAddress))
  451. {
  452. pDX->Fail();
  453. }
  454. //
  455. // Build with empty host header
  456. //
  457. CInstanceProps::BuildBinding(
  458. m_pSettings->m_strBinding,
  459. m_iaIpAddress,
  460. m_nTCPPort,
  461. m_strDomainName
  462. );
  463. if (m_fCertInstalled)
  464. {
  465. CInstanceProps::BuildSecureBinding(
  466. m_pSettings->m_strSecureBinding,
  467. m_iaIpAddress,
  468. m_nSSLPort
  469. );
  470. }
  471. else
  472. {
  473. m_pSettings->m_strSecureBinding.Empty();
  474. }
  475. }
  476. }
  477. void
  478. CWebWizBindings::SetControlStates()
  479. /*++
  480. Routine Description:
  481. Set the state of the control data
  482. Arguments:
  483. None
  484. Return Value:
  485. None
  486. --*/
  487. {
  488. // for some reason, bug:206328 happens when we use SetWizardButtons, use SendMessage instead.
  489. //SetWizardButtons(PSWIZB_NEXT | PSWIZB_BACK);
  490. ::SendMessage(::GetParent(m_hWnd), PSM_SETWIZBUTTONS, 0, PSWIZB_NEXT | PSWIZB_BACK);
  491. BeginWaitCursor();
  492. m_fCertInstalled = ::IsCertInstalledOnServer(
  493. m_pSettings->m_pKey->QueryAuthInfo(),
  494. CMetabasePath(
  495. m_pSettings->m_strService,
  496. m_pSettings->m_dwInstance,
  497. m_pSettings->m_strParent,
  498. m_pSettings->m_strAlias
  499. )
  500. );
  501. EndWaitCursor();
  502. if (m_fCertInstalled)
  503. {
  504. GetDlgItem(IDC_STATIC_SSL_PORT)->ShowWindow(SW_SHOW);
  505. GetDlgItem(IDC_EDIT_SSL_PORT)->ShowWindow(SW_SHOW);
  506. }
  507. else
  508. {
  509. GetDlgItem(IDC_STATIC_SSL_PORT)->ShowWindow(SW_HIDE);
  510. GetDlgItem(IDC_EDIT_SSL_PORT)->ShowWindow(SW_HIDE);
  511. }
  512. GetDlgItem(IDC_STATIC_SSL_PORT)->EnableWindow(m_fCertInstalled);
  513. GetDlgItem(IDC_EDIT_SSL_PORT)->EnableWindow(m_fCertInstalled);
  514. }
  515. //
  516. // Message Map
  517. //
  518. BEGIN_MESSAGE_MAP(CWebWizBindings, CIISWizardPage)
  519. //{{AFX_MSG_MAP(CWebWizBindings)
  520. //}}AFX_MSG_MAP
  521. END_MESSAGE_MAP()
  522. //
  523. // Message Handlers
  524. //
  525. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  526. BOOL
  527. CWebWizBindings::OnInitDialog()
  528. /*++
  529. Routine Description:
  530. WM_INITDIALOG handler. Initialize the dialog.
  531. Arguments:
  532. None.
  533. Return Value:
  534. TRUE if no focus is to be set automatically, FALSE if the focus
  535. is already set.
  536. --*/
  537. {
  538. CIISWizardPage::OnInitDialog();
  539. BeginWaitCursor();
  540. PopulateComboWithKnownIpAddresses(
  541. m_pSettings->m_strServerName,
  542. m_combo_IpAddresses,
  543. m_iaIpAddress,
  544. m_oblIpAddresses,
  545. m_nIpAddressSel
  546. );
  547. EndWaitCursor();
  548. LimitInputDomainName(CONTROL_HWND(IDC_EDIT_DOMAIN_NAME ));
  549. return TRUE;
  550. }
  551. BOOL
  552. CWebWizBindings::OnSetActive()
  553. {
  554. m_bNextPage = FALSE;
  555. SetControlStates();
  556. return CIISWizardPage::OnSetActive();
  557. }
  558. LRESULT
  559. CWebWizBindings::OnWizardNext()
  560. {
  561. m_bNextPage = TRUE;
  562. return CIISWizardPage::OnWizardNext();
  563. }
  564. //
  565. // New Virtual Directory Wizard Alias Page
  566. //
  567. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  568. IMPLEMENT_DYNCREATE(CWebWizAlias, CIISWizardPage)
  569. CWebWizAlias::CWebWizAlias(
  570. IN OUT CWebWizSettings * pwsSettings
  571. )
  572. /*++
  573. Routine Description:
  574. Constructor
  575. Arguments:
  576. CString & strServerName : Server name
  577. Return Value:
  578. None
  579. --*/
  580. : CIISWizardPage(
  581. CWebWizAlias::IDD,
  582. IDS_WEB_NEW_VDIR_WIZARD,
  583. HEADER_PAGE
  584. ),
  585. m_pSettings(pwsSettings)
  586. {
  587. #if 0 // Keep Class Wizard Happy
  588. //{{AFX_DATA_INIT(CWebWizAlias)
  589. //}}AFX_DATA_INIT
  590. #endif // 0
  591. }
  592. CWebWizAlias::~CWebWizAlias()
  593. /*++
  594. Routine Description:
  595. Destructor
  596. Arguments:
  597. N/A
  598. Return Value:
  599. N/A
  600. --*/
  601. {
  602. }
  603. void
  604. CWebWizAlias::DoDataExchange(
  605. IN CDataExchange * pDX
  606. )
  607. /*++
  608. Routine Description:
  609. Initialise/Store control data
  610. Arguments:
  611. CDataExchange * pDX - DDX/DDV control structure
  612. Return Value:
  613. None
  614. --*/
  615. {
  616. CIISWizardPage::DoDataExchange(pDX);
  617. //{{AFX_DATA_MAP(CWebWizAlias)
  618. DDX_Control(pDX, IDC_EDIT_ALIAS, m_edit_Alias);
  619. //}}AFX_DATA_MAP
  620. }
  621. LRESULT
  622. CWebWizAlias::OnWizardNext()
  623. /*++
  624. Routine Description:
  625. prevent the / and \ characters from being in the alias name
  626. Arguments:
  627. None
  628. Return Value:
  629. None
  630. --*/
  631. {
  632. if (!ValidateString(
  633. m_edit_Alias,
  634. m_pSettings->m_strAlias,
  635. 1,
  636. MAX_ALIAS_NAME
  637. ))
  638. {
  639. return -1;
  640. }
  641. //
  642. // Find the illegal characters. If they exist tell
  643. // the user and don't go on.
  644. //
  645. if (m_pSettings->m_strAlias.FindOneOf(_T("/\\?*")) >= 0)
  646. {
  647. EditShowBalloon(m_edit_Alias.m_hWnd, IDS_ILLEGAL_ALIAS_CHARS);
  648. //
  649. // prevent the wizard page from changing
  650. //
  651. return -1;
  652. }
  653. //
  654. // Allow the wizard to continue
  655. //
  656. return CIISWizardPage::OnWizardNext();
  657. }
  658. void
  659. CWebWizAlias::SetControlStates()
  660. /*++
  661. Routine Description:
  662. Set the state of the control data
  663. Arguments:
  664. None
  665. Return Value:
  666. None
  667. --*/
  668. {
  669. DWORD dwFlags = PSWIZB_BACK;
  670. if (m_edit_Alias.GetWindowTextLength() > 0)
  671. {
  672. dwFlags |= PSWIZB_NEXT;
  673. }
  674. // for some reason, bug:206328 happens when we use SetWizardButtons, use SendMessage instead.
  675. //SetWizardButtons(dwFlags);
  676. ::SendMessage(::GetParent(m_hWnd), PSM_SETWIZBUTTONS, 0, dwFlags);
  677. }
  678. //
  679. // Message Map
  680. //
  681. BEGIN_MESSAGE_MAP(CWebWizAlias, CIISWizardPage)
  682. //{{AFX_MSG_MAP(CWebWizAlias)
  683. ON_EN_CHANGE(IDC_EDIT_ALIAS, OnChangeEditAlias)
  684. //}}AFX_MSG_MAP
  685. END_MESSAGE_MAP()
  686. //
  687. // Message Handlers
  688. //
  689. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  690. BOOL
  691. CWebWizAlias::OnSetActive()
  692. /*++
  693. Routine Description:
  694. Activation handler
  695. Arguments:
  696. None
  697. Return Value:
  698. TRUE for success, FALSE for failure
  699. --*/
  700. {
  701. SetControlStates();
  702. return CIISWizardPage::OnSetActive();
  703. }
  704. void
  705. CWebWizAlias::OnChangeEditAlias()
  706. /*++
  707. Routine Description:
  708. 'edit change' handler
  709. Arguments:
  710. None
  711. Return Value:
  712. None
  713. --*/
  714. {
  715. SetControlStates();
  716. }
  717. //
  718. // New Virtual Directory Wizard Path Page
  719. //
  720. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  721. IMPLEMENT_DYNCREATE(CWebWizPath, CIISWizardPage)
  722. CWebWizPath::CWebWizPath(
  723. IN OUT CWebWizSettings * pwsSettings,
  724. IN BOOL bVDir
  725. )
  726. /*++
  727. Routine Description:
  728. Constructor
  729. Arguments:
  730. CString & strServerName : Server name
  731. BOOL bVDir : TRUE for a VDIR, FALSE for an instance
  732. Return Value:
  733. None
  734. --*/
  735. : CIISWizardPage(
  736. (bVDir ? IDD_WEB_NEW_DIR_PATH : IDD_WEB_NEW_INST_HOME),
  737. (bVDir ? IDS_WEB_NEW_VDIR_WIZARD : IDS_WEB_NEW_SITE_WIZARD),
  738. HEADER_PAGE
  739. ),
  740. m_pSettings(pwsSettings)
  741. {
  742. #if 0 // Keep ClassWizard happy
  743. //{{AFX_DATA_INIT(CWebWizPath)
  744. //}}AFX_DATA_INIT
  745. #endif // 0
  746. }
  747. CWebWizPath::~CWebWizPath()
  748. /*++
  749. Routine Description:
  750. Destructor
  751. Arguments:
  752. N/A
  753. Return Value:
  754. N/A
  755. --*/
  756. {
  757. }
  758. void
  759. CWebWizPath::DoDataExchange(
  760. IN CDataExchange * pDX
  761. )
  762. /*++
  763. Routine Description:
  764. Initialise/Store control data
  765. Arguments:
  766. CDataExchange * pDX - DDX/DDV control structure
  767. Return Value:
  768. None
  769. --*/
  770. {
  771. CIISWizardPage::DoDataExchange(pDX);
  772. //{{AFX_DATA_MAP(CWebWizPath)
  773. DDX_Control(pDX, IDC_BUTTON_BROWSE, m_button_Browse);
  774. DDX_Control(pDX, IDC_EDIT_PATH, m_edit_Path);
  775. DDX_Check(pDX, IDC_CHECK_ALLOW_ANONYMOUS, m_pSettings->m_fAllowAnonymous);
  776. //}}AFX_DATA_MAP
  777. DDX_Text(pDX, IDC_EDIT_PATH, m_pSettings->m_strPath);
  778. DDV_MaxCharsBalloon(pDX, m_pSettings->m_strPath, MAX_PATH);
  779. }
  780. void
  781. CWebWizPath::SetControlStates()
  782. /*++
  783. Routine Description:
  784. Set the state of the control data
  785. Arguments:
  786. None
  787. Return Value:
  788. None
  789. --*/
  790. {
  791. DWORD dwFlags = PSWIZB_BACK;
  792. if (m_edit_Path.GetWindowTextLength() > 0)
  793. {
  794. dwFlags |= PSWIZB_NEXT;
  795. }
  796. // for some reason, bug:206328 happens when we use SetWizardButtons, use SendMessage instead.
  797. //SetWizardButtons(dwFlags);
  798. ::SendMessage(::GetParent(m_hWnd), PSM_SETWIZBUTTONS, 0, dwFlags);
  799. }
  800. //
  801. // Message Map
  802. //
  803. BEGIN_MESSAGE_MAP(CWebWizPath, CIISWizardPage)
  804. //{{AFX_MSG_MAP(CWebWizPath)
  805. ON_EN_CHANGE(IDC_EDIT_PATH, OnChangeEditPath)
  806. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  807. //}}AFX_MSG_MAP
  808. END_MESSAGE_MAP()
  809. //
  810. // Message Handlers
  811. //
  812. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  813. BOOL
  814. CWebWizPath::OnSetActive()
  815. /*++
  816. Routine Description:
  817. Activation handler
  818. Arguments:
  819. None
  820. Return Value:
  821. TRUE for success, FALSE for failure
  822. --*/
  823. {
  824. SetControlStates();
  825. return CIISWizardPage::OnSetActive();
  826. }
  827. LRESULT
  828. CWebWizPath::OnWizardNext()
  829. /*++
  830. Routine Description:
  831. 'next' handler. This is where validation is done,
  832. because DoDataExchange() gets called every time
  833. the dialog is exited, and this is not valid for
  834. wizards
  835. Arguments:
  836. None
  837. Return Value:
  838. 0 to proceed, -1 to fail
  839. --*/
  840. {
  841. CString csPathMunged = m_pSettings->m_strPath;
  842. if (!ValidateString(m_edit_Path, m_pSettings->m_strPath, 1, MAX_PATH))
  843. {
  844. return -1;
  845. }
  846. if (!PathIsValid(m_pSettings->m_strPath,TRUE))
  847. {
  848. m_edit_Path.SetSel(0,-1);
  849. m_edit_Path.SetFocus();
  850. EditShowBalloon(m_edit_Path.m_hWnd, IDS_ERR_BAD_PATH);
  851. return -1;
  852. }
  853. // -------------------------------------------------------------
  854. // Before we do anything we need to see if it's a "special" path
  855. //
  856. // Everything after this function must validate against csPathMunged...
  857. // this is because IsSpecialPath could have munged it...
  858. // -------------------------------------------------------------
  859. csPathMunged = m_pSettings->m_strPath;
  860. #ifdef SUPPORT_SLASH_SLASH_QUESTIONMARK_SLASH_TYPE_PATHS
  861. GetSpecialPathRealPath(0,m_pSettings->m_strPath,csPathMunged);
  862. #endif
  863. m_pSettings->m_fUNC = IsUNCName(csPathMunged);
  864. DWORD dwAllowed = CHKPATH_ALLOW_DEVICE_PATH;
  865. dwAllowed |= CHKPATH_ALLOW_UNC_PATH; // allow UNC type dir paths
  866. dwAllowed |= CHKPATH_ALLOW_UNC_SERVERSHARE_ONLY;
  867. // don't allow these type of paths commented out below:
  868. //dwAllowed |= CHKPATH_ALLOW_RELATIVE_PATH;
  869. //dwAllowed |= CHKPATH_ALLOW_UNC_SERVERNAME_ONLY;
  870. DWORD dwCharSet = CHKPATH_CHARSET_GENERAL;
  871. FILERESULT dwValidRet = MyValidatePath(csPathMunged,m_pSettings->m_fLocal,CHKPATH_WANT_DIR,dwAllowed,dwCharSet);
  872. if (FAILED(dwValidRet))
  873. {
  874. int ids = IDS_ERR_BAD_PATH;
  875. if (dwValidRet == CHKPATH_FAIL_NOT_ALLOWED_DIR_NOT_EXIST)
  876. {
  877. ids = IDS_ERR_PATH_NOT_FOUND;
  878. }
  879. m_edit_Path.SetSel(0,-1);
  880. m_edit_Path.SetFocus();
  881. EditShowBalloon(m_edit_Path.m_hWnd, IDS_ERR_PATH_NOT_FOUND);
  882. return -1;
  883. }
  884. return CIISWizardPage::OnWizardNext();
  885. }
  886. void
  887. CWebWizPath::OnChangeEditPath()
  888. /*++
  889. Routine Description:
  890. 'edit change' handler
  891. Arguments:
  892. None
  893. Return Value:
  894. None
  895. --*/
  896. {
  897. SetControlStates();
  898. }
  899. static int CALLBACK
  900. FileChooserCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
  901. {
  902. CWebWizPath * pThis = (CWebWizPath *)lpData;
  903. ASSERT(pThis != NULL);
  904. return pThis->BrowseForFolderCallback(hwnd, uMsg, lParam);
  905. }
  906. int
  907. CWebWizPath::BrowseForFolderCallback(HWND hwnd, UINT uMsg, LPARAM lParam)
  908. {
  909. switch (uMsg)
  910. {
  911. case BFFM_INITIALIZED:
  912. ASSERT(m_pPathTemp != NULL);
  913. if (::PathIsNetworkPath(m_pPathTemp))
  914. return 0;
  915. while (!::PathIsDirectory(m_pPathTemp))
  916. {
  917. if (0 == ::PathRemoveFileSpec(m_pPathTemp) && !::PathIsRoot(m_pPathTemp))
  918. {
  919. return 0;
  920. }
  921. DWORD attr = GetFileAttributes(m_pPathTemp);
  922. if ((attr & FILE_ATTRIBUTE_READONLY) == 0)
  923. break;
  924. }
  925. ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)m_pPathTemp);
  926. break;
  927. case BFFM_SELCHANGED:
  928. {
  929. LPITEMIDLIST pidl = (LPITEMIDLIST)lParam;
  930. TCHAR path[MAX_PATH];
  931. if (SHGetPathFromIDList(pidl, path))
  932. {
  933. ::SendMessage(hwnd, BFFM_ENABLEOK, 0, !PathIsNetworkPath(path));
  934. }
  935. }
  936. break;
  937. case BFFM_VALIDATEFAILED:
  938. break;
  939. }
  940. return 0;
  941. }
  942. void
  943. CWebWizPath::OnButtonBrowse()
  944. /*++
  945. Routine Description:
  946. Handle 'browsing' for directory path -- local system only
  947. Arguments:
  948. None
  949. Return Value:
  950. None
  951. --*/
  952. {
  953. ASSERT(m_pSettings->m_fLocal);
  954. BOOL bRes = FALSE;
  955. HRESULT hr;
  956. CString str;
  957. m_edit_Path.GetWindowText(str);
  958. if (SUCCEEDED(hr = CoInitialize(NULL)))
  959. {
  960. LPITEMIDLIST pidl = NULL;
  961. if (SUCCEEDED(SHGetFolderLocation(NULL, CSIDL_DRIVES, NULL, 0, &pidl)))
  962. {
  963. LPITEMIDLIST pidList = NULL;
  964. BROWSEINFO bi;
  965. TCHAR buf[MAX_PATH];
  966. ZeroMemory(&bi, sizeof(bi));
  967. int drive = PathGetDriveNumber(str);
  968. if (GetDriveType(PathBuildRoot(buf, drive)) == DRIVE_FIXED)
  969. {
  970. StrCpy(buf, str);
  971. }
  972. else
  973. {
  974. buf[0] = 0;
  975. }
  976. m_strBrowseTitle.LoadString(m_pSettings->m_fNewSite ?
  977. IDS_WEB_NEW_SITE_WIZARD : IDS_WEB_NEW_VDIR_WIZARD);
  978. bi.hwndOwner = m_hWnd;
  979. bi.pidlRoot = pidl;
  980. bi.pszDisplayName = m_pPathTemp = buf;
  981. bi.lpszTitle = m_strBrowseTitle;
  982. bi.ulFlags |= BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS/* | BIF_EDITBOX*/;
  983. bi.lpfn = FileChooserCallback;
  984. bi.lParam = (LPARAM)this;
  985. pidList = SHBrowseForFolder(&bi);
  986. if ( pidList != NULL
  987. && SHGetPathFromIDList(pidList, buf)
  988. )
  989. {
  990. str = buf;
  991. bRes = TRUE;
  992. }
  993. IMalloc * pMalloc;
  994. VERIFY(SUCCEEDED(SHGetMalloc(&pMalloc)));
  995. if (pidl != NULL)
  996. pMalloc->Free(pidl);
  997. pMalloc->Release();
  998. }
  999. CoUninitialize();
  1000. }
  1001. if (bRes)
  1002. {
  1003. m_edit_Path.SetWindowText(str);
  1004. SetControlStates();
  1005. }
  1006. }
  1007. BOOL
  1008. CWebWizPath::OnInitDialog()
  1009. /*++
  1010. Routine Description:
  1011. WM_INITDIALOG handler. Initialize the dialog.
  1012. Arguments:
  1013. None.
  1014. Return Value:
  1015. TRUE if no focus is to be set automatically, FALSE if the focus
  1016. is already set.
  1017. --*/
  1018. {
  1019. CIISWizardPage::OnInitDialog();
  1020. m_button_Browse.EnableWindow(m_pSettings->m_fLocal);
  1021. #ifdef SUPPORT_SLASH_SLASH_QUESTIONMARK_SLASH_TYPE_PATHS
  1022. LimitInputPath(CONTROL_HWND(IDC_EDIT_PATH),TRUE);
  1023. #else
  1024. LimitInputPath(CONTROL_HWND(IDC_EDIT_PATH),FALSE);
  1025. #endif
  1026. return TRUE;
  1027. }
  1028. //
  1029. // Wizard User/Password Page
  1030. //
  1031. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1032. IMPLEMENT_DYNCREATE(CWebWizUserName, CIISWizardPage)
  1033. CWebWizUserName::CWebWizUserName(
  1034. IN OUT CWebWizSettings * pwsSettings,
  1035. IN BOOL bVDir
  1036. )
  1037. : CIISWizardPage(
  1038. CWebWizUserName::IDD,
  1039. (bVDir ? IDS_WEB_NEW_VDIR_WIZARD : IDS_WEB_NEW_SITE_WIZARD),
  1040. HEADER_PAGE,
  1041. (bVDir ? USE_DEFAULT_CAPTION : IDS_WEB_NEW_SITE_SECURITY_TITLE),
  1042. (bVDir ? USE_DEFAULT_CAPTION : IDS_WEB_NEW_SITE_SECURITY_SUBTITLE)
  1043. ),
  1044. m_pSettings(pwsSettings)
  1045. {
  1046. }
  1047. CWebWizUserName::~CWebWizUserName()
  1048. {
  1049. }
  1050. void
  1051. CWebWizUserName::DoDataExchange(
  1052. IN CDataExchange * pDX
  1053. )
  1054. {
  1055. CIISWizardPage::DoDataExchange(pDX);
  1056. //{{AFX_DATA_MAP(CWebWizUserName)
  1057. DDX_Control(pDX, IDC_EDIT_USERNAME, m_edit_UserName);
  1058. DDX_Control(pDX, IDC_EDIT_PASSWORD, m_edit_Password);
  1059. DDX_Control(pDX, IDC_DELEGATION, m_chk_Delegation);
  1060. DDX_Check(pDX, IDC_DELEGATION, m_pSettings->m_fDelegation);
  1061. //}}AFX_DATA_MAP
  1062. //
  1063. // Private DDX/DDV Routines
  1064. //
  1065. DDX_Text(pDX, IDC_EDIT_USERNAME, m_pSettings->m_strUserName);
  1066. if (pDX->m_bSaveAndValidate && !m_pSettings->m_fDelegation)
  1067. {
  1068. DDV_MaxCharsBalloon(pDX, m_pSettings->m_strUserName, UNLEN);
  1069. }
  1070. //
  1071. // Some people have a tendency to add "\\" before
  1072. // the computer name in user accounts. Fix this here.
  1073. //
  1074. m_pSettings->m_strUserName.TrimLeft();
  1075. while (*m_pSettings->m_strUserName == '\\')
  1076. {
  1077. m_pSettings->m_strUserName = m_pSettings->m_strUserName.Mid(2);
  1078. }
  1079. if (!m_pSettings->m_fDelegation && !m_fMovingBack)
  1080. {
  1081. DDX_Password_SecuredString(pDX, IDC_EDIT_PASSWORD, m_pSettings->m_strPassword, g_lpszDummyPassword);
  1082. if (pDX->m_bSaveAndValidate)
  1083. {
  1084. //DDV_MaxCharsBalloon(pDX, m_pSettings->m_strPassword, PWLEN);
  1085. DDV_MaxCharsBalloon_SecuredString(pDX, m_pSettings->m_strPassword, PWLEN);
  1086. }
  1087. }
  1088. }
  1089. void
  1090. CWebWizUserName::SetControlStates()
  1091. {
  1092. DWORD dwFlags = PSWIZB_BACK;
  1093. BOOL bEnable = BST_CHECKED != m_chk_Delegation.GetCheck();
  1094. if (m_edit_UserName.GetWindowTextLength() > 0 || !bEnable)
  1095. {
  1096. dwFlags |= PSWIZB_NEXT;
  1097. }
  1098. // for some reason, bug:206328 happens when we use SetWizardButtons, use SendMessage instead.
  1099. //SetWizardButtons(dwFlags);
  1100. ::SendMessage(::GetParent(m_hWnd), PSM_SETWIZBUTTONS, 0, dwFlags);
  1101. m_edit_UserName.EnableWindow(bEnable);
  1102. m_edit_Password.EnableWindow(bEnable);
  1103. GetDlgItem(IDC_BUTTON_BROWSE_USERS)->EnableWindow(bEnable);
  1104. }
  1105. //
  1106. // Message Map
  1107. //
  1108. BEGIN_MESSAGE_MAP(CWebWizUserName, CIISWizardPage)
  1109. //{{AFX_MSG_MAP(CWebWizUserName)
  1110. ON_BN_CLICKED(IDC_BUTTON_BROWSE_USERS, OnButtonBrowseUsers)
  1111. ON_EN_CHANGE(IDC_EDIT_USERNAME, OnChangeEditUsername)
  1112. ON_BN_CLICKED(IDC_BUTTON_CHECK_PASSWORD, OnButtonCheckPassword)
  1113. ON_BN_CLICKED(IDC_DELEGATION, OnCheckDelegation)
  1114. //}}AFX_MSG_MAP
  1115. END_MESSAGE_MAP()
  1116. BOOL
  1117. CWebWizUserName::OnSetActive()
  1118. {
  1119. if (!m_pSettings->m_fUNC)
  1120. {
  1121. return 0;
  1122. }
  1123. BOOL bRes = CIISWizardPage::OnSetActive();
  1124. SetControlStates();
  1125. return bRes;
  1126. }
  1127. BOOL
  1128. CWebWizUserName::OnInitDialog()
  1129. {
  1130. CIISWizardPage::OnInitDialog();
  1131. return TRUE;
  1132. }
  1133. LRESULT
  1134. CWebWizUserName::OnWizardNext()
  1135. {
  1136. m_fMovingBack = FALSE;
  1137. if (BST_CHECKED != m_chk_Delegation.GetCheck())
  1138. {
  1139. if (!ValidateString(m_edit_UserName, m_pSettings->m_strUserName, 1, UNLEN))
  1140. {
  1141. return -1;
  1142. }
  1143. }
  1144. return CIISWizardPage::OnWizardNext();
  1145. }
  1146. LRESULT
  1147. CWebWizUserName::OnWizardBack()
  1148. {
  1149. m_fMovingBack = TRUE;
  1150. return CIISWizardPage::OnWizardNext();
  1151. }
  1152. void
  1153. CWebWizUserName::OnButtonBrowseUsers()
  1154. {
  1155. CString str;
  1156. if (GetIUsrAccount(m_pSettings->m_strServerName, this, str))
  1157. {
  1158. //
  1159. // If a name was selected, blank
  1160. // out the password
  1161. //
  1162. m_edit_UserName.SetWindowText(str);
  1163. m_edit_Password.SetFocus();
  1164. }
  1165. }
  1166. void
  1167. CWebWizUserName::OnChangeEditUsername()
  1168. {
  1169. m_edit_Password.SetWindowText(_T(""));
  1170. SetControlStates();
  1171. }
  1172. void
  1173. CWebWizUserName::OnCheckDelegation()
  1174. {
  1175. SetControlStates();
  1176. }
  1177. void
  1178. CWebWizUserName::OnButtonCheckPassword()
  1179. {
  1180. if (!UpdateData(TRUE))
  1181. {
  1182. return;
  1183. }
  1184. CString csTempPassword = m_pSettings->m_strPassword;
  1185. CError err(CComAuthInfo::VerifyUserPassword(
  1186. m_pSettings->m_strUserName,
  1187. csTempPassword
  1188. ));
  1189. if (!err.MessageBoxOnFailure(m_hWnd))
  1190. {
  1191. DoHelpMessageBox(m_hWnd,IDS_PASSWORD_OK, MB_APPLMODAL | MB_OK | MB_ICONINFORMATION, 0);
  1192. }
  1193. }
  1194. //
  1195. // Wizard Permissions Page
  1196. //
  1197. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1198. IMPLEMENT_DYNCREATE(CWebWizPermissions, CIISWizardPage)
  1199. CWebWizPermissions::CWebWizPermissions(
  1200. IN OUT CWebWizSettings * pwsSettings,
  1201. IN BOOL bVDir
  1202. )
  1203. /*++
  1204. Routine Description:
  1205. Constructor
  1206. Arguments:
  1207. CString & strServerName : Server name
  1208. BOOL bVDir : TRUE if this is a vdir page,
  1209. FALSE for instance
  1210. Return Value:
  1211. None
  1212. --*/
  1213. : CIISWizardPage(
  1214. CWebWizPermissions::IDD,
  1215. (bVDir ? IDS_WEB_NEW_VDIR_WIZARD : IDS_WEB_NEW_SITE_WIZARD),
  1216. HEADER_PAGE,
  1217. (bVDir ? USE_DEFAULT_CAPTION : IDS_WEB_NEW_SITE_PERMS_TITLE),
  1218. (bVDir ? USE_DEFAULT_CAPTION : IDS_WEB_NEW_SITE_PERMS_SUBTITLE)
  1219. ),
  1220. m_bVDir(bVDir),
  1221. m_pSettings(pwsSettings)
  1222. {
  1223. //{{AFX_DATA_INIT(CWebWizPermissions)
  1224. //}}AFX_DATA_INIT
  1225. m_pSettings->m_fDirBrowsing = FALSE;
  1226. m_pSettings->m_fRead = TRUE;
  1227. m_pSettings->m_fScript = TRUE;
  1228. m_pSettings->m_fWrite = FALSE;
  1229. m_pSettings->m_fExecute = FALSE;
  1230. }
  1231. CWebWizPermissions::~CWebWizPermissions()
  1232. /*++
  1233. Routine Description:
  1234. Destructor
  1235. Arguments:
  1236. None
  1237. Return Value:
  1238. None
  1239. --*/
  1240. {
  1241. }
  1242. void
  1243. CWebWizPermissions::DoDataExchange(
  1244. IN CDataExchange * pDX
  1245. )
  1246. /*++
  1247. Routine Description:
  1248. Initialise/Store control data
  1249. Arguments:
  1250. CDataExchange * pDX - DDX/DDV control structure
  1251. Return Value:
  1252. None
  1253. --*/
  1254. {
  1255. CIISWizardPage::DoDataExchange(pDX);
  1256. //{{AFX_DATA_MAP(CWebWizPermissions)
  1257. //}}AFX_DATA_MAP
  1258. DDX_Check(pDX, IDC_CHECK_DIRBROWS, m_pSettings->m_fDirBrowsing);
  1259. DDX_Check(pDX, IDC_CHECK_READ, m_pSettings->m_fRead);
  1260. DDX_Check(pDX, IDC_CHECK_SCRIPT, m_pSettings->m_fScript);
  1261. DDX_Check(pDX, IDC_CHECK_WRITE, m_pSettings->m_fWrite);
  1262. DDX_Check(pDX, IDC_CHECK_EXECUTE, m_pSettings->m_fExecute);
  1263. }
  1264. void
  1265. CWebWizPermissions::SetControlStates()
  1266. /*++
  1267. Routine Description:
  1268. Set the state of the control data
  1269. Arguments:
  1270. None
  1271. Return Value:
  1272. None
  1273. --*/
  1274. {
  1275. // for some reason, bug:206328 happens when we use SetWizardButtons, use SendMessage instead.
  1276. //SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  1277. ::SendMessage(::GetParent(m_hWnd), PSM_SETWIZBUTTONS, 0, PSWIZB_BACK | PSWIZB_NEXT);
  1278. }
  1279. //
  1280. // Message Map
  1281. //
  1282. BEGIN_MESSAGE_MAP(CWebWizPermissions, CIISWizardPage)
  1283. //{{AFX_MSG_MAP(CWebWizPermissions)
  1284. //}}AFX_MSG_MAP
  1285. END_MESSAGE_MAP()
  1286. //
  1287. // Message Handlers
  1288. //
  1289. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1290. BOOL
  1291. CWebWizPermissions::OnSetActive()
  1292. /*++
  1293. Routine Description:
  1294. Activation handler
  1295. Arguments:
  1296. None
  1297. Return Value:
  1298. TRUE for success, FALSE for failure
  1299. --*/
  1300. {
  1301. SetControlStates();
  1302. return CIISWizardPage::OnSetActive();
  1303. }
  1304. LRESULT
  1305. CWebWizPermissions::OnWizardNext()
  1306. /*++
  1307. Routine Description:
  1308. 'next' handler. Complete the wizard
  1309. Arguments:
  1310. None
  1311. Return Value:
  1312. 0 to proceed, -1 to fail
  1313. --*/
  1314. {
  1315. if (!UpdateData(TRUE))
  1316. {
  1317. return -1;
  1318. }
  1319. ASSERT(m_pSettings != NULL);
  1320. CWaitCursor wait;
  1321. //
  1322. // Build permissions DWORD
  1323. //
  1324. DWORD dwPermissions = 0L;
  1325. DWORD dwAuthFlags = MD_AUTH_NT;
  1326. DWORD dwDirBrowsing =
  1327. MD_DIRBROW_SHOW_DATE |
  1328. MD_DIRBROW_SHOW_TIME |
  1329. MD_DIRBROW_SHOW_SIZE |
  1330. MD_DIRBROW_SHOW_EXTENSION |
  1331. MD_DIRBROW_LONG_DATE |
  1332. MD_DIRBROW_LOADDEFAULT;
  1333. if (m_pSettings->m_fWrite && m_pSettings->m_fExecute)
  1334. {
  1335. if (IDNO == ::AfxMessageBox(IDS_EXECUTE_AND_WRITE_WARNING, MB_YESNO))
  1336. return -1;
  1337. }
  1338. SET_FLAG_IF(m_pSettings->m_fRead, dwPermissions, MD_ACCESS_READ);
  1339. SET_FLAG_IF(m_pSettings->m_fWrite, dwPermissions, MD_ACCESS_WRITE);
  1340. SET_FLAG_IF(m_pSettings->m_fScript || m_pSettings->m_fExecute,
  1341. dwPermissions, MD_ACCESS_SCRIPT);
  1342. SET_FLAG_IF(m_pSettings->m_fExecute, dwPermissions, MD_ACCESS_EXECUTE);
  1343. SET_FLAG_IF(m_pSettings->m_fDirBrowsing, dwDirBrowsing, MD_DIRBROW_ENABLED);
  1344. SET_FLAG_IF(m_pSettings->m_fAllowAnonymous, dwAuthFlags, MD_AUTH_ANONYMOUS);
  1345. if (m_bVDir)
  1346. {
  1347. //
  1348. // First see if by any chance this name already exists
  1349. //
  1350. CError err;
  1351. BOOL fRepeat;
  1352. CMetabasePath target(FALSE,
  1353. m_pSettings->m_strParent, m_pSettings->m_strAlias);
  1354. CChildNodeProps node(
  1355. m_pSettings->m_pKey->QueryAuthInfo(),
  1356. target);
  1357. do
  1358. {
  1359. fRepeat = FALSE;
  1360. err = node.LoadData();
  1361. if (err.Win32Error() == RPC_S_SERVER_UNAVAILABLE)
  1362. {
  1363. err = RebindInterface(
  1364. m_pSettings->m_pKey,
  1365. &fRepeat,
  1366. ERROR_CANCELLED
  1367. );
  1368. }
  1369. } while (fRepeat);
  1370. if (err.Succeeded())
  1371. {
  1372. BOOL fNotUnique = TRUE;
  1373. //
  1374. // If the item existed without a VrPath, we'll just blow it
  1375. // away, as a vdir takes presedence over a directory/file.
  1376. //
  1377. if (node.GetPath().IsEmpty())
  1378. {
  1379. err = CChildNodeProps::Delete(
  1380. m_pSettings->m_pKey,
  1381. m_pSettings->m_strParent,
  1382. m_pSettings->m_strAlias
  1383. );
  1384. fNotUnique = !err.Succeeded();
  1385. }
  1386. //
  1387. // This one already exists and exists as a virtual
  1388. // directory, so away with it.
  1389. //
  1390. if (fNotUnique)
  1391. {
  1392. DoHelpMessageBox(m_hWnd,IDS_ERR_ALIAS_NOT_UNIQUE, MB_APPLMODAL | MB_OK | MB_ICONEXCLAMATION, 0);
  1393. return IDD_WEB_NEW_DIR_ALIAS;
  1394. }
  1395. }
  1396. //
  1397. // Create new vdir
  1398. //
  1399. do
  1400. {
  1401. fRepeat = FALSE;
  1402. CString csTempPassword;
  1403. m_pSettings->m_strPassword.CopyTo(csTempPassword);
  1404. err = CChildNodeProps::Add(
  1405. m_pSettings->m_pKey,
  1406. m_pSettings->m_strParent,
  1407. m_pSettings->m_strAlias, // Desired alias name
  1408. m_pSettings->m_strAlias, // Name returned here (may differ)
  1409. &dwPermissions, // Permissions
  1410. &dwDirBrowsing, // dir browsing
  1411. m_pSettings->m_strPath, // Physical path of this directory
  1412. (m_pSettings->m_fUNC && !m_pSettings->m_fDelegation ?
  1413. (LPCTSTR)m_pSettings->m_strUserName : NULL),
  1414. (m_pSettings->m_fUNC && !m_pSettings->m_fDelegation ?
  1415. (LPCTSTR)csTempPassword : NULL),
  1416. TRUE // Name must be unique
  1417. );
  1418. if (err.Win32Error() == RPC_S_SERVER_UNAVAILABLE)
  1419. {
  1420. err = RebindInterface(m_pSettings->m_pKey, &fRepeat, ERROR_CANCELLED);
  1421. }
  1422. } while (fRepeat);
  1423. m_pSettings->m_hrResult = err;
  1424. //
  1425. // Create an (in-proc) application on the new directory if
  1426. // script or execute was requested.
  1427. //
  1428. if (SUCCEEDED(m_pSettings->m_hrResult))
  1429. {
  1430. if (m_pSettings->m_fExecute || m_pSettings->m_fScript)
  1431. {
  1432. CMetabasePath app_path(FALSE,
  1433. m_pSettings->m_strParent, m_pSettings->m_strAlias);
  1434. CIISApplication app(
  1435. m_pSettings->m_pKey->QueryAuthInfo(), app_path);
  1436. m_pSettings->m_hrResult = app.QueryResult();
  1437. //
  1438. // This would make no sense...
  1439. //
  1440. // ASSERT(!app.IsEnabledApplication());
  1441. if (SUCCEEDED(m_pSettings->m_hrResult))
  1442. {
  1443. //
  1444. // Attempt to create a pooled-proc by default; failing
  1445. // that if it's not supported, create it in proc
  1446. //
  1447. DWORD dwAppProtState = app.SupportsPooledProc()
  1448. ? CWamInterface::APP_POOLEDPROC
  1449. : CWamInterface::APP_INPROC;
  1450. m_pSettings->m_hrResult = app.Create(
  1451. m_pSettings->m_strAlias,
  1452. dwAppProtState
  1453. );
  1454. }
  1455. }
  1456. if (SUCCEEDED(m_pSettings->m_hrResult))
  1457. {
  1458. if (m_pSettings->m_dwVersionMajor >= 6)
  1459. {
  1460. CMetabasePath path(FALSE,
  1461. m_pSettings->m_strParent, m_pSettings->m_strAlias);
  1462. CMetaKey mk(m_pSettings->m_pKey, path.QueryMetaPath(), METADATA_PERMISSION_WRITE);
  1463. err = mk.QueryResult();
  1464. m_pSettings->m_hrResult = err;
  1465. }
  1466. }
  1467. }
  1468. }
  1469. else
  1470. {
  1471. //
  1472. // Create new instance
  1473. //
  1474. CError err;
  1475. BOOL fRepeat;
  1476. do
  1477. {
  1478. fRepeat = FALSE;
  1479. CString csTempPassword;
  1480. m_pSettings->m_strPassword.CopyTo(csTempPassword);
  1481. err = CInstanceProps::Add(
  1482. m_pSettings->m_pKey,
  1483. m_pSettings->m_strService, // Service name
  1484. m_pSettings->m_strPath, // Physical path of this directory
  1485. (m_pSettings->m_fUNC && !m_pSettings->m_fDelegation ?
  1486. (LPCTSTR)m_pSettings->m_strUserName : NULL),
  1487. (m_pSettings->m_fUNC && !m_pSettings->m_fDelegation ?
  1488. (LPCTSTR)csTempPassword : NULL),
  1489. m_pSettings->m_strDescription,
  1490. m_pSettings->m_strBinding,
  1491. m_pSettings->m_strSecureBinding,
  1492. &dwPermissions,
  1493. &dwDirBrowsing, // dir browsing
  1494. &dwAuthFlags, // Auth flags
  1495. &m_pSettings->m_dwInstance
  1496. );
  1497. if (err.Win32Error() == RPC_S_SERVER_UNAVAILABLE)
  1498. {
  1499. err = RebindInterface(m_pSettings->m_pKey, &fRepeat, ERROR_CANCELLED);
  1500. }
  1501. } while (fRepeat);
  1502. m_pSettings->m_hrResult = err;
  1503. if (SUCCEEDED(m_pSettings->m_hrResult))
  1504. {
  1505. //
  1506. // Create an (in-proc) application on the new instance's home root
  1507. //
  1508. CMetabasePath app_path(SZ_MBN_WEB,
  1509. m_pSettings->m_dwInstance,
  1510. SZ_MBN_ROOT);
  1511. CIISApplication app(
  1512. m_pSettings->m_pKey->QueryAuthInfo(),
  1513. app_path
  1514. );
  1515. m_pSettings->m_hrResult = app.QueryResult();
  1516. //
  1517. // This would make no sense...
  1518. //
  1519. // ASSERT(!app.IsEnabledApplication());
  1520. if (SUCCEEDED(m_pSettings->m_hrResult))
  1521. {
  1522. //
  1523. // Create in-proc
  1524. //
  1525. CString strAppName;
  1526. VERIFY(strAppName.LoadString(IDS_DEF_APP));
  1527. //
  1528. // Attempt to create a pooled-proc by default; failing
  1529. // that if it's not supported, create it in proc
  1530. //
  1531. DWORD dwAppProtState = app.SupportsPooledProc()
  1532. ? CWamInterface::APP_POOLEDPROC
  1533. : CWamInterface::APP_INPROC;
  1534. m_pSettings->m_hrResult = app.Create(
  1535. strAppName,
  1536. dwAppProtState
  1537. );
  1538. }
  1539. if (SUCCEEDED(m_pSettings->m_hrResult))
  1540. {
  1541. // should start it up for iis5 remote admin case
  1542. if (m_pSettings->m_dwVersionMajor >= 5)
  1543. {
  1544. CMetabasePath path(m_pSettings->m_strService, m_pSettings->m_dwInstance);
  1545. // Start new site
  1546. CInstanceProps ip(m_pSettings->m_pKey->QueryAuthInfo(), path);
  1547. err = ip.LoadData();
  1548. if (err.Succeeded())
  1549. {
  1550. if (ip.m_dwState != MD_SERVER_STATE_STARTED)
  1551. {
  1552. m_pSettings->m_hrResult = ip.ChangeState(MD_SERVER_COMMAND_START);
  1553. }
  1554. }
  1555. else
  1556. {
  1557. m_pSettings->m_hrResult = err;
  1558. }
  1559. }
  1560. }
  1561. }
  1562. }
  1563. return CIISWizardPage::OnWizardNext();
  1564. }