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.

813 lines
19 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // policywiz.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // Defines the classes that implement the new proxy policy wizard.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 03/11/2000 Original version.
  16. // 04/19/2000 Marshall SDOs across apartments.
  17. // 05/15/2000 Don't reset the list of conditions every time we display
  18. // the conditions wizard page.
  19. //
  20. ///////////////////////////////////////////////////////////////////////////////
  21. #include <proxypch.h>
  22. #include <profileprop.h>
  23. #include <groupwiz.h>
  24. #include <policywiz.h>
  25. // Set a policy to match on a given realm.
  26. void SetRealmCondition(SdoCollection& conditions, PCWSTR realm)
  27. {
  28. // Remove any existing conditions.
  29. conditions.removeAll();
  30. // Create a new condition object.
  31. Sdo condition = conditions.create();
  32. // Form the match condition.
  33. CComBSTR text = L"MATCH(\"User-Name=";
  34. text.Append(realm);
  35. text.Append(L"\")");
  36. if (!text) { AfxThrowOleException(E_OUTOFMEMORY); }
  37. // Set the condition text.
  38. condition.setValue(PROPERTY_CONDITION_TEXT, text);
  39. }
  40. // Add a rule to a profile to strip a realm.
  41. void AddRealmStrippingRule(SdoProfile& profile, PCWSTR realm)
  42. {
  43. // Target is always User-Name for realms.
  44. profile.setValue(IAS_ATTRIBUTE_MANIPULATION_TARGET, 1L);
  45. CComVariant rule;
  46. // Allocate a SAFEARRAY to hold the rule.
  47. SAFEARRAYBOUND rgsabound = { 2 , 0 };
  48. V_VT(&rule) = VT_ARRAY | VT_VARIANT;
  49. V_ARRAY(&rule) = SafeArrayCreate(VT_VARIANT, 1, &rgsabound);
  50. if (!V_ARRAY(&rule)) { AfxThrowOleException(E_OUTOFMEMORY); }
  51. VARIANT* v = (VARIANT*)V_ARRAY(&rule)->pvData;
  52. // Find the realm.
  53. V_VT(v) = VT_BSTR;
  54. V_BSTR(v) = SysAllocString(realm);
  55. if (!V_BSTR(v)) { AfxThrowOleException(E_OUTOFMEMORY); }
  56. ++v;
  57. // Replace with nothing.
  58. V_VT(v) = VT_BSTR;
  59. V_BSTR(v) = SysAllocString(L"");
  60. if (!V_BSTR(v)) { AfxThrowOleException(E_OUTOFMEMORY); }
  61. // Add the attribute to the profile.
  62. profile.setValue(IAS_ATTRIBUTE_MANIPULATION_RULE, rule);
  63. }
  64. NewPolicyStartPage::NewPolicyStartPage(NewPolicyWizard& wizard)
  65. : SnapInPropertyPage(IDD_NEWPOLICY_WELCOME, 0, 0, false),
  66. parent(wizard)
  67. {
  68. }
  69. BOOL NewPolicyStartPage::OnInitDialog()
  70. {
  71. SnapInPropertyPage::OnInitDialog();
  72. setLargeFont(IDC_STATIC_LARGE);
  73. return TRUE;
  74. }
  75. BOOL NewPolicyStartPage::OnSetActive()
  76. {
  77. SnapInPropertyPage::OnSetActive();
  78. parent.SetWizardButtons(PSWIZB_NEXT);
  79. return TRUE;
  80. }
  81. NewPolicyNamePage::NewPolicyNamePage(NewPolicyWizard& wizard)
  82. : SnapInPropertyPage(
  83. IDD_NEWPOLICY_NAME,
  84. IDS_NEWPOLICY_NAME_TITLE,
  85. IDS_NEWPOLICY_NAME_SUBTITLE,
  86. false
  87. ),
  88. parent(wizard)
  89. {
  90. }
  91. LRESULT NewPolicyNamePage::OnWizardNext()
  92. {
  93. // Make sure the name is unique.
  94. if (!parent.policy.setName(name))
  95. {
  96. failNoThrow(IDC_EDIT_NAME, IDS_POLICY_E_NOT_UNIQUE);
  97. return -1;
  98. }
  99. // Keep the profile in sync with the policy.
  100. parent.policy.setValue(PROPERTY_POLICY_PROFILE_NAME, name);
  101. parent.profile.setName(name);
  102. // Advance based on the type.
  103. if (parent.getType() == NewPolicyWizard::CUSTOM)
  104. {
  105. return IDD_NEWPOLICY_CONDITIONS;
  106. }
  107. else
  108. {
  109. return IDD_NEWPOLICY_TYPE;
  110. }
  111. }
  112. void NewPolicyNamePage::onButtonClick()
  113. {
  114. getRadio(IDC_RADIO_TYPICAL, IDC_RADIO_CUSTOM, parent.custom);
  115. }
  116. void NewPolicyNamePage::onChangeName()
  117. {
  118. getValue(IDC_EDIT_NAME, name);
  119. setButtons();
  120. }
  121. void NewPolicyNamePage::setData()
  122. {
  123. setValue(IDC_EDIT_NAME, name);
  124. setRadio(IDC_RADIO_TYPICAL, IDC_RADIO_CUSTOM, parent.custom);
  125. setButtons();
  126. }
  127. void NewPolicyNamePage::setButtons()
  128. {
  129. parent.SetWizardButtons(
  130. name.Length() ? (PSWIZB_BACK | PSWIZB_NEXT) : PSWIZB_BACK
  131. );
  132. }
  133. BEGIN_MESSAGE_MAP(NewPolicyNamePage, SnapInPropertyPage)
  134. ON_BN_CLICKED(IDC_RADIO_TYPICAL, onButtonClick)
  135. ON_BN_CLICKED(IDC_RADIO_CUSTOM, onButtonClick)
  136. ON_EN_CHANGE(IDC_EDIT_NAME, onChangeName)
  137. END_MESSAGE_MAP()
  138. NewPolicyTypePage::NewPolicyTypePage(NewPolicyWizard& wizard)
  139. : SnapInPropertyPage(
  140. IDD_NEWPOLICY_TYPE,
  141. IDS_NEWPOLICY_TYPE_TITLE,
  142. IDS_NEWPOLICY_TYPE_SUBTITLE,
  143. false
  144. ),
  145. parent(wizard)
  146. {
  147. }
  148. LRESULT NewPolicyTypePage::OnWizardNext()
  149. {
  150. switch (parent.getType())
  151. {
  152. case NewPolicyWizard::OUTSOURCED:
  153. return IDD_NEWPOLICY_OUTSOURCE;
  154. case NewPolicyWizard::DIRECT:
  155. return IDD_NEWPOLICY_NOTNEEDED;
  156. default:
  157. return IDD_NEWPOLICY_FORWARD;
  158. }
  159. }
  160. void NewPolicyTypePage::onButtonClick(UINT id)
  161. {
  162. switch (id)
  163. {
  164. case IDC_RADIO_LOCAL:
  165. case IDC_RADIO_FORWARD:
  166. getRadio(IDC_RADIO_LOCAL, IDC_RADIO_FORWARD, parent.radius);
  167. setControlState();
  168. break;
  169. case IDC_RADIO_OUTSOURCE:
  170. case IDC_RADIO_DIRECT:
  171. getRadio(IDC_RADIO_OUTSOURCE, IDC_RADIO_DIRECT, parent.dialin);
  172. }
  173. }
  174. void NewPolicyTypePage::setData()
  175. {
  176. // Set the radio buttons.
  177. setRadio(IDC_RADIO_LOCAL, IDC_RADIO_FORWARD, parent.radius);
  178. setRadio(IDC_RADIO_OUTSOURCE, IDC_RADIO_DIRECT, parent.dialin);
  179. // Update the control state.
  180. setControlState();
  181. }
  182. void NewPolicyTypePage::setControlState()
  183. {
  184. // Enable/disable the inner radio buttons.
  185. enableControl(IDC_RADIO_OUTSOURCE, !parent.radius);
  186. enableControl(IDC_RADIO_DIRECT, !parent.radius);
  187. // Enable the wizard buttons.
  188. parent.SetWizardButtons(PSWIZB_NEXT | PSWIZB_BACK);
  189. }
  190. BEGIN_MESSAGE_MAP(NewPolicyTypePage, SnapInPropertyPage)
  191. ON_CONTROL_RANGE(
  192. BN_CLICKED,
  193. IDC_RADIO_LOCAL,
  194. IDC_RADIO_DIRECT,
  195. onButtonClick
  196. )
  197. END_MESSAGE_MAP()
  198. NewPolicyOutsourcePage::NewPolicyOutsourcePage(NewPolicyWizard& wizard)
  199. : SnapInPropertyPage(
  200. IDD_NEWPOLICY_OUTSOURCE,
  201. IDS_NEWPOLICY_OUTSRC_TITLE,
  202. IDS_NEWPOLICY_OUTSRC_SUBTITLE,
  203. false
  204. ),
  205. parent(wizard),
  206. strip(true)
  207. {
  208. }
  209. LRESULT NewPolicyOutsourcePage::OnWizardBack()
  210. {
  211. // Save the strip checkbox.
  212. getValue(IDC_CHECK_STRIP, strip);
  213. return IDD_NEWPOLICY_TYPE;
  214. }
  215. LRESULT NewPolicyOutsourcePage::OnWizardNext()
  216. {
  217. // The policy triggers based on realm.
  218. SetRealmCondition(parent.conditions, realm);
  219. // We use Windows authentication.
  220. parent.attributes.clear();
  221. parent.attributes.setValue(IAS_ATTRIBUTE_AUTH_PROVIDER_TYPE, 1L);
  222. // If the user wants to strip the realm, ...
  223. getValue(IDC_CHECK_STRIP, strip);
  224. if (strip)
  225. {
  226. // ... then add a rule.
  227. AddRealmStrippingRule(parent.attributes, realm);
  228. }
  229. return IDD_NEWPOLICY_COMPLETION;
  230. }
  231. void NewPolicyOutsourcePage::onChangeRealm()
  232. {
  233. getValue(IDC_EDIT_REALM, realm);
  234. setButtons();
  235. }
  236. void NewPolicyOutsourcePage::setData()
  237. {
  238. setValue(IDC_EDIT_REALM, realm);
  239. setValue(IDC_CHECK_STRIP, strip);
  240. setButtons();
  241. }
  242. void NewPolicyOutsourcePage::setButtons()
  243. {
  244. parent.SetWizardButtons(
  245. realm.Length() ? (PSWIZB_BACK | PSWIZB_NEXT) : PSWIZB_BACK
  246. );
  247. }
  248. BEGIN_MESSAGE_MAP(NewPolicyOutsourcePage, SnapInPropertyPage)
  249. ON_EN_CHANGE(IDC_EDIT_REALM, onChangeRealm)
  250. END_MESSAGE_MAP()
  251. NewPolicyDirectPage::NewPolicyDirectPage(NewPolicyWizard& wizard)
  252. : SnapInPropertyPage(IDD_NEWPOLICY_NOTNEEDED, 0, 0, false),
  253. parent(wizard)
  254. {
  255. }
  256. BOOL NewPolicyDirectPage::OnInitDialog()
  257. {
  258. SnapInPropertyPage::OnInitDialog();
  259. setLargeFont(IDC_STATIC_LARGE);
  260. return TRUE;
  261. }
  262. BOOL NewPolicyDirectPage::OnSetActive()
  263. {
  264. SnapInPropertyPage::OnSetActive();
  265. parent.SetWizardButtons(PSWIZB_FINISH | PSWIZB_BACK);
  266. return TRUE;
  267. }
  268. LRESULT NewPolicyDirectPage::OnWizardBack()
  269. {
  270. return IDD_NEWPOLICY_TYPE;
  271. }
  272. NewPolicyForwardPage::NewPolicyForwardPage(NewPolicyWizard& wizard)
  273. : SnapInPropertyPage(
  274. IDD_NEWPOLICY_FORWARD,
  275. IDS_NEWPOLICY_FWD_TITLE,
  276. IDS_NEWPOLICY_FWD_SUBTITLE,
  277. false
  278. ),
  279. parent(wizard),
  280. strip(true)
  281. {
  282. }
  283. LRESULT NewPolicyForwardPage::OnWizardBack()
  284. {
  285. // Save the data.
  286. getValue(IDC_CHECK_STRIP, strip);
  287. getValue(IDC_COMBO_GROUP, providerName);
  288. return IDD_NEWPOLICY_TYPE;
  289. }
  290. LRESULT NewPolicyForwardPage::OnWizardNext()
  291. {
  292. // The policy triggers based on realm.
  293. SetRealmCondition(parent.conditions, realm);
  294. // Get the RADIUS server group.
  295. getValue(IDC_COMBO_GROUP, providerName);
  296. parent.attributes.clear();
  297. // Set both authentication and accounting to use the group.
  298. parent.attributes.setValue(IAS_ATTRIBUTE_AUTH_PROVIDER_TYPE, 2L);
  299. parent.attributes.setValue(IAS_ATTRIBUTE_AUTH_PROVIDER_NAME, providerName);
  300. parent.attributes.setValue(IAS_ATTRIBUTE_ACCT_PROVIDER_TYPE, 2L);
  301. parent.attributes.setValue(IAS_ATTRIBUTE_ACCT_PROVIDER_NAME, providerName);
  302. // If the user wants to strip the realm, ...
  303. getValue(IDC_CHECK_STRIP, strip);
  304. if (strip)
  305. {
  306. // ... then add a rule.
  307. AddRealmStrippingRule(parent.attributes, realm);
  308. }
  309. return IDD_NEWPOLICY_COMPLETION;
  310. }
  311. void NewPolicyForwardPage::onChangeRealm()
  312. {
  313. getValue(IDC_EDIT_REALM, realm);
  314. setButtons();
  315. }
  316. void NewPolicyForwardPage::onNewGroup()
  317. {
  318. // Fire up the wizard.
  319. NewGroupWizard wizard(parent.cxn, parent.view);
  320. if (wizard.DoModal() != IDCANCEL)
  321. {
  322. // Set the provider name to the group just created.
  323. wizard.group.getName(providerName);
  324. // Repopulate the combo box.
  325. setData();
  326. }
  327. }
  328. void NewPolicyForwardPage::setData()
  329. {
  330. // Set the realm information.
  331. setValue(IDC_EDIT_REALM, realm);
  332. setValue(IDC_CHECK_STRIP, strip);
  333. initControl(IDC_COMBO_GROUP, groupsCombo);
  334. groupsCombo.ResetContent();
  335. // Get the server groups collection if necessary.
  336. if (!serverGroups) { serverGroups = parent.cxn.getServerGroups(); }
  337. // Are there any server groups configured?
  338. if (serverGroups.count())
  339. {
  340. // Yes, so add them to the combo box.
  341. Sdo group;
  342. SdoEnum sdoEnum = serverGroups.getNewEnum();
  343. while (sdoEnum.next(group))
  344. {
  345. CComBSTR name;
  346. group.getName(name);
  347. int index = groupsCombo.AddString(name);
  348. // We'll also look for our provider. We can't use
  349. // CComboBox::FindStringExact because it's not case-sensitive.
  350. if (providerName && !wcscmp(name, providerName))
  351. {
  352. // Select it in the combo box.
  353. groupsCombo.SetCurSel(index);
  354. }
  355. }
  356. groupsCombo.EnableWindow(TRUE);
  357. }
  358. else
  359. {
  360. // If there aren't groups, add the <None configured> string.
  361. groupsCombo.AddString(ResourceString(IDS_POLICY_NO_GROUPS));
  362. groupsCombo.EnableWindow(FALSE);
  363. }
  364. // Make sure something is selected.
  365. if (groupsCombo.GetCurSel() == CB_ERR)
  366. {
  367. groupsCombo.SetCurSel(0);
  368. }
  369. setButtons();
  370. }
  371. void NewPolicyForwardPage::setButtons()
  372. {
  373. DWORD buttons = PSWIZB_BACK;
  374. if (realm.Length() && serverGroups.count())
  375. {
  376. buttons |= PSWIZB_NEXT;
  377. }
  378. parent.SetWizardButtons(buttons);
  379. }
  380. BEGIN_MESSAGE_MAP(NewPolicyForwardPage, SnapInPropertyPage)
  381. ON_EN_CHANGE(IDC_EDIT_REALM, onChangeRealm)
  382. ON_BN_CLICKED(IDC_BUTTON_NEWGROUP, onNewGroup)
  383. END_MESSAGE_MAP()
  384. NewPolicyConditionPage::NewPolicyConditionPage(NewPolicyWizard& wizard)
  385. : SnapInPropertyPage(
  386. IDD_NEWPOLICY_CONDITIONS,
  387. IDS_NEWPOLICY_COND_TITLE,
  388. IDS_NEWPOLICY_COND_SUBTITLE,
  389. false
  390. ),
  391. parent(wizard)
  392. {
  393. }
  394. BOOL NewPolicyConditionPage::OnInitDialog()
  395. {
  396. initControl(IDC_LIST_POLICYPAGE1_CONDITIONS, listBox);
  397. CComBSTR name;
  398. parent.policy.getName(name);
  399. condList.finalConstruct(
  400. m_hWnd,
  401. parent.cxn.getCIASAttrList(),
  402. ALLOWEDINPROXYCONDITION,
  403. parent.cxn.getDictionary(),
  404. parent.conditions,
  405. parent.cxn.getMachineName(),
  406. name
  407. );
  408. condList.onInitDialog();
  409. return SnapInPropertyPage::OnInitDialog();
  410. }
  411. LRESULT NewPolicyConditionPage::OnWizardBack()
  412. {
  413. return IDD_NEWPOLICY_NAME;
  414. }
  415. LRESULT NewPolicyConditionPage::OnWizardNext()
  416. {
  417. condList.onApply();
  418. return 0;
  419. }
  420. void NewPolicyConditionPage::onAdd()
  421. {
  422. BOOL modified = FALSE;
  423. condList.onAdd(modified);
  424. if (modified) { setButtons(); }
  425. }
  426. void NewPolicyConditionPage::onEdit()
  427. {
  428. BOOL handled, modified = FALSE;
  429. condList.onEdit(modified, handled);
  430. }
  431. void NewPolicyConditionPage::onRemove()
  432. {
  433. BOOL handled, modified = FALSE;
  434. condList.onRemove(modified, handled);
  435. if (modified) { setButtons(); }
  436. }
  437. void NewPolicyConditionPage::setData()
  438. {
  439. setButtons();
  440. }
  441. void NewPolicyConditionPage::setButtons()
  442. {
  443. parent.SetWizardButtons(
  444. listBox.GetCount() ? (PSWIZB_BACK | PSWIZB_NEXT) : PSWIZB_BACK
  445. );
  446. }
  447. BEGIN_MESSAGE_MAP(NewPolicyConditionPage, SnapInPropertyPage)
  448. ON_BN_CLICKED(IDC_BUTTON_CONDITION_ADD, onAdd)
  449. ON_BN_CLICKED(IDC_BUTTON_CONDITION_EDIT, onEdit)
  450. ON_BN_CLICKED(IDC_BUTTON_CONDITION_REMOVE, onRemove)
  451. ON_LBN_DBLCLK(IDC_LIST_CONDITIONS, onEdit)
  452. END_MESSAGE_MAP()
  453. NewPolicyProfilePage::NewPolicyProfilePage(NewPolicyWizard& wizard)
  454. : SnapInPropertyPage(
  455. IDD_NEWPOLICY_PROFILE,
  456. IDS_NEWPOLICY_PROF_TITLE,
  457. IDS_NEWPOLICY_PROF_SUBTITLE,
  458. false
  459. ),
  460. parent(wizard)
  461. {
  462. }
  463. BOOL NewPolicyProfilePage::OnSetActive()
  464. {
  465. SnapInPropertyPage::OnSetActive();
  466. parent.SetWizardButtons(PSWIZB_NEXT | PSWIZB_BACK);
  467. return TRUE;
  468. }
  469. void NewPolicyProfilePage::onEditProfile()
  470. {
  471. ProxyProfileProperties profile(parent.profile, parent.cxn);
  472. profile.DoModal();
  473. }
  474. BEGIN_MESSAGE_MAP(NewPolicyProfilePage, SnapInPropertyPage)
  475. ON_BN_CLICKED(IDC_BUTTON_EDIT, onEditProfile)
  476. END_MESSAGE_MAP()
  477. NewPolicyFinishPage::NewPolicyFinishPage(NewPolicyWizard& wizard)
  478. : SnapInPropertyPage(IDD_NEWPOLICY_COMPLETION, 0, 0, false),
  479. parent(wizard)
  480. {
  481. }
  482. BOOL NewPolicyFinishPage::OnInitDialog()
  483. {
  484. setLargeFont(IDC_STATIC_LARGE);
  485. initControl(IDC_RICHEDIT_TASKS, tasks);
  486. return SnapInPropertyPage::OnInitDialog();
  487. }
  488. LRESULT NewPolicyFinishPage::OnWizardBack()
  489. {
  490. switch (parent.getType())
  491. {
  492. case NewPolicyWizard::OUTSOURCED:
  493. return IDD_NEWPOLICY_OUTSOURCE;
  494. case NewPolicyWizard::FORWARD:
  495. return IDD_NEWPOLICY_FORWARD;
  496. default:
  497. return IDD_NEWPOLICY_PROFILE;
  498. }
  499. }
  500. void NewPolicyFinishPage::setData()
  501. {
  502. parent.SetWizardButtons(PSWIZB_BACK | PSWIZB_FINISH);
  503. tasks.SetWindowText(parent.getFinishText());
  504. }
  505. void NewPolicyFinishPage::saveChanges()
  506. {
  507. // Persist the policy and profile.
  508. parent.policy.apply();
  509. parent.profile.apply();
  510. }
  511. NewPolicyWizard::NewPolicyWizard(
  512. SdoConnection& connection,
  513. SnapInView* snapInView
  514. )
  515. : CPropertySheetEx(
  516. (UINT)0,
  517. NULL,
  518. 0,
  519. LoadBitmapW(
  520. AfxGetResourceHandle(),
  521. MAKEINTRESOURCEW(IDB_PROXY_POLICY_WATERMARK)
  522. ),
  523. NULL,
  524. LoadBitmapW(
  525. AfxGetResourceHandle(),
  526. MAKEINTRESOURCEW(IDB_PROXY_POLICY_HEADER)
  527. )
  528. ),
  529. cxn(connection),
  530. view(snapInView),
  531. attributes(connection),
  532. custom(0),
  533. radius(0),
  534. dialin(0),
  535. start(*this),
  536. name(*this),
  537. type(*this),
  538. outsource(*this),
  539. direct(*this),
  540. forward(*this),
  541. condition(*this),
  542. profilePage(*this),
  543. finish(*this)
  544. {
  545. m_psh.dwFlags |= PSH_WIZARD97;
  546. AddPage(&start);
  547. AddPage(&name);
  548. AddPage(&type);
  549. AddPage(&outsource);
  550. AddPage(&direct);
  551. AddPage(&forward);
  552. AddPage(&condition);
  553. AddPage(&profilePage);
  554. AddPage(&finish);
  555. }
  556. INT_PTR NewPolicyWizard::DoModal()
  557. {
  558. int retval = CPropertySheetEx::DoModal();
  559. if (retval == IDCANCEL || getType() == DIRECT)
  560. {
  561. // Unmarshal the SDOs.
  562. policyStream.get(policy);
  563. profileStream.get(profile);
  564. // User cancelled, so remove the policy and profile.
  565. cxn.getProxyPolicies().remove(policy);
  566. cxn.getProxyProfiles().remove(profile);
  567. }
  568. else if (view)
  569. {
  570. // User created a policy, so send a propertyChanged notification.
  571. cxn.propertyChanged(
  572. *view,
  573. PROPERTY_IAS_PROXYPOLICIES_COLLECTION
  574. );
  575. }
  576. return retval;
  577. }
  578. // Returns a string representation for a provider.
  579. ::CString GetProvider(
  580. SdoProfile& profile,
  581. ATTRIBUTEID typeId,
  582. ATTRIBUTEID nameId
  583. )
  584. {
  585. // Get the provider type. Default is Windows.
  586. LONG type = 1;
  587. profile.getValue(typeId, type);
  588. // Convert to a string.
  589. ::CString provider;
  590. switch (type)
  591. {
  592. case 1:
  593. {
  594. // Windows.
  595. provider.LoadString(IDS_NEWPOLICY_PROVIDER_WINDOWS);
  596. break;
  597. }
  598. case 2:
  599. {
  600. // RADIUS, so use the server group name.
  601. CComBSTR name;
  602. profile.getValue(nameId, name);
  603. provider = name;
  604. break;
  605. }
  606. default:
  607. {
  608. // None.
  609. provider.LoadString(IDS_NEWPOLICY_PROVIDER_NONE);
  610. }
  611. }
  612. return provider;
  613. }
  614. ::CString NewPolicyWizard::getFinishText()
  615. {
  616. using ::CString;
  617. /////////
  618. // Get the insertion strings.
  619. /////////
  620. // Policy name.
  621. CComBSTR policyName;
  622. policy.getName(policyName);
  623. // List of conditions.
  624. ConditionList condList;
  625. condList.finalConstruct(
  626. NULL,
  627. cxn.getCIASAttrList(),
  628. ALLOWEDINPROXYCONDITION,
  629. cxn.getDictionary(),
  630. conditions,
  631. cxn.getMachineName(),
  632. policyName
  633. );
  634. CString conditionText = condList.getDisplayText();
  635. // Authentication provider.
  636. CString authProvider = GetProvider(
  637. attributes,
  638. IAS_ATTRIBUTE_AUTH_PROVIDER_TYPE,
  639. IAS_ATTRIBUTE_AUTH_PROVIDER_NAME
  640. );
  641. // Accounting provider.
  642. CString acctProvider = GetProvider(
  643. attributes,
  644. IAS_ATTRIBUTE_ACCT_PROVIDER_TYPE,
  645. IAS_ATTRIBUTE_ACCT_PROVIDER_NAME
  646. );
  647. //////////
  648. // Format the finish text.
  649. //////////
  650. CString finishText;
  651. finishText.FormatMessage(
  652. IDS_NEWPOLICY_FINISH_TEXT,
  653. (PCWSTR)policyName,
  654. (PCWSTR)conditionText,
  655. (PCWSTR)authProvider,
  656. (PCWSTR)acctProvider
  657. );
  658. return finishText;
  659. }
  660. NewPolicyWizard::Type NewPolicyWizard::getType() const throw ()
  661. {
  662. if (custom) { return CUSTOM; }
  663. if (radius) { return FORWARD; }
  664. if (dialin) { return DIRECT; }
  665. return OUTSOURCED;
  666. }
  667. BOOL NewPolicyWizard::OnInitDialog()
  668. {
  669. // Create the new policy and save it in a stream so we can access it from
  670. // DoModal.
  671. policy = cxn.getProxyPolicies().create();
  672. policyStream.marshal(policy);
  673. // Create the corresponding profile.
  674. profile = cxn.getProxyProfiles().create();
  675. profileStream.marshal(profile);
  676. // Set the merit to zero, so it'll be the highest priority policy.
  677. policy.setValue(PROPERTY_POLICY_MERIT, 0L);
  678. // Get the conditions collection.
  679. policy.getValue(PROPERTY_POLICY_CONDITIONS_COLLECTION, conditions);
  680. // Load the profile attributes.
  681. attributes = profile;
  682. // The auth provider is mandatory, so we'll default it to Windows for now.
  683. attributes.setValue(IAS_ATTRIBUTE_AUTH_PROVIDER_TYPE, 1L);
  684. return CPropertySheetEx::OnInitDialog();
  685. }