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.

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