Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1946 lines
32 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name :
  4. wizard.cpp
  5. Abstract:
  6. WWW Wizards pages
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "w3scfg.h"
  18. #include "dirbrows.h"
  19. #include "wizard.h"
  20. #define DEF_PORT (80)
  21. #define DEF_SSL_PORT (443)
  22. #define MAX_ALIAS_NAME (240) // Ref Bug 241148
  23. CIISWebWizSettings::CIISWebWizSettings(
  24. IN HANDLE hServer,
  25. IN LPCTSTR lpszService,
  26. IN DWORD dwInstance, OPTIONAL
  27. IN LPCTSTR lpszParent OPTIONAL
  28. )
  29. /*++
  30. Routine Description:
  31. Web Wizard Constructor
  32. Arguments:
  33. HANDLE hServer : Server handle
  34. LPCTSTR lpszService : Service name
  35. DWORD dwInstance : Instance number
  36. LPCTSTR lpszParent : Parent path
  37. Return Value:
  38. N/A
  39. --*/
  40. : m_hrResult(S_OK),
  41. m_pKey(NULL),
  42. m_fLocal(FALSE),
  43. m_fUNC(FALSE),
  44. m_fRead(FALSE),
  45. m_fWrite(FALSE),
  46. m_fAllowAnonymous(TRUE),
  47. m_fDirBrowsing(FALSE),
  48. m_fScript(FALSE),
  49. m_fExecute(FALSE),
  50. m_strServerName(),
  51. m_strService(),
  52. m_strParent(),
  53. m_dwInstance(dwInstance)
  54. {
  55. m_pKey = GetMetaKeyFromHandle(hServer);
  56. LPCTSTR lpszServer = GetServerNameFromHandle(hServer);
  57. ASSERT(lpszServer != NULL);
  58. m_strServerName = lpszServer;
  59. m_fLocal = IsServerLocal(m_strServerName);
  60. if (lpszService)
  61. {
  62. m_strService = lpszService;
  63. }
  64. if (lpszParent)
  65. {
  66. m_strParent = lpszParent;
  67. }
  68. }
  69. //
  70. // New Virtual Server Wizard Description Page
  71. //
  72. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  73. IMPLEMENT_DYNCREATE(CVDWPDescription, CIISWizardPage)
  74. CVDWPDescription::CVDWPDescription(
  75. IN OUT CIISWebWizSettings * pwsSettings
  76. )
  77. /*++
  78. Routine Description:
  79. Constructor
  80. Arguments:
  81. CString & strServerName : Server name
  82. Return Value:
  83. None
  84. --*/
  85. : CIISWizardPage(
  86. CVDWPDescription::IDD, // Template
  87. IDS_NEW_SITE_WIZARD, // Caption
  88. HEADER_PAGE
  89. ),
  90. m_pwsSettings(pwsSettings)
  91. {
  92. #if 0 // Keep Class Wizard Happy
  93. //{{AFX_DATA_INIT(CVDWPDescription)
  94. m_strDescription = _T("");
  95. //}}AFX_DATA_INIT
  96. #endif // 0
  97. }
  98. CVDWPDescription::~CVDWPDescription()
  99. /*++
  100. Routine Description:
  101. Destructor
  102. Arguments:
  103. N/A
  104. Return Value:
  105. N/A
  106. --*/
  107. {
  108. }
  109. void
  110. CVDWPDescription::DoDataExchange(
  111. IN CDataExchange * pDX
  112. )
  113. /*++
  114. Routine Description:
  115. Initialise/Store control data
  116. Arguments:
  117. CDataExchange * pDX - DDX/DDV control structure
  118. Return Value:
  119. None
  120. --*/
  121. {
  122. CIISWizardPage::DoDataExchange(pDX);
  123. //{{AFX_DATA_MAP(CVDWPDescription)
  124. DDX_Control(pDX, IDC_EDIT_DESCRIPTION, m_edit_Description);
  125. //}}AFX_DATA_MAP
  126. }
  127. void
  128. CVDWPDescription::SetControlStates()
  129. /*++
  130. Routine Description:
  131. Set the state of the control data
  132. Arguments:
  133. None
  134. Return Value:
  135. None
  136. --*/
  137. {
  138. DWORD dwFlags = PSWIZB_BACK;
  139. if (m_edit_Description.GetWindowTextLength() > 0)
  140. {
  141. dwFlags |= PSWIZB_NEXT;
  142. }
  143. SetWizardButtons(dwFlags);
  144. }
  145. LRESULT
  146. CVDWPDescription::OnWizardNext()
  147. /*++
  148. Routine Description:
  149. 'next' handler. This is where validation is done,
  150. because DoDataExchange() gets called every time
  151. the dialog is exited, and this is not valid for
  152. wizards
  153. Arguments:
  154. None
  155. Return Value:
  156. 0 to proceed, -1 to fail
  157. --*/
  158. {
  159. if (!ValidateString(
  160. m_edit_Description,
  161. m_pwsSettings->m_strDescription,
  162. 1,
  163. MAX_PATH
  164. ))
  165. {
  166. return -1;
  167. }
  168. return CIISWizardPage::OnWizardNext();
  169. }
  170. //
  171. // Message Map
  172. //
  173. BEGIN_MESSAGE_MAP(CVDWPDescription, CIISWizardPage)
  174. //{{AFX_MSG_MAP(CVDWPDescription)
  175. ON_EN_CHANGE(IDC_EDIT_DESCRIPTION, OnChangeEditDescription)
  176. //}}AFX_MSG_MAP
  177. END_MESSAGE_MAP()
  178. //
  179. // Message Handlers
  180. //
  181. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  182. BOOL
  183. CVDWPDescription::OnSetActive()
  184. /*++
  185. Routine Description:
  186. Activation handler
  187. Arguments:
  188. None
  189. Return Value:
  190. TRUE for success, FALSE for failure
  191. --*/
  192. {
  193. SetControlStates();
  194. return CIISWizardPage::OnSetActive();
  195. }
  196. void
  197. CVDWPDescription::OnChangeEditDescription()
  198. /*++
  199. Routine Description:
  200. 'edit change' handler
  201. Arguments:
  202. None
  203. Return Value:
  204. None
  205. --*/
  206. {
  207. SetControlStates();
  208. }
  209. //
  210. // New Virtual Server Wizard Bindings Page
  211. //
  212. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  213. IMPLEMENT_DYNCREATE(CVDWPBindings, CIISWizardPage)
  214. CVDWPBindings::CVDWPBindings(
  215. IN OUT CIISWebWizSettings * pwsSettings,
  216. IN DWORD dwInstance
  217. )
  218. /*++
  219. Routine Description:
  220. Constructor
  221. Arguments:
  222. CString & strServerName : Server name
  223. Return Value:
  224. None
  225. --*/
  226. : CIISWizardPage(
  227. CVDWPBindings::IDD, // Template
  228. IDS_NEW_SITE_WIZARD, // Caption
  229. HEADER_PAGE // Header
  230. ),
  231. m_pwsSettings(pwsSettings),
  232. m_fCertInstalled(IsCertInstalledOnServer(
  233. pwsSettings->m_strServerName,
  234. dwInstance)
  235. ),
  236. m_iaIpAddress(),
  237. m_oblIpAddresses(),
  238. m_dwInstance(dwInstance)
  239. {
  240. //{{AFX_DATA_INIT(CVDWPBindings)
  241. m_nIpAddressSel = -1;
  242. m_nTCPPort = DEF_PORT;
  243. m_nSSLPort = DEF_SSL_PORT;
  244. m_strDomainName = _T("");
  245. //}}AFX_DATA_INIT
  246. }
  247. CVDWPBindings::~CVDWPBindings()
  248. /*++
  249. Routine Description:
  250. Destructor
  251. Arguments:
  252. N/A
  253. Return Value:
  254. N/A
  255. --*/
  256. {
  257. }
  258. void
  259. CVDWPBindings::DoDataExchange(
  260. IN CDataExchange * pDX
  261. )
  262. /*++
  263. Routine Description:
  264. Initialise/Store control data
  265. Arguments:
  266. CDataExchange * pDX - DDX/DDV control structure
  267. Return Value:
  268. None
  269. --*/
  270. {
  271. CIISWizardPage::DoDataExchange(pDX);
  272. //{{AFX_DATA_MAP(CVDWPBindings)
  273. DDX_Text(pDX, IDC_EDIT_TCP_PORT, m_nTCPPort);
  274. DDV_MinMaxUInt(pDX, m_nTCPPort, 1, 65535);
  275. DDX_Control(pDX, IDC_COMBO_IP_ADDRESSES, m_combo_IpAddresses);
  276. DDX_Text(pDX, IDC_EDIT_DOMAIN_NAME, m_strDomainName);
  277. DDV_MaxChars(pDX, m_strDomainName, MAX_PATH);
  278. //}}AFX_DATA_MAP
  279. if (m_fCertInstalled)
  280. {
  281. DDX_Text(pDX, IDC_EDIT_SSL_PORT, m_nSSLPort);
  282. DDV_MinMaxUInt(pDX, m_nSSLPort, 1, 65535);
  283. }
  284. //
  285. // Check for dup port right after DDXV of SSL port -- because focus will
  286. // be set appropriately. Don't change!
  287. //
  288. if (pDX->m_bSaveAndValidate && m_nTCPPort == m_nSSLPort)
  289. {
  290. ::AfxMessageBox(IDS_TCP_SSL_PART);
  291. pDX->Fail();
  292. }
  293. DDX_CBIndex(pDX, IDC_COMBO_IP_ADDRESSES, m_nIpAddressSel);
  294. if (pDX->m_bSaveAndValidate)
  295. {
  296. if (!FetchIpAddressFromCombo(
  297. m_combo_IpAddresses,
  298. m_oblIpAddresses,
  299. m_iaIpAddress
  300. ))
  301. {
  302. pDX->Fail();
  303. }
  304. //
  305. // Build with empty host header
  306. //
  307. CInstanceProps::BuildBinding(
  308. m_pwsSettings->m_strBinding,
  309. m_iaIpAddress,
  310. m_nTCPPort,
  311. m_strDomainName
  312. );
  313. if (m_fCertInstalled)
  314. {
  315. CInstanceProps::BuildSecureBinding(
  316. m_pwsSettings->m_strSecureBinding,
  317. m_iaIpAddress,
  318. m_nSSLPort
  319. );
  320. }
  321. else
  322. {
  323. m_pwsSettings->m_strSecureBinding.Empty();
  324. }
  325. }
  326. }
  327. void
  328. CVDWPBindings::SetControlStates()
  329. /*++
  330. Routine Description:
  331. Set the state of the control data
  332. Arguments:
  333. None
  334. Return Value:
  335. None
  336. --*/
  337. {
  338. SetWizardButtons(PSWIZB_NEXT | PSWIZB_BACK);
  339. m_fCertInstalled = IsCertInstalledOnServer(
  340. m_pwsSettings->m_strServerName,
  341. m_dwInstance
  342. );
  343. GetDlgItem(IDC_STATIC_SSL_PORT)->EnableWindow(m_fCertInstalled);
  344. GetDlgItem(IDC_EDIT_SSL_PORT)->EnableWindow(m_fCertInstalled);
  345. }
  346. //
  347. // Message Map
  348. //
  349. BEGIN_MESSAGE_MAP(CVDWPBindings, CIISWizardPage)
  350. //{{AFX_MSG_MAP(CVDWPBindings)
  351. //}}AFX_MSG_MAP
  352. END_MESSAGE_MAP()
  353. //
  354. // Message Handlers
  355. //
  356. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  357. BOOL
  358. CVDWPBindings::OnInitDialog()
  359. /*++
  360. Routine Description:
  361. WM_INITDIALOG handler. Initialize the dialog.
  362. Arguments:
  363. None.
  364. Return Value:
  365. TRUE if no focus is to be set automatically, FALSE if the focus
  366. is already set.
  367. --*/
  368. {
  369. CIISWizardPage::OnInitDialog();
  370. BeginWaitCursor();
  371. PopulateComboWithKnownIpAddresses(
  372. m_pwsSettings->m_strServerName,
  373. m_combo_IpAddresses,
  374. m_iaIpAddress,
  375. m_oblIpAddresses,
  376. m_nIpAddressSel
  377. );
  378. EndWaitCursor();
  379. return TRUE;
  380. }
  381. BOOL
  382. CVDWPBindings::OnSetActive()
  383. /*++
  384. Routine Description:
  385. Activation handler
  386. Arguments:
  387. None
  388. Return Value:
  389. TRUE for success, FALSE for failure
  390. --*/
  391. {
  392. SetControlStates();
  393. return CIISWizardPage::OnSetActive();
  394. }
  395. //
  396. // New Virtual Directory Wizard Alias Page
  397. //
  398. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  399. IMPLEMENT_DYNCREATE(CVDWPAlias, CIISWizardPage)
  400. CVDWPAlias::CVDWPAlias(
  401. IN OUT CIISWebWizSettings * pwsSettings
  402. )
  403. /*++
  404. Routine Description:
  405. Constructor
  406. Arguments:
  407. CString & strServerName : Server name
  408. Return Value:
  409. None
  410. --*/
  411. : CIISWizardPage(
  412. CVDWPAlias::IDD, // Template
  413. IDS_NEW_VDIR_WIZARD, // Caption
  414. HEADER_PAGE
  415. ),
  416. m_pwsSettings(pwsSettings)
  417. {
  418. #if 0 // Keep Class Wizard Happy
  419. //{{AFX_DATA_INIT(CVDWPAlias)
  420. //}}AFX_DATA_INIT
  421. #endif // 0
  422. }
  423. CVDWPAlias::~CVDWPAlias()
  424. /*++
  425. Routine Description:
  426. Destructor
  427. Arguments:
  428. N/A
  429. Return Value:
  430. N/A
  431. --*/
  432. {
  433. }
  434. void
  435. CVDWPAlias::DoDataExchange(
  436. IN CDataExchange * pDX
  437. )
  438. /*++
  439. Routine Description:
  440. Initialise/Store control data
  441. Arguments:
  442. CDataExchange * pDX - DDX/DDV control structure
  443. Return Value:
  444. None
  445. --*/
  446. {
  447. CIISWizardPage::DoDataExchange(pDX);
  448. //{{AFX_DATA_MAP(CVDWPAlias)
  449. DDX_Control(pDX, IDC_EDIT_ALIAS, m_edit_Alias);
  450. //}}AFX_DATA_MAP
  451. }
  452. LRESULT
  453. CVDWPAlias::OnWizardNext()
  454. /*++
  455. Routine Description:
  456. prevent the / and \ characters from being in the alias name
  457. Arguments:
  458. None
  459. Return Value:
  460. None
  461. --*/
  462. {
  463. if (!ValidateString(
  464. m_edit_Alias,
  465. m_pwsSettings->m_strAlias,
  466. 1,
  467. MAX_ALIAS_NAME
  468. ))
  469. {
  470. return -1;
  471. }
  472. //
  473. // Find the illegal characters. If they exist tell
  474. // the user and don't go on.
  475. //
  476. if (m_pwsSettings->m_strAlias.FindOneOf(_T("/\\?*")) >= 0)
  477. {
  478. AfxMessageBox(IDS_ILLEGAL_ALIAS_CHARS);
  479. m_edit_Alias.SetFocus();
  480. m_edit_Alias.SetSel(0, -1);
  481. //
  482. // prevent the wizard page from changing
  483. //
  484. return -1;
  485. }
  486. //
  487. // Allow the wizard to continue
  488. //
  489. return CIISWizardPage::OnWizardNext();
  490. }
  491. void
  492. CVDWPAlias::SetControlStates()
  493. /*++
  494. Routine Description:
  495. Set the state of the control data
  496. Arguments:
  497. None
  498. Return Value:
  499. None
  500. --*/
  501. {
  502. DWORD dwFlags = PSWIZB_BACK;
  503. if (m_edit_Alias.GetWindowTextLength() > 0)
  504. {
  505. dwFlags |= PSWIZB_NEXT;
  506. }
  507. SetWizardButtons(dwFlags);
  508. }
  509. //
  510. // Message Map
  511. //
  512. BEGIN_MESSAGE_MAP(CVDWPAlias, CIISWizardPage)
  513. //{{AFX_MSG_MAP(CVDWPAlias)
  514. ON_EN_CHANGE(IDC_EDIT_ALIAS, OnChangeEditAlias)
  515. //}}AFX_MSG_MAP
  516. END_MESSAGE_MAP()
  517. //
  518. // Message Handlers
  519. //
  520. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  521. BOOL
  522. CVDWPAlias::OnSetActive()
  523. /*++
  524. Routine Description:
  525. Activation handler
  526. Arguments:
  527. None
  528. Return Value:
  529. TRUE for success, FALSE for failure
  530. --*/
  531. {
  532. SetControlStates();
  533. return CIISWizardPage::OnSetActive();
  534. }
  535. void
  536. CVDWPAlias::OnChangeEditAlias()
  537. /*++
  538. Routine Description:
  539. 'edit change' handler
  540. Arguments:
  541. None
  542. Return Value:
  543. None
  544. --*/
  545. {
  546. SetControlStates();
  547. }
  548. //
  549. // New Virtual Directory Wizard Path Page
  550. //
  551. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  552. IMPLEMENT_DYNCREATE(CVDWPPath, CIISWizardPage)
  553. CVDWPPath::CVDWPPath(
  554. IN OUT CIISWebWizSettings * pwsSettings,
  555. IN BOOL bVDir
  556. )
  557. /*++
  558. Routine Description:
  559. Constructor
  560. Arguments:
  561. CString & strServerName : Server name
  562. BOOL bVDir : TRUE for a VDIR, FALSE for an instance
  563. Return Value:
  564. None
  565. --*/
  566. : CIISWizardPage(
  567. (bVDir ? IDD_NEW_DIR_PATH : IDD_NEW_INST_HOME), // Template
  568. (bVDir ? IDS_NEW_VDIR_WIZARD : IDS_NEW_SITE_WIZARD), // Caption
  569. HEADER_PAGE // Header page
  570. ),
  571. m_pwsSettings(pwsSettings)
  572. {
  573. #if 0 // Keep ClassWizard happy
  574. //{{AFX_DATA_INIT(CVDWPPath)
  575. //}}AFX_DATA_INIT
  576. #endif // 0
  577. }
  578. CVDWPPath::~CVDWPPath()
  579. /*++
  580. Routine Description:
  581. Destructor
  582. Arguments:
  583. N/A
  584. Return Value:
  585. N/A
  586. --*/
  587. {
  588. }
  589. void
  590. CVDWPPath::DoDataExchange(
  591. IN CDataExchange * pDX
  592. )
  593. /*++
  594. Routine Description:
  595. Initialise/Store control data
  596. Arguments:
  597. CDataExchange * pDX - DDX/DDV control structure
  598. Return Value:
  599. None
  600. --*/
  601. {
  602. CIISWizardPage::DoDataExchange(pDX);
  603. //{{AFX_DATA_MAP(CVDWPPath)
  604. DDX_Control(pDX, IDC_BUTTON_BROWSE, m_button_Browse);
  605. DDX_Control(pDX, IDC_EDIT_PATH, m_edit_Path);
  606. DDX_Check(pDX, IDC_CHECK_ALLOW_ANONYMOUS, m_pwsSettings->m_fAllowAnonymous);
  607. //}}AFX_DATA_MAP
  608. DDX_Text(pDX, IDC_EDIT_PATH, m_pwsSettings->m_strPath);
  609. DDV_MaxChars(pDX, m_pwsSettings->m_strPath, MAX_PATH);
  610. }
  611. void
  612. CVDWPPath::SetControlStates()
  613. /*++
  614. Routine Description:
  615. Set the state of the control data
  616. Arguments:
  617. None
  618. Return Value:
  619. None
  620. --*/
  621. {
  622. DWORD dwFlags = PSWIZB_BACK;
  623. if (m_edit_Path.GetWindowTextLength() > 0)
  624. {
  625. dwFlags |= PSWIZB_NEXT;
  626. }
  627. SetWizardButtons(dwFlags);
  628. }
  629. //
  630. // Message Map
  631. //
  632. BEGIN_MESSAGE_MAP(CVDWPPath, CIISWizardPage)
  633. //{{AFX_MSG_MAP(CVDWPPath)
  634. ON_EN_CHANGE(IDC_EDIT_PATH, OnChangeEditPath)
  635. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  636. //}}AFX_MSG_MAP
  637. END_MESSAGE_MAP()
  638. //
  639. // Message Handlers
  640. //
  641. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  642. BOOL
  643. CVDWPPath::OnSetActive()
  644. /*++
  645. Routine Description:
  646. Activation handler
  647. Arguments:
  648. None
  649. Return Value:
  650. TRUE for success, FALSE for failure
  651. --*/
  652. {
  653. SetControlStates();
  654. return CIISWizardPage::OnSetActive();
  655. }
  656. LRESULT
  657. CVDWPPath::OnWizardNext()
  658. /*++
  659. Routine Description:
  660. 'next' handler. This is where validation is done,
  661. because DoDataExchange() gets called every time
  662. the dialog is exited, and this is not valid for
  663. wizards
  664. Arguments:
  665. None
  666. Return Value:
  667. 0 to proceed, -1 to fail
  668. --*/
  669. {
  670. if (!ValidateString(m_edit_Path, m_pwsSettings->m_strPath, 1, MAX_PATH))
  671. {
  672. return -1;
  673. }
  674. m_pwsSettings->m_fUNC = IsUNCName(m_pwsSettings->m_strPath);
  675. if (!m_pwsSettings->m_fUNC)
  676. {
  677. if (!IsFullyQualifiedPath(m_pwsSettings->m_strPath)
  678. && !IsDevicePath(m_pwsSettings->m_strPath)
  679. )
  680. {
  681. m_edit_Path.SetSel(0,-1);
  682. m_edit_Path.SetFocus();
  683. ::AfxMessageBox(IDS_ERR_BAD_PATH);
  684. return -1;
  685. }
  686. if (m_pwsSettings->m_fLocal)
  687. {
  688. DWORD dwAttr = GetFileAttributes(m_pwsSettings->m_strPath);
  689. if (dwAttr == 0xffffffff ||
  690. (dwAttr & FILE_ATTRIBUTE_DIRECTORY) == 0)
  691. {
  692. m_edit_Path.SetSel(0,-1);
  693. m_edit_Path.SetFocus();
  694. ::AfxMessageBox(IDS_ERR_PATH_NOT_FOUND);
  695. return -1;
  696. }
  697. }
  698. }
  699. return CIISWizardPage::OnWizardNext();
  700. }
  701. void
  702. CVDWPPath::OnChangeEditPath()
  703. /*++
  704. Routine Description:
  705. 'edit change' handler
  706. Arguments:
  707. None
  708. Return Value:
  709. None
  710. --*/
  711. {
  712. SetControlStates();
  713. }
  714. void
  715. CVDWPPath::OnButtonBrowse()
  716. /*++
  717. Routine Description:
  718. Handle 'browsing' for directory path -- local system only
  719. Arguments:
  720. None
  721. Return Value:
  722. None
  723. --*/
  724. {
  725. ASSERT(m_pwsSettings->m_fLocal);
  726. CString str;
  727. m_edit_Path.GetWindowText(str);
  728. CDirBrowseDlg dlgBrowse(this, str);
  729. if (dlgBrowse.DoModal() == IDOK)
  730. {
  731. m_edit_Path.SetWindowText(dlgBrowse.GetFullPath(
  732. m_pwsSettings->m_strPath
  733. ));
  734. SetControlStates();
  735. }
  736. }
  737. BOOL
  738. CVDWPPath::OnInitDialog()
  739. /*++
  740. Routine Description:
  741. WM_INITDIALOG handler. Initialize the dialog.
  742. Arguments:
  743. None.
  744. Return Value:
  745. TRUE if no focus is to be set automatically, FALSE if the focus
  746. is already set.
  747. --*/
  748. {
  749. CIISWizardPage::OnInitDialog();
  750. m_button_Browse.EnableWindow(m_pwsSettings->m_fLocal);
  751. return TRUE;
  752. }
  753. //
  754. // Wizard User/Password Page
  755. //
  756. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  757. IMPLEMENT_DYNCREATE(CVDWPUserName, CIISWizardPage)
  758. CVDWPUserName::CVDWPUserName(
  759. IN OUT CIISWebWizSettings * pwsSettings,
  760. IN BOOL bVDir
  761. )
  762. /*++
  763. Routine Description:
  764. Constructor
  765. Arguments:
  766. CString & strServerName : Server name
  767. BOOL bVDir : TRUE if this is for a vdir,
  768. FALSE if this is an instance
  769. Return Value:
  770. None
  771. --*/
  772. : CIISWizardPage(
  773. CVDWPUserName::IDD, // Templ.
  774. (bVDir ? IDS_NEW_VDIR_WIZARD : IDS_NEW_SITE_WIZARD), // Caption
  775. HEADER_PAGE, // Header
  776. (bVDir ? USE_DEFAULT_CAPTION : IDS_SITE_SECURITY_TITLE), // Title
  777. (bVDir ? USE_DEFAULT_CAPTION : IDS_SITE_SECURITY_SUBTITLE) // Subtitle
  778. ),
  779. m_pwsSettings(pwsSettings)
  780. {
  781. #if 0 // Keep Class Wizard Happy
  782. //{{AFX_DATA_INIT(CVDWPUserName)
  783. //}}AFX_DATA_INIT
  784. #endif // 0
  785. }
  786. CVDWPUserName::~CVDWPUserName()
  787. /*++
  788. Routine Description:
  789. Destructor
  790. Arguments:
  791. N/A
  792. Return Value:
  793. N/A
  794. --*/
  795. {
  796. }
  797. void
  798. CVDWPUserName::DoDataExchange(
  799. IN CDataExchange * pDX
  800. )
  801. /*++
  802. Routine Description:
  803. Initialise/Store control data
  804. Arguments:
  805. CDataExchange * pDX - DDX/DDV control structure
  806. Return Value:
  807. None
  808. --*/
  809. {
  810. CIISWizardPage::DoDataExchange(pDX);
  811. //{{AFX_DATA_MAP(CVDWPUserName)
  812. DDX_Control(pDX, IDC_EDIT_USERNAME, m_edit_UserName);
  813. DDX_Control(pDX, IDC_EDIT_PASSWORD, m_edit_Password);
  814. //}}AFX_DATA_MAP
  815. //
  816. // Private DDX/DDV Routines
  817. //
  818. DDX_Text(pDX, IDC_EDIT_USERNAME, m_pwsSettings->m_strUserName);
  819. DDV_MaxChars(pDX, m_pwsSettings->m_strUserName, UNLEN);
  820. //
  821. // Some people have a tendency to add "\\" before
  822. // the computer name in user accounts. Fix this here.
  823. //
  824. m_pwsSettings->m_strUserName.TrimLeft();
  825. while (*m_pwsSettings->m_strUserName == '\\')
  826. {
  827. m_pwsSettings->m_strUserName = m_pwsSettings->m_strUserName.Mid(2);
  828. }
  829. DDX_Password(pDX, IDC_EDIT_PASSWORD, m_pwsSettings->m_strPassword, g_lpszDummyPassword);
  830. DDV_MaxChars(pDX, m_pwsSettings->m_strPassword, PWLEN);
  831. }
  832. void
  833. CVDWPUserName::SetControlStates()
  834. /*++
  835. Routine Description:
  836. Set the state of the control data
  837. Arguments:
  838. None
  839. Return Value:
  840. None
  841. --*/
  842. {
  843. DWORD dwFlags = PSWIZB_BACK;
  844. if (m_edit_UserName.GetWindowTextLength() > 0)
  845. {
  846. dwFlags |= PSWIZB_NEXT;
  847. }
  848. SetWizardButtons(dwFlags);
  849. }
  850. //
  851. // Message Map
  852. //
  853. BEGIN_MESSAGE_MAP(CVDWPUserName, CIISWizardPage)
  854. //{{AFX_MSG_MAP(CVDWPUserName)
  855. ON_BN_CLICKED(IDC_BUTTON_BROWSE_USERS, OnButtonBrowseUsers)
  856. ON_EN_CHANGE(IDC_EDIT_USERNAME, OnChangeEditUsername)
  857. ON_BN_CLICKED(IDC_BUTTON_CHECK_PASSWORD, OnButtonCheckPassword)
  858. //}}AFX_MSG_MAP
  859. END_MESSAGE_MAP()
  860. //
  861. // Message Handlers
  862. //
  863. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  864. BOOL
  865. CVDWPUserName::OnSetActive()
  866. /*++
  867. Routine Description:
  868. Activation handler
  869. Arguments:
  870. None
  871. Return Value:
  872. TRUE for success, FALSE for failure
  873. --*/
  874. {
  875. if (!m_pwsSettings->m_fUNC)
  876. {
  877. return 0;
  878. }
  879. SetControlStates();
  880. return CIISWizardPage::OnSetActive();
  881. }
  882. BOOL
  883. CVDWPUserName::OnInitDialog()
  884. /*++
  885. Routine Description:
  886. WM_INITDIALOG handler. Initialize the dialog.
  887. Arguments:
  888. None.
  889. Return Value:
  890. TRUE if no focus is to be set automatically, FALSE if the focus
  891. is already set.
  892. --*/
  893. {
  894. CIISWizardPage::OnInitDialog();
  895. return TRUE;
  896. }
  897. LRESULT
  898. CVDWPUserName::OnWizardNext()
  899. /*++
  900. Routine Description:
  901. 'next' handler. This is where validation is done,
  902. because DoDataExchange() gets called every time
  903. the dialog is exited, and this is not valid for
  904. wizards
  905. Arguments:
  906. None
  907. Return Value:
  908. 0 to proceed, -1 to fail
  909. --*/
  910. {
  911. if (!ValidateString(
  912. m_edit_UserName,
  913. m_pwsSettings->m_strUserName,
  914. 1,
  915. UNLEN
  916. ))
  917. {
  918. return -1;
  919. }
  920. return CIISWizardPage::OnWizardNext();
  921. }
  922. void
  923. CVDWPUserName::OnButtonBrowseUsers()
  924. /*++
  925. Routine Description:
  926. 'browse' for users handler
  927. Arguments:
  928. None
  929. Return Value:
  930. None
  931. --*/
  932. {
  933. CString str;
  934. if (GetIUsrAccount(m_pwsSettings->m_strServerName, this, str))
  935. {
  936. //
  937. // If a name was selected, blank
  938. // out the password
  939. //
  940. m_edit_UserName.SetWindowText(str);
  941. m_edit_Password.SetFocus();
  942. }
  943. }
  944. void
  945. CVDWPUserName::OnChangeEditUsername()
  946. /*++
  947. Routine Description:
  948. 'edit change' in user name notification handler
  949. Arguments:
  950. None
  951. Return Value:
  952. None
  953. --*/
  954. {
  955. m_edit_Password.SetWindowText(_T(""));
  956. SetControlStates();
  957. }
  958. void
  959. CVDWPUserName::OnButtonCheckPassword()
  960. /*++
  961. Routine Description:
  962. 'Check Password' has been pressed. Try to validate
  963. the password that has been entered
  964. Arguments:
  965. None
  966. Return Value:
  967. None
  968. --*/
  969. {
  970. if (!UpdateData(TRUE))
  971. {
  972. return;
  973. }
  974. CError err(VerifyUserPassword(
  975. m_pwsSettings->m_strUserName,
  976. m_pwsSettings->m_strPassword
  977. ));
  978. if (!err.MessageBoxOnFailure())
  979. {
  980. ::AfxMessageBox(IDS_PASSWORD_OK);
  981. }
  982. }
  983. //
  984. // Wizard Permissions Page
  985. //
  986. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  987. IMPLEMENT_DYNCREATE(CVDWPPermissions, CIISWizardPage)
  988. CVDWPPermissions::CVDWPPermissions(
  989. IN OUT CIISWebWizSettings * pwsSettings,
  990. IN BOOL bVDir
  991. )
  992. /*++
  993. Routine Description:
  994. Constructor
  995. Arguments:
  996. CString & strServerName : Server name
  997. BOOL bVDir : TRUE if this is a vdir page,
  998. FALSE for instance
  999. Return Value:
  1000. None
  1001. --*/
  1002. : CIISWizardPage(
  1003. CVDWPPermissions::IDD, // Template
  1004. (bVDir ? IDS_NEW_VDIR_WIZARD : IDS_NEW_SITE_WIZARD), // Caption
  1005. HEADER_PAGE, // Header
  1006. (bVDir ? USE_DEFAULT_CAPTION : IDS_SITE_PERMS_TITLE), // Title
  1007. (bVDir ? USE_DEFAULT_CAPTION : IDS_SITE_PERMS_SUBTITLE) // Subtitle
  1008. ),
  1009. m_bVDir(bVDir),
  1010. m_pwsSettings(pwsSettings)
  1011. {
  1012. //{{AFX_DATA_INIT(CVDWPPermissions)
  1013. //}}AFX_DATA_INIT
  1014. m_pwsSettings->m_fDirBrowsing = FALSE;
  1015. m_pwsSettings->m_fRead = TRUE;
  1016. m_pwsSettings->m_fScript = TRUE;
  1017. m_pwsSettings->m_fWrite = FALSE;
  1018. m_pwsSettings->m_fExecute = FALSE;
  1019. }
  1020. CVDWPPermissions::~CVDWPPermissions()
  1021. /*++
  1022. Routine Description:
  1023. Destructor
  1024. Arguments:
  1025. None
  1026. Return Value:
  1027. None
  1028. --*/
  1029. {
  1030. }
  1031. void
  1032. CVDWPPermissions::DoDataExchange(
  1033. IN CDataExchange * pDX
  1034. )
  1035. /*++
  1036. Routine Description:
  1037. Initialise/Store control data
  1038. Arguments:
  1039. CDataExchange * pDX - DDX/DDV control structure
  1040. Return Value:
  1041. None
  1042. --*/
  1043. {
  1044. CIISWizardPage::DoDataExchange(pDX);
  1045. //{{AFX_DATA_MAP(CVDWPPermissions)
  1046. //}}AFX_DATA_MAP
  1047. DDX_Check(pDX, IDC_CHECK_DIRBROWS, m_pwsSettings->m_fDirBrowsing);
  1048. DDX_Check(pDX, IDC_CHECK_READ, m_pwsSettings->m_fRead);
  1049. DDX_Check(pDX, IDC_CHECK_SCRIPT, m_pwsSettings->m_fScript);
  1050. DDX_Check(pDX, IDC_CHECK_WRITE, m_pwsSettings->m_fWrite);
  1051. DDX_Check(pDX, IDC_CHECK_EXECUTE, m_pwsSettings->m_fExecute);
  1052. }
  1053. void
  1054. CVDWPPermissions::SetControlStates()
  1055. /*++
  1056. Routine Description:
  1057. Set the state of the control data
  1058. Arguments:
  1059. None
  1060. Return Value:
  1061. None
  1062. --*/
  1063. {
  1064. SetWizardButtons(PSWIZB_BACK | PSWIZB_NEXT);
  1065. }
  1066. //
  1067. // Message Map
  1068. //
  1069. BEGIN_MESSAGE_MAP(CVDWPPermissions, CIISWizardPage)
  1070. //{{AFX_MSG_MAP(CVDWPPermissions)
  1071. //}}AFX_MSG_MAP
  1072. END_MESSAGE_MAP()
  1073. //
  1074. // Message Handlers
  1075. //
  1076. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  1077. BOOL
  1078. CVDWPPermissions::OnSetActive()
  1079. /*++
  1080. Routine Description:
  1081. Activation handler
  1082. Arguments:
  1083. None
  1084. Return Value:
  1085. TRUE for success, FALSE for failure
  1086. --*/
  1087. {
  1088. SetControlStates();
  1089. return CIISWizardPage::OnSetActive();
  1090. }
  1091. LRESULT
  1092. CVDWPPermissions::OnWizardNext()
  1093. /*++
  1094. Routine Description:
  1095. 'next' handler. Complete the wizard
  1096. Arguments:
  1097. None
  1098. Return Value:
  1099. 0 to proceed, -1 to fail
  1100. --*/
  1101. {
  1102. if (!UpdateData(TRUE))
  1103. {
  1104. return -1;
  1105. }
  1106. ASSERT(m_pwsSettings != NULL);
  1107. CWaitCursor wait;
  1108. //
  1109. // Build permissions DWORD
  1110. //
  1111. DWORD dwPermissions = 0L;
  1112. DWORD dwAuthFlags = MD_AUTH_NT;
  1113. DWORD dwDirBrowsing =
  1114. MD_DIRBROW_SHOW_DATE |
  1115. MD_DIRBROW_SHOW_TIME |
  1116. MD_DIRBROW_SHOW_SIZE |
  1117. MD_DIRBROW_SHOW_EXTENSION |
  1118. MD_DIRBROW_LONG_DATE |
  1119. MD_DIRBROW_LOADDEFAULT;
  1120. if (m_pwsSettings->m_fWrite && m_pwsSettings->m_fExecute)
  1121. {
  1122. if (IDNO == ::AfxMessageBox(IDS_EXECUTE_AND_WRITE_WARNING, MB_YESNO))
  1123. return -1;
  1124. }
  1125. SET_FLAG_IF(m_pwsSettings->m_fRead, dwPermissions, MD_ACCESS_READ);
  1126. SET_FLAG_IF(m_pwsSettings->m_fWrite, dwPermissions, MD_ACCESS_WRITE);
  1127. SET_FLAG_IF(m_pwsSettings->m_fScript || m_pwsSettings->m_fExecute,
  1128. dwPermissions, MD_ACCESS_SCRIPT);
  1129. SET_FLAG_IF(m_pwsSettings->m_fExecute, dwPermissions, MD_ACCESS_EXECUTE);
  1130. SET_FLAG_IF(m_pwsSettings->m_fDirBrowsing, dwDirBrowsing, MD_DIRBROW_ENABLED);
  1131. SET_FLAG_IF(m_pwsSettings->m_fAllowAnonymous, dwAuthFlags, MD_AUTH_ANONYMOUS);
  1132. if (m_bVDir)
  1133. {
  1134. //
  1135. // First see if by any chance this name already exists
  1136. //
  1137. ISMCHILDINFO ii;
  1138. ii.dwSize = sizeof(ii);
  1139. CError err;
  1140. BEGIN_ASSURE_BINDING_SECTION
  1141. err = ::ISMQueryChildInfo(
  1142. m_pwsSettings->m_pKey,
  1143. WITHOUT_INHERITANCE,
  1144. &ii,
  1145. m_pwsSettings->m_dwInstance,
  1146. m_pwsSettings->m_strParent,
  1147. m_pwsSettings->m_strAlias
  1148. );
  1149. END_ASSURE_BINDING_SECTION(err, m_pwsSettings->m_pKey, ERROR_CANCELLED);
  1150. if (err.Succeeded())
  1151. {
  1152. BOOL fNotUnique = TRUE;
  1153. //
  1154. // If the item existed without a VrPath, we'll just blow it
  1155. // away, as a vdir takes presedence over a directory/file.
  1156. //
  1157. if (!*ii.szPath)
  1158. {
  1159. err = ::ISMDeleteChild(
  1160. m_pwsSettings->m_pKey,
  1161. m_pwsSettings->m_dwInstance,
  1162. m_pwsSettings->m_strParent,
  1163. m_pwsSettings->m_strAlias
  1164. );
  1165. if (err.Succeeded())
  1166. {
  1167. //
  1168. // Successfully deleted -- continue as normal.
  1169. //
  1170. fNotUnique = FALSE;
  1171. }
  1172. }
  1173. //
  1174. // This one already exists and exists as a virtual
  1175. // directory, so away with it.
  1176. //
  1177. if (fNotUnique)
  1178. {
  1179. ::AfxMessageBox(IDS_ERR_ALIAS_NOT_UNIQUE);
  1180. return IDD_NEW_DIR_ALIAS;
  1181. }
  1182. }
  1183. //
  1184. // Create new vdir
  1185. //
  1186. BEGIN_ASSURE_BINDING_SECTION
  1187. err = CChildNodeProps::Add(
  1188. m_pwsSettings->m_pKey,
  1189. m_pwsSettings->m_strService, // Service name
  1190. m_pwsSettings->m_dwInstance, // Instance
  1191. m_pwsSettings->m_strParent, // Parent path
  1192. m_pwsSettings->m_strAlias, // Desired alias name
  1193. m_pwsSettings->m_strAlias, // Name returned here (may differ)
  1194. &dwPermissions, // Permissions
  1195. &dwDirBrowsing, // dir browsing
  1196. m_pwsSettings->m_strPath, // Physical path of this directory
  1197. (m_pwsSettings->m_fUNC ? (LPCTSTR)m_pwsSettings->m_strUserName : NULL),
  1198. (m_pwsSettings->m_fUNC ? (LPCTSTR)m_pwsSettings->m_strPassword : NULL),
  1199. TRUE // Name must be unique
  1200. );
  1201. END_ASSURE_BINDING_SECTION(err, m_pwsSettings->m_pKey, ERROR_CANCELLED);
  1202. m_pwsSettings->m_hrResult = err;
  1203. //
  1204. // Create an (in-proc) application on the new directory if
  1205. // script or execute was requested.
  1206. //
  1207. if (SUCCEEDED(m_pwsSettings->m_hrResult))
  1208. {
  1209. if (m_pwsSettings->m_fExecute || m_pwsSettings->m_fScript)
  1210. {
  1211. CIISApplication app(
  1212. m_pwsSettings->m_strServerName,
  1213. m_pwsSettings->m_strService,
  1214. m_pwsSettings->m_dwInstance,
  1215. m_pwsSettings->m_strParent,
  1216. m_pwsSettings->m_strAlias
  1217. );
  1218. m_pwsSettings->m_hrResult = app.QueryResult();
  1219. //
  1220. // This would make no sense...
  1221. //
  1222. ASSERT(!app.IsEnabledApplication());
  1223. if (SUCCEEDED(m_pwsSettings->m_hrResult))
  1224. {
  1225. //
  1226. // Attempt to create a pooled-proc by default; failing
  1227. // that if it's not supported, create it in proc
  1228. //
  1229. DWORD dwAppProtState = app.SupportsPooledProc()
  1230. ? CWamInterface::APP_POOLEDPROC
  1231. : CWamInterface::APP_INPROC;
  1232. m_pwsSettings->m_hrResult = app.Create(
  1233. m_pwsSettings->m_strAlias,
  1234. dwAppProtState
  1235. );
  1236. }
  1237. }
  1238. }
  1239. }
  1240. else
  1241. {
  1242. //
  1243. // Create new instance
  1244. //
  1245. CError err;
  1246. BEGIN_ASSURE_BINDING_SECTION
  1247. err = CInstanceProps::Add(
  1248. m_pwsSettings->m_pKey,
  1249. m_pwsSettings->m_strService, // Service name
  1250. m_pwsSettings->m_strPath, // Physical path of this directory
  1251. (m_pwsSettings->m_fUNC ? (LPCTSTR)m_pwsSettings->m_strUserName : NULL),
  1252. (m_pwsSettings->m_fUNC ? (LPCTSTR)m_pwsSettings->m_strPassword : NULL),
  1253. m_pwsSettings->m_strDescription,
  1254. m_pwsSettings->m_strBinding,
  1255. m_pwsSettings->m_strSecureBinding,
  1256. &dwPermissions,
  1257. &dwDirBrowsing, // dir browsing
  1258. &dwAuthFlags, // Auth flags
  1259. &m_pwsSettings->m_dwInstance
  1260. );
  1261. END_ASSURE_BINDING_SECTION(err, m_pwsSettings->m_pKey, ERROR_CANCELLED);
  1262. m_pwsSettings->m_hrResult = err;
  1263. if (SUCCEEDED(m_pwsSettings->m_hrResult))
  1264. {
  1265. //
  1266. // Create an (in-proc) application on the new instance's home root
  1267. //
  1268. CIISApplication app(
  1269. m_pwsSettings->m_strServerName,
  1270. m_pwsSettings->m_strService,
  1271. m_pwsSettings->m_dwInstance,
  1272. g_cszRoot
  1273. );
  1274. m_pwsSettings->m_hrResult = app.QueryResult();
  1275. //
  1276. // This would make no sense...
  1277. //
  1278. ASSERT(!app.IsEnabledApplication());
  1279. if (SUCCEEDED(m_pwsSettings->m_hrResult))
  1280. {
  1281. //
  1282. // Create in-proc
  1283. //
  1284. CString strAppName;
  1285. VERIFY(strAppName.LoadString(IDS_DEF_APP));
  1286. //
  1287. // Attempt to create a pooled-proc by default; failing
  1288. // that if it's not supported, create it in proc
  1289. //
  1290. DWORD dwAppProtState = app.SupportsPooledProc()
  1291. ? CWamInterface::APP_POOLEDPROC
  1292. : CWamInterface::APP_INPROC;
  1293. m_pwsSettings->m_hrResult = app.Create(
  1294. strAppName,
  1295. dwAppProtState
  1296. );
  1297. }
  1298. }
  1299. }
  1300. return CIISWizardPage::OnWizardNext();
  1301. }