Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1872 lines
54 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. /*++
  3. Copyright (C) Microsoft Corporation
  4. Module Name: rapwiz.cpp
  5. Abstract:
  6. We implement the class needed to handle the property pages for a RAP Policy wizard.
  7. Revision History:
  8. History: Created Header 05/04/00 4:31:52 PM
  9. --*/
  10. //////////////////////////////////////////////////////////////////////////////
  11. #include "Precompiled.h"
  12. #include "iasattrlist.h"
  13. #include "condlist.h"
  14. #include "rapwiz.h"
  15. #include "NapUtil.h"
  16. #include "PolicyNode.h"
  17. #include "PoliciesNode.h"
  18. #include "ChangeNotification.h"
  19. #include "dialinusr.h"
  20. #include "safearray.h"
  21. #include "rrascfg.h"
  22. #include "proxyres.h"
  23. #include "ias.h"
  24. #include "varvec.h"
  25. HRESULT InternalGetEapProviders(
  26. LPCWSTR machineName,
  27. AuthProviderArray *pProvList
  28. );
  29. //=======================================================================================
  30. //
  31. //
  32. // CRapWizardData
  33. //
  34. //
  35. //=======================================================================================
  36. // page sequence information
  37. // page id array ends with 0
  38. DWORD __SCEN_NAME_GRP_AUTH_ENCY__[] = {
  39. IDD_NEWRAPWIZ_WELCOME,
  40. IDD_NEWRAPWIZ_NAME,
  41. IDD_NEWRAPWIZ_SCENARIO,
  42. IDD_NEWRAPWIZ_GROUP,
  43. IDD_NEWRAPWIZ_AUTHENTICATION,
  44. IDD_NEWRAPWIZ_ENCRYPTION,
  45. IDD_NEWRAPWIZ_COMPLETION,
  46. 0};
  47. DWORD __SCEN_NAME_GRP_AUTH_ENCY_VPN__[] = {
  48. IDD_NEWRAPWIZ_WELCOME,
  49. IDD_NEWRAPWIZ_NAME,
  50. IDD_NEWRAPWIZ_SCENARIO,
  51. IDD_NEWRAPWIZ_GROUP,
  52. IDD_NEWRAPWIZ_AUTHENTICATION,
  53. IDD_NEWRAPWIZ_ENCRYPTION_VPN,
  54. IDD_NEWRAPWIZ_COMPLETION,
  55. 0};
  56. DWORD __SCEN_NAME_GRP_EAP_ENCY_WIRELESS__[] = {
  57. IDD_NEWRAPWIZ_WELCOME,
  58. IDD_NEWRAPWIZ_NAME,
  59. IDD_NEWRAPWIZ_SCENARIO,
  60. IDD_NEWRAPWIZ_GROUP,
  61. IDD_NEWRAPWIZ_EAP,
  62. IDD_NEWRAPWIZ_COMPLETION,
  63. 0};
  64. DWORD __SCEN_NAME_GRP_EAP__[] = {
  65. IDD_NEWRAPWIZ_WELCOME,
  66. IDD_NEWRAPWIZ_NAME,
  67. IDD_NEWRAPWIZ_SCENARIO,
  68. IDD_NEWRAPWIZ_GROUP,
  69. IDD_NEWRAPWIZ_EAP,
  70. IDD_NEWRAPWIZ_COMPLETION,
  71. 0};
  72. DWORD __SCEN_NAME_COND_ALLW_PROF__[] = {
  73. IDD_NEWRAPWIZ_WELCOME,
  74. IDD_NEWRAPWIZ_NAME,
  75. IDD_NEWRAPWIZ_CONDITION,
  76. IDD_NEWRAPWIZ_ALLOWDENY,
  77. IDD_NEWRAPWIZ_EDITPROFILE,
  78. IDD_NEWRAPWIZ_COMPLETION,
  79. 0};
  80. // top scenarios
  81. CRapWizScenario Scenario_Senarios =
  82. {
  83. IDC_NEWRAPWIZ_NAME_SCENARIO, // ID
  84. FALSE, // No encr
  85. TRUE, // E_EAP
  86. FALSE, // C_EAP
  87. EXCLUDE_AUTH_TYPE, // Exclude flags (authentication, FramedProtocol)
  88. VPN_PORT_CONDITION, // Pre-condition
  89. TRUE, // bSDO
  90. __SCEN_NAME_GRP_AUTH_ENCY__ // pagelist
  91. };
  92. CRapWizScenario Scenario_Manual =
  93. {
  94. IDC_NEWRAPWIZ_NAME_MANUAL,
  95. DONT_CARE,
  96. DONT_CARE,
  97. DONT_CARE,
  98. DONT_CARE,
  99. NULL,
  100. FALSE,
  101. __SCEN_NAME_COND_ALLW_PROF__
  102. };
  103. // sub scenarios
  104. CRapWizScenario Scenario_VPN =
  105. {
  106. IDC_NEWRAPWIZ_SCENARIO_VPN,
  107. FALSE,
  108. TRUE,
  109. FALSE,
  110. EXCLUDE_AUTH_TYPE,
  111. VPN_PORT_CONDITION,
  112. TRUE,
  113. __SCEN_NAME_GRP_AUTH_ENCY_VPN__
  114. };
  115. CRapWizScenario Scenario_DialUp =
  116. {
  117. IDC_NEWRAPWIZ_SCENARIO_DIALUP,
  118. TRUE,
  119. TRUE,
  120. TRUE,
  121. EXCLUDE_AUTH_TYPE,
  122. DIALUP_PORT_CONDITION,
  123. TRUE,
  124. __SCEN_NAME_GRP_AUTH_ENCY__
  125. };
  126. CRapWizScenario Scenario_Wireless =
  127. {
  128. IDC_NEWRAPWIZ_SCENARIO_WIRELESS,
  129. DONT_CARE,
  130. TRUE,
  131. FALSE,
  132. EXCLUDE_AUTH_TYPE | EXCLUDE_DEFAULT_FRAMED,
  133. WIRELESS_PORT_CONDITION,
  134. TRUE,
  135. __SCEN_NAME_GRP_EAP_ENCY_WIRELESS__
  136. };
  137. CRapWizScenario Scenario_Switch =
  138. {
  139. IDC_NEWRAPWIZ_SCENARIO_SWITCH,
  140. DONT_CARE,
  141. TRUE,
  142. TRUE,
  143. EXCLUDE_AUTH_TYPE | EXCLUDE_DEFAULT_FRAMED,
  144. SWITCH_PORT_CONDITION,
  145. TRUE,
  146. __SCEN_NAME_GRP_EAP__
  147. };
  148. CRapWizScenario*
  149. CRapWizardData::m_Scenarios[] = {
  150. &Scenario_Senarios,
  151. &Scenario_Manual,
  152. &Scenario_VPN,
  153. &Scenario_DialUp,
  154. &Scenario_Wireless,
  155. &Scenario_Switch,
  156. NULL};
  157. CRapWizardData::CRapWizardData():
  158. // scenario
  159. m_dwScenarioIndex(0),
  160. // user / group
  161. m_dwUserOrGroup(IDC_NEWRAPWIZ_GROUP_GROUP),
  162. // authentication
  163. m_bMSCHAP(FALSE),
  164. m_bMSCHAP2(TRUE),
  165. m_bEAP(FALSE),
  166. m_dwEAPProvider(0),
  167. // encryption
  168. m_bEncrypt_No(FALSE),
  169. m_bEncrypt_Basic(TRUE),
  170. m_bEncrypt_Strong(TRUE),
  171. m_bEncrypt_Strongest(TRUE),
  172. m_pPolicyNode(NULL),
  173. // Dialin
  174. m_bAllowDialin(FALSE)
  175. {
  176. }
  177. void CRapWizardData::SetInfo(LPCTSTR czMachine, CPolicyNode* pNode, ISdoDictionaryOld* pDic, ISdo* pPolicy, ISdo* pProfile, ISdoCollection* pPolicyCol, ISdoCollection* pProfileCol, ISdoServiceControl* pServiceCtrl, CIASAttrList* pAttrList)
  178. {
  179. // related to MMC
  180. m_pPolicyNode = pNode;
  181. m_NTGroups.m_bstrServerName = czMachine;
  182. // SDO pointers
  183. m_spDictionarySdo = pDic;
  184. m_spPolicySdo = pPolicy;
  185. m_spProfileSdo = pProfile;
  186. m_spPoliciesCollectionSdo = pPolicyCol;
  187. m_spProfilesCollectionSdo = pProfileCol;
  188. m_spSdoServiceControl = pServiceCtrl;
  189. m_pAttrList = pAttrList;
  190. }
  191. DWORD CRapWizardData::GetNextPageId(LPCTSTR pszCurrTemplate)
  192. {
  193. DWORD* pdwPages = m_Scenarios[m_dwScenarioIndex]->m_pdwPages;
  194. if ( pdwPages == NULL )
  195. return 0;
  196. if (pszCurrTemplate == MAKEINTRESOURCE(0))
  197. return pdwPages[0];
  198. int i = 0;
  199. while ( pdwPages[i] != 0 && MAKEINTRESOURCE(pdwPages[i]) != pszCurrTemplate ) i++;
  200. if ( MAKEINTRESOURCE(pdwPages[i]) == pszCurrTemplate )
  201. {
  202. if (pdwPages[i+1] == 0)
  203. // this allows the page to finish
  204. return TRUE;
  205. else
  206. return pdwPages[i+1];
  207. }
  208. else
  209. return NULL;
  210. }
  211. DWORD CRapWizardData::GetPrevPageId(LPCTSTR pszCurrTemplate)
  212. {
  213. DWORD* pdwPages = m_Scenarios[m_dwScenarioIndex]->m_pdwPages;
  214. // when there is no previous page
  215. if ( pdwPages == NULL || pszCurrTemplate == MAKEINTRESOURCE(0) || MAKEINTRESOURCE(pdwPages[0]) == pszCurrTemplate)
  216. return NULL;
  217. int i = 0;
  218. while ( pdwPages[i] != 0 && MAKEINTRESOURCE(pdwPages[i]) != pszCurrTemplate ) i++;
  219. if ( MAKEINTRESOURCE(pdwPages[i]) == pszCurrTemplate )
  220. return pdwPages[i - 1];
  221. else
  222. return NULL;
  223. }
  224. BOOL CRapWizardData::SetScenario(DWORD dwScenario)
  225. {
  226. BOOL bRet = FALSE;
  227. int i = 0;
  228. while (m_Scenarios[i] != 0)
  229. {
  230. if (m_Scenarios[i]->m_dwScenarioID == dwScenario)
  231. {
  232. m_dwScenarioIndex = i;
  233. if (m_Scenarios[i]->m_bAllowClear == FALSE)
  234. m_bEncrypt_No = FALSE;
  235. else if (m_Scenarios[i]->m_bAllowClear == DONT_CARE)
  236. {
  237. // this will cause finish not to populate the attribute
  238. m_bEncrypt_No = TRUE;
  239. m_bEncrypt_Basic = TRUE;
  240. m_bEncrypt_Strong = TRUE;
  241. m_bEncrypt_Strongest = TRUE;
  242. }
  243. bRet = TRUE;
  244. break;
  245. }
  246. i++;
  247. }
  248. return bRet;
  249. }
  250. //////////////////////////////////////////////////////////////////////////////
  251. /*++
  252. CRapWizardData::GetSettingsText
  253. --*/
  254. //////////////////////////////////////////////////////////////////////////////
  255. BOOL CRapWizardData::GetSettingsText(::CString& settingsText)
  256. {
  257. BOOL bRet = TRUE;
  258. ::CString strOutput;
  259. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  260. try{
  261. strOutput.LoadString(IDS_NEWRAPWIZ_COMPLETION_CONDITION);
  262. // condition text -- get condition text from sdo
  263. // Policy name.
  264. CComBSTR policyName;
  265. policyName = m_strPolicyName;
  266. //get the condition collection for this SDO
  267. CComPtr<ISdoCollection> spConditions;
  268. // ====================
  269. // conditions
  270. ::GetSdoInterfaceProperty(
  271. m_spPolicySdo,
  272. PROPERTY_POLICY_CONDITIONS_COLLECTION,
  273. IID_ISdoCollection,
  274. (void **)&spConditions);
  275. // List of conditions.
  276. ConditionList condList;
  277. condList.finalConstruct(
  278. NULL,
  279. m_pAttrList,
  280. ALLOWEDINCONDITION,
  281. m_spDictionarySdo,
  282. spConditions,
  283. m_pPolicyNode->m_pszServerAddress,
  284. policyName
  285. );
  286. strOutput += condList.getDisplayText();
  287. // profile text
  288. // if manual , then only display information -- it was set manually
  289. ::CString temp1;
  290. if (!m_Scenarios[m_dwScenarioIndex]->m_bSheetWriteSDO)
  291. {
  292. temp1.LoadString(IDS_NEWRAPWIZ_COMPLETION_MANUALSET);
  293. strOutput += temp1;
  294. }
  295. else
  296. {
  297. ::CString sep;
  298. // authentication
  299. temp1.LoadString(IDS_NEWRAPWIZ_COMPLETION_AUTHEN);
  300. strOutput += temp1;
  301. if (m_bEAP)
  302. {
  303. ::CString temp2;
  304. temp1.LoadString(IDS_AUTHEN_METHOD_EAP);
  305. temp2.Format(temp1, m_strEAPProvider);
  306. strOutput += temp2;
  307. sep.LoadString(IDS_NEWRAPWIZ_ITEM_SEP);
  308. }
  309. if (m_bMSCHAP)
  310. {
  311. temp1.LoadString(IDS_AUTHEN_METHOD_MSCHAP);
  312. strOutput += sep;
  313. strOutput += temp1;
  314. sep.LoadString(IDS_NEWRAPWIZ_ITEM_SEP);
  315. }
  316. if (m_bMSCHAP2)
  317. {
  318. temp1.LoadString(IDS_AUTHEN_METHOD_MSCHAP2);
  319. strOutput += sep;
  320. strOutput += temp1;
  321. }
  322. // encryption
  323. temp1.LoadString(IDS_NEWRAPWIZ_COMPLETION_ENCRY);
  324. strOutput += temp1;
  325. sep = L"";
  326. if (m_bEncrypt_Basic)
  327. {
  328. temp1.LoadString(IDS_ENCYP_METHOD_BASIC);
  329. strOutput += sep;
  330. strOutput += temp1;
  331. sep.LoadString(IDS_NEWRAPWIZ_ITEM_SEP);
  332. }
  333. if (m_bEncrypt_Strong)
  334. {
  335. temp1.LoadString(IDS_ENCYP_METHOD_STRONG);
  336. strOutput += sep;
  337. strOutput += temp1;
  338. sep.LoadString(IDS_NEWRAPWIZ_ITEM_SEP);
  339. }
  340. if (m_bEncrypt_Strongest)
  341. {
  342. temp1.LoadString(IDS_ENCYP_METHOD_STRONGEST);
  343. strOutput += sep;
  344. strOutput += temp1;
  345. sep.LoadString(IDS_NEWRAPWIZ_ITEM_SEP);
  346. }
  347. if (m_bEncrypt_No)
  348. {
  349. temp1.LoadString(IDS_ENCYP_METHOD_NO);
  350. strOutput += sep;
  351. strOutput += temp1;
  352. }
  353. }
  354. settingsText = strOutput;
  355. }
  356. catch(...)
  357. {
  358. bRet = FALSE;
  359. }
  360. return bRet;
  361. }
  362. //////////////////////////////////////////////////////////////////////////////
  363. /*++
  364. CRapWizardData::OnWizardPreFinish
  365. --*/
  366. //////////////////////////////////////////////////////////////////////////////
  367. BOOL CRapWizardData::OnWizardPreFinish(HWND hWnd)
  368. {
  369. HRESULT hr = S_OK;
  370. //
  371. // when on manual scenario, the condition and profile data are already written in SDO -- but no persisted yet
  372. // when on other scenario, the data are kept in RapWizardData, so we need to write the data to sdo
  373. if (!m_Scenarios[m_dwScenarioIndex]->m_bSheetWriteSDO) // no write the addtional data into SDO
  374. return TRUE;
  375. // clean up profile, and policy object -- in case use used manual
  376. //get the condition collection for this SDO
  377. CComPtr<ISdoCollection> spConditions;
  378. CComPtr<ISdoCollection> spProfileProperties;
  379. VARIANT var;
  380. VariantInit(&var);
  381. CComBSTR bstrName;
  382. CComPtr<IDispatch> spDisp;
  383. CComPtr<ISdo> spCond;
  384. // ====================
  385. // conditions
  386. hr = ::GetSdoInterfaceProperty(
  387. m_spPolicySdo,
  388. PROPERTY_POLICY_CONDITIONS_COLLECTION,
  389. IID_ISdoCollection,
  390. (void **)&spConditions);
  391. if ( FAILED(hr) )
  392. {
  393. ErrorTrace(ERROR_NAPMMC_POLICYPAGE1, "Can't get condition collection Sdo, err = %x", hr);
  394. return FALSE;
  395. }
  396. // clean up conditions
  397. spConditions->RemoveAll();
  398. // preconditions based on scenario
  399. if ( m_Scenarios[m_dwScenarioIndex]->m_lpszPreCond)
  400. {
  401. bstrName = L"PreCondition0";
  402. // prepare new condition
  403. spDisp.Release();
  404. hr = spConditions->Add(bstrName, &spDisp);
  405. ASSERT(hr == S_OK);
  406. spCond.Release();
  407. hr = spDisp->QueryInterface(IID_ISdo, (void**)&spCond);
  408. ASSERT(hr == S_OK);
  409. VariantClear(&var);
  410. V_VT(&var) = VT_BSTR;
  411. V_BSTR(&var) = SysAllocString(m_Scenarios[m_dwScenarioIndex]->m_lpszPreCond);
  412. // put condition with SDO
  413. hr = spCond->PutProperty(PROPERTY_CONDITION_TEXT, &var);
  414. VariantClear(&var);
  415. if( FAILED (hr) )
  416. {
  417. ErrorTrace(DEBUG_NAPMMC_POLICYPAGE1, "Couldn't save this condition, err = %x", hr);
  418. ShowErrorDialog( hWnd
  419. , IDS_ERROR_SDO_ERROR_PUTPROP_CONDTEXT
  420. , NULL
  421. , hr
  422. );
  423. return FALSE;
  424. }
  425. }
  426. // windows group condition
  427. if(m_dwUserOrGroup == IDC_NEWRAPWIZ_GROUP_GROUP)
  428. {
  429. bstrName = L"GrpCondition";
  430. // prepare new condition
  431. spDisp.Release();
  432. hr = spConditions->Add(bstrName, &spDisp);
  433. ASSERT(hr == S_OK);
  434. spCond.Release();
  435. hr = spDisp->QueryInterface(IID_ISdo, (void**)&spCond);
  436. ASSERT(hr == S_OK);
  437. m_NTGroups.PopulateVariantFromGroups(&var);
  438. ::CString str;
  439. // now form the condition text
  440. str = NTG_PREFIX;
  441. str += _T("(\"");
  442. str += V_BSTR(&var);
  443. str += _T("\")");
  444. VariantClear(&var);
  445. V_VT(&var) = VT_BSTR;
  446. V_BSTR(&var) = SysAllocString((LPCTSTR)str);
  447. // put condition with SDO
  448. hr = spCond->PutProperty(PROPERTY_CONDITION_TEXT, &var);
  449. VariantClear(&var);
  450. if( FAILED (hr) )
  451. {
  452. ErrorTrace(DEBUG_NAPMMC_POLICYPAGE1, "Couldn't save this condition, err = %x", hr);
  453. ShowErrorDialog( hWnd
  454. , IDS_ERROR_SDO_ERROR_PUTPROP_CONDTEXT
  455. , NULL
  456. , hr
  457. );
  458. return FALSE;
  459. }
  460. }
  461. // ====================
  462. // profile properties
  463. hr = ::GetSdoInterfaceProperty(
  464. m_spProfileSdo,
  465. PROPERTY_PROFILE_ATTRIBUTES_COLLECTION,
  466. IID_ISdoCollection,
  467. (void **)&spProfileProperties);
  468. if ( FAILED(hr) )
  469. {
  470. ErrorTrace(ERROR_NAPMMC_POLICYPAGE1, "Can't get property collection Sdo, err = %x", hr);
  471. return FALSE;
  472. }
  473. // clean up profiles -- in case use went to manual mode first, and then came back to other scenarios
  474. spProfileProperties->RemoveAll();
  475. ((CPoliciesNode*)m_pPolicyNode->m_pParentNode)->AddDefaultProfileAttrs(
  476. m_spProfileSdo,
  477. m_Scenarios[m_dwScenarioIndex]->m_excludeFlag
  478. );
  479. // authentication -- attributes
  480. DWORD MyArray[6];
  481. DWORD dwNextCel = 0;
  482. if (m_bEAP && m_dwEAPProvider != 0)
  483. {
  484. MyArray[dwNextCel++] = IAS_AUTH_EAP;
  485. VariantClear(&var);
  486. CVariantVector<VARIANT> eapArray(&var, 1);
  487. VARIANT varEap;
  488. VariantInit(&varEap);
  489. V_VT(&varEap) = VT_I4;
  490. V_I4(&varEap) = m_dwEAPProvider;
  491. eapArray[0] = varEap;
  492. ((CPoliciesNode*)m_pPolicyNode->m_pParentNode)->AddProfAttr(spProfileProperties, IAS_ATTRIBUTE_NP_ALLOWED_EAP_TYPE, &var);
  493. VariantClear(&var);
  494. m_eapProfile.ClearExcept(static_cast<BYTE>(m_dwEAPProvider));
  495. if (!m_eapProfile.IsEmpty())
  496. {
  497. HRESULT hr = m_eapProfile.Store(var);
  498. if (SUCCEEDED(hr))
  499. {
  500. static_cast<CPoliciesNode*>(
  501. m_pPolicyNode->m_pParentNode
  502. )->AddProfAttr(
  503. spProfileProperties,
  504. IAS_ATTRIBUTE_EAP_CONFIG,
  505. &var
  506. );
  507. VariantClear(&var);
  508. }
  509. }
  510. }
  511. if (m_bMSCHAP)
  512. {
  513. MyArray[dwNextCel++] = IAS_AUTH_MSCHAP;
  514. MyArray[dwNextCel++] = IAS_AUTH_MSCHAP_CPW;
  515. }
  516. if (m_bMSCHAP2)
  517. {
  518. MyArray[dwNextCel++] = IAS_AUTH_MSCHAP2;
  519. MyArray[dwNextCel++] = IAS_AUTH_MSCHAP2_CPW;
  520. }
  521. // put new value
  522. CSafeArray<CComVariant, VT_VARIANT> Values = Dim(dwNextCel); // 2 values
  523. Values.Lock();
  524. for ( int i = 0; i < dwNextCel; i++)
  525. {
  526. VariantClear(&var);
  527. V_VT(&var) = VT_I4;
  528. V_I4(&var) = MyArray[i];
  529. Values[i] = var;
  530. VariantClear(&var);
  531. }
  532. Values.Unlock();
  533. if(dwNextCel > 0)
  534. {
  535. SAFEARRAY sa = (SAFEARRAY)Values;
  536. V_VT(&var) = VT_ARRAY | VT_VARIANT;
  537. V_ARRAY(&var) = &sa;
  538. ((CPoliciesNode*)m_pPolicyNode->m_pParentNode)->AddProfAttr(spProfileProperties, IAS_ATTRIBUTE_NP_AUTHENTICATION_TYPE, &var);
  539. // not to call VariantClear, since the SAFEARRAY is not allocated using normal way
  540. VariantInit(&var);
  541. }
  542. // encryption
  543. DWORD EncPolicy = 0;
  544. DWORD EncType = 0;
  545. // ignore the default case -- allow anything, -- remove the attributes
  546. if (!(m_bEncrypt_No && m_bEncrypt_Basic && m_bEncrypt_Strong && m_bEncrypt_Strongest))
  547. {
  548. if(m_bEncrypt_No)
  549. EncPolicy = RAS_EP_ALLOW;
  550. else
  551. EncPolicy = RAS_EP_REQUIRE;
  552. if ( m_bEncrypt_Basic )
  553. EncType |= RAS_ET_BASIC;
  554. if ( m_bEncrypt_Strong )
  555. EncType |= RAS_ET_STRONG;
  556. if ( m_bEncrypt_Strongest )
  557. EncType |= RAS_ET_STRONGEST;
  558. V_VT(&var) = VT_I4;
  559. V_I4(&var) = EncType;
  560. ((CPoliciesNode*)m_pPolicyNode->m_pParentNode)->AddProfAttr(spProfileProperties, RAS_ATTRIBUTE_ENCRYPTION_TYPE, &var);
  561. VariantClear(&var);
  562. V_VT(&var) = VT_I4;
  563. V_I4(&var) = EncPolicy;
  564. ((CPoliciesNode*)m_pPolicyNode->m_pParentNode)->AddProfAttr(spProfileProperties, RAS_ATTRIBUTE_ENCRYPTION_POLICY, &var);
  565. VariantClear(&var);
  566. }
  567. // Dialin
  568. V_VT(&var) = VT_BOOL;
  569. V_I4(&var) = (m_bAllowDialin)? VARIANT_TRUE : VARIANT_FALSE;
  570. ((CPoliciesNode*)m_pPolicyNode->m_pParentNode)->AddProfAttr(spProfileProperties, IAS_ATTRIBUTE_ALLOW_DIALIN, &var);
  571. VariantClear(&var);
  572. return TRUE;
  573. }
  574. //////////////////////////////////////////////////////////////////////////////
  575. /*++
  576. CRapWizardData::OnWizardFinish
  577. --*/
  578. //////////////////////////////////////////////////////////////////////////////
  579. BOOL CRapWizardData::OnWizardFinish(HWND hWnd)
  580. {
  581. HRESULT hr = S_OK;
  582. try
  583. {
  584. // We should just be able to Apply here because the user has hit the Finish button.
  585. hr = m_spPolicySdo->Apply();
  586. if( FAILED( hr ) )
  587. {
  588. // can't commit on Policy
  589. ErrorTrace(ERROR_NAPMMC_POLICYPAGE1, "PolicySdo->Apply() failed, err = %x", hr);
  590. if(hr == DB_E_NOTABLE) // assume, the RPC connection has problem
  591. ShowErrorDialog( hWnd, IDS_ERROR__NOTABLE_TO_WRITE_SDO );
  592. else if(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS))
  593. ShowErrorDialog( hWnd, IDS_ERROR_INVALID_POLICYNAME );
  594. else
  595. ShowErrorDialog( hWnd, IDS_ERROR_SDO_ERROR_POLICY_APPLY, NULL, hr );
  596. throw hr;
  597. }
  598. hr = m_spProfileSdo->Apply();
  599. if( FAILED( hr ) )
  600. {
  601. if(hr == DB_E_NOTABLE) // assume, the RPC connection has problem
  602. ShowErrorDialog( hWnd, IDS_ERROR__NOTABLE_TO_WRITE_SDO );
  603. else
  604. {
  605. // can't commit on Profiles
  606. ErrorTrace(ERROR_NAPMMC_POLICYPAGE1, "ProfileSdo->Apply() failed, err = %x", hr);
  607. ShowErrorDialog( hWnd, IDS_ERROR_SDO_ERROR_PROFILE_APPLY, NULL, hr );
  608. }
  609. throw hr;
  610. }
  611. // Tell the service to reload data.
  612. HRESULT hrTemp = m_spSdoServiceControl->ResetService();
  613. if( FAILED( hrTemp ) )
  614. {
  615. ErrorTrace(ERROR_NAPMMC_POLICYPAGE1, "ISdoServiceControl::ResetService() failed, err = %x", hrTemp);
  616. }
  617. // Make sure the node object knows about any changes we made to SDO while in proppage.
  618. m_pPolicyNode->LoadSdoData();
  619. // Add the child to the UI's list of nodes and end this dialog.
  620. DebugTrace(DEBUG_NAPMMC_POLICYPAGE1, "Adding the brand new node...");
  621. CPoliciesNode* pPoliciesNode = (CPoliciesNode*)(m_pPolicyNode->m_pParentNode);
  622. pPoliciesNode->AddSingleChildToListAndCauseViewUpdate( m_pPolicyNode );
  623. }
  624. catch(...)
  625. {
  626. return FALSE;
  627. }
  628. // reset the dirty bit
  629. return TRUE;
  630. }
  631. //=======================================================================================
  632. //
  633. //
  634. // CPolicyWizard_Scenarios
  635. //
  636. //
  637. //=======================================================================================
  638. //+---------------------------------------------------------------------------
  639. //
  640. // Function: CPolicyWizard_Scenarios
  641. // History: Created Header 05/04/00 4:31:52 PM
  642. //
  643. //+---------------------------------------------------------------------------
  644. CPolicyWizard_Scenarios::CPolicyWizard_Scenarios( CRapWizardData* pWizData, LONG_PTR hNotificationHandle,
  645. TCHAR* pTitle, BOOL bOwnsNotificationHandle
  646. )
  647. : m_spWizData(pWizData)
  648. , CIASWizard97Page<CPolicyWizard_Scenarios, IDS_NEWRAPWIZ_SCENARIO_TITLE, IDS_NEWRAPWIZ_SCENARIO_SUBTITLE>( hNotificationHandle, pTitle, bOwnsNotificationHandle )
  649. {
  650. TRACE_FUNCTION("CPolicyWizard_Scenarios::CPolicyWizard_Scenarios");
  651. _ASSERTE(pWizData);
  652. }
  653. //+---------------------------------------------------------------------------
  654. //
  655. // Function: CPolicyWizard_Scenarios
  656. // History: Created Header 05/04/00 4:31:52 PM
  657. //
  658. //+---------------------------------------------------------------------------
  659. CPolicyWizard_Scenarios::~CPolicyWizard_Scenarios()
  660. {
  661. TRACE_FUNCTION("CPolicyWizard_Scenarios::~CPolicyWizard_Scenarios");
  662. }
  663. //////////////////////////////////////////////////////////////////////////////
  664. /*++
  665. CPolicyWizard_Scenarios::OnInitDialog
  666. --*/
  667. //////////////////////////////////////////////////////////////////////////////
  668. LRESULT CPolicyWizard_Scenarios::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  669. {
  670. TRACE_FUNCTION("CPolicyWizard_Scenarios::OnInitDialog");
  671. // uncheck all
  672. // check the default selected one
  673. CheckDlgButton(IDC_NEWRAPWIZ_SCENARIO_VPN, BST_CHECKED);
  674. // clean dirty bit
  675. SetModified(FALSE);
  676. return TRUE;
  677. }
  678. //////////////////////////////////////////////////////////////////////////////
  679. /*++
  680. CPolicyWizard_Scenarios::OnDialinCheck
  681. --*/
  682. //////////////////////////////////////////////////////////////////////////////
  683. LRESULT CPolicyWizard_Scenarios::OnScenario(UINT uMsg, WPARAM wParam, HWND hWnd, BOOL& bHandled)
  684. {
  685. TRACE_FUNCTION("CPolicyWizard_Scenarios::OnScenario");
  686. SetModified(TRUE);
  687. return 0;
  688. }
  689. //////////////////////////////////////////////////////////////////////////////
  690. /*++
  691. CPolicyWizard_Scenarios::OnWizardNext
  692. // History: Created Header 05/04/00 4:31:52 PM
  693. --*/
  694. //////////////////////////////////////////////////////////////////////////////
  695. BOOL CPolicyWizard_Scenarios::OnWizardNext()
  696. {
  697. TRACE_FUNCTION("CPolicyWizard_Scenarios::OnWizardNext");
  698. DWORD dwScenaro = 0;
  699. CRapWizScenario** pS = m_spWizData->GetAllScenarios();
  700. while(*pS != NULL)
  701. {
  702. if (IsDlgButtonChecked((*pS)->m_dwScenarioID))
  703. {
  704. dwScenaro = (*pS)->m_dwScenarioID;
  705. break;
  706. }
  707. pS++;
  708. }
  709. if (dwScenaro == 0)
  710. return FALSE;
  711. // reset the dirty bit
  712. SetModified(FALSE);
  713. m_spWizData->SetScenario(dwScenaro);
  714. return m_spWizData->GetNextPageId(((PROPSHEETPAGE*)(*this))->pszTemplate);
  715. }
  716. //////////////////////////////////////////////////////////////////////////////
  717. /*++
  718. CPolicyWizard_Scenarios::OnSetActive
  719. Return values:
  720. TRUE if the page can be made active
  721. FALSE if the page should be be skipped and the next page should be looked at.
  722. Remarks:
  723. If you want to change which pages are visited based on a user's
  724. choices in a previous page, return FALSE here as appropriate.
  725. --*/
  726. //////////////////////////////////////////////////////////////////////////////
  727. BOOL CPolicyWizard_Scenarios::OnSetActive()
  728. {
  729. ATLTRACE(_T("# CPolicyWizard_Scenarios::OnSetActive\n"));
  730. // MSDN docs say you need to use PostMessage here rather than SendMessage.
  731. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_NEXT | PSWIZB_BACK);
  732. return TRUE;
  733. }
  734. //=======================================================================================
  735. //
  736. //
  737. // CPolicyWizard_Groups
  738. //
  739. //
  740. //=======================================================================================
  741. //+---------------------------------------------------------------------------
  742. //
  743. // Function: CPolicyWizard_Groups
  744. // History: Created Header 05/04/00 4:31:52 PM
  745. //
  746. //+---------------------------------------------------------------------------
  747. CPolicyWizard_Groups::CPolicyWizard_Groups( CRapWizardData* pWizData, LONG_PTR hNotificationHandle,
  748. TCHAR* pTitle, BOOL bOwnsNotificationHandle
  749. )
  750. : m_spWizData(pWizData)
  751. , CIASWizard97Page<CPolicyWizard_Groups, IDS_NEWRAPWIZ_GROUP_TITLE, IDS_NEWRAPWIZ_GROUP_SUBTITLE>( hNotificationHandle, pTitle, bOwnsNotificationHandle )
  752. {
  753. TRACE_FUNCTION("CPolicyWizard_Scenarios::CPolicyWizard_Scenarios");
  754. _ASSERTE(pWizData);
  755. }
  756. //+---------------------------------------------------------------------------
  757. //
  758. // Function: CPolicyWizard_Scenarios
  759. // History: Created Header 05/04/00 4:31:52 PM
  760. //
  761. //+---------------------------------------------------------------------------
  762. CPolicyWizard_Groups::~CPolicyWizard_Groups()
  763. {
  764. TRACE_FUNCTION("CPolicyWizard_Groups::~CPolicyWizard_Groups");
  765. }
  766. //////////////////////////////////////////////////////////////////////////////
  767. /*++
  768. CPolicyWizard_Groups::OnInitDialog
  769. --*/
  770. //////////////////////////////////////////////////////////////////////////////
  771. LRESULT CPolicyWizard_Groups::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  772. {
  773. TRACE_FUNCTION("CPolicyWizard_Groups::OnInitDialog");
  774. // uncheck all
  775. CheckDlgButton(IDC_NEWRAPWIZ_GROUP_USER, BST_UNCHECKED);
  776. CheckDlgButton(IDC_NEWRAPWIZ_GROUP_GROUP, BST_UNCHECKED);
  777. // check the default selected one
  778. CheckDlgButton(m_spWizData->m_dwUserOrGroup, BST_CHECKED);
  779. SetBtnState();
  780. // listview init
  781. HWND hList = GetDlgItem(IDC_NEWRAPWIZ_GROUP_GROUPS);
  782. //
  783. // first, set the list box to 2 columns
  784. //
  785. LVCOLUMN lvc;
  786. int iCol;
  787. WCHAR achColumnHeader[256];
  788. HINSTANCE hInst;
  789. // initialize the LVCOLUMN structure
  790. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  791. lvc.fmt = LVCFMT_LEFT;
  792. lvc.cx = 300;
  793. lvc.pszText = achColumnHeader;
  794. // first column header: name
  795. hInst = _Module.GetModuleInstance();
  796. ::LoadStringW(hInst, IDS_DISPLAY_GROUPS_FIRSTCOLUMN, achColumnHeader, sizeof(achColumnHeader)/sizeof(achColumnHeader[0]));
  797. lvc.iSubItem = 0;
  798. ListView_InsertColumn(hList, 0, &lvc);
  799. // Set the listview control so that double-click anywhere in row selects.
  800. ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
  801. //
  802. // link the list view with help class
  803. m_spWizData->m_NTGroups.SetListView(GetDlgItem(IDC_NEWRAPWIZ_GROUP_GROUPS), this->m_hWnd);
  804. m_spWizData->m_NTGroups.PopulateGroupList( 0 );
  805. // Set some items based on whether the list is empty or not.
  806. if( m_spWizData->m_NTGroups.size() )
  807. {
  808. // Select the first item.
  809. ListView_SetItemState(hList, 0, LVIS_SELECTED, LVIS_SELECTED);
  810. }
  811. else
  812. {
  813. // Make sure the Remove button is not enabled initially.
  814. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_GROUP_REMOVEGROUP), FALSE);
  815. }
  816. // clean dirty bit
  817. SetModified(FALSE);
  818. return TRUE;
  819. }
  820. //////////////////////////////////////////////////////////////////////////////
  821. /*++
  822. CPolicyWizard_Scenarios::OnUserOrGroup
  823. --*/
  824. //////////////////////////////////////////////////////////////////////////////
  825. LRESULT CPolicyWizard_Groups::OnUserOrGroup(UINT uMsg, WPARAM wParam, HWND hWnd, BOOL& bHandled)
  826. {
  827. BOOL bGroup = IsDlgButtonChecked(IDC_NEWRAPWIZ_GROUP_GROUP);
  828. // ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_GROUP_GROUPS), bGroup);
  829. SetBtnState();
  830. // ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_GROUP_ADDGROUP), bGroup);
  831. SetModified(TRUE);
  832. return 0;
  833. }
  834. //////////////////////////////////////////////////////////////////////////////
  835. /*++
  836. CPolicyWizard_Scenarios::OnUserOrGroup
  837. --*/
  838. //////////////////////////////////////////////////////////////////////////////
  839. LRESULT CPolicyWizard_Groups::OnRemoveGroup(UINT uMsg, WPARAM wParam, HWND hWnd, BOOL& bHandled)
  840. {
  841. m_spWizData->m_NTGroups.RemoveSelectedGroups();
  842. SetBtnState();
  843. SetModified(TRUE);
  844. return 0;
  845. }
  846. //////////////////////////////////////////////////////////////////////////////
  847. /*++
  848. CPolicyWizard_Scenarios::OnUserOrGroup
  849. --*/
  850. //////////////////////////////////////////////////////////////////////////////
  851. LRESULT CPolicyWizard_Groups::OnAddGroups(UINT uMsg, WPARAM wParam, HWND hWnd, BOOL& bHandled)
  852. {
  853. m_spWizData->m_NTGroups.AddMoreGroups();
  854. SetBtnState();
  855. SetModified(TRUE);
  856. return 0;
  857. }
  858. //////////////////////////////////////////////////////////////////////////////
  859. /*++
  860. CNewRAPWiz_AllowDeny::OnWizardNext
  861. // History: Created Header 05/04/00 4:31:52 PM
  862. --*/
  863. //////////////////////////////////////////////////////////////////////////////
  864. BOOL CPolicyWizard_Groups::OnWizardNext()
  865. {
  866. DWORD dwScenaro = 0;
  867. if (IsDlgButtonChecked(IDC_NEWRAPWIZ_GROUP_GROUP))
  868. {
  869. m_spWizData->m_dwUserOrGroup = IDC_NEWRAPWIZ_GROUP_GROUP;
  870. m_spWizData->m_bAllowDialin = TRUE;
  871. }
  872. else if (IsDlgButtonChecked(IDC_NEWRAPWIZ_GROUP_USER))
  873. {
  874. m_spWizData->m_dwUserOrGroup = IDC_NEWRAPWIZ_GROUP_USER;
  875. m_spWizData->m_bAllowDialin = FALSE;
  876. }
  877. else
  878. {
  879. return FALSE;
  880. }
  881. // reset the dirty bit
  882. SetModified(FALSE);
  883. return m_spWizData->GetNextPageId(((PROPSHEETPAGE*)(*this))->pszTemplate);
  884. }
  885. //////////////////////////////////////////////////////////////////////////////
  886. /*++
  887. CPolicyWizard_Groups::OnSetActive
  888. Return values:
  889. TRUE if the page can be made active
  890. FALSE if the page should be be skipped and the next page should be looked at.
  891. Remarks:
  892. If you want to change which pages are visited based on a user's
  893. choices in a previous page, return FALSE here as appropriate.
  894. --*/
  895. //////////////////////////////////////////////////////////////////////////////
  896. BOOL CPolicyWizard_Groups::OnSetActive()
  897. {
  898. ATLTRACE(_T("# CPolicyWizard_Groups::OnSetActive\n"));
  899. // MSDN docs say you need to use PostMessage here rather than SendMessage.
  900. SetBtnState();
  901. return TRUE;
  902. }
  903. //////////////////////////////////////////////////////////////////////////////
  904. /*++
  905. CPolicyWizard_Groups::OnListViewItemChanged
  906. We enable or disable the Remove button depending on whether an item is selected.
  907. --*/
  908. //////////////////////////////////////////////////////////////////////////////
  909. LRESULT CPolicyWizard_Groups::OnListViewItemChanged(int idCtrl,
  910. LPNMHDR pnmh,
  911. BOOL& bHandled)
  912. {
  913. SetBtnState();
  914. bHandled = FALSE;
  915. return 0;
  916. }
  917. void CPolicyWizard_Groups::SetBtnState()
  918. {
  919. BOOL bGroup = IsDlgButtonChecked(IDC_NEWRAPWIZ_GROUP_GROUP);
  920. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_GROUP_GROUPS), bGroup);
  921. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_GROUP_GROUPTEXT), bGroup);
  922. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_GROUP_ADDGROUP), bGroup);
  923. // remove button
  924. // Find out what's selected.
  925. int iSelected = ListView_GetNextItem(GetDlgItem(IDC_NEWRAPWIZ_GROUP_GROUPS), -1, LVNI_SELECTED);
  926. if (-1 == iSelected || !bGroup)
  927. {
  928. if( ::GetFocus() == GetDlgItem(IDC_NEWRAPWIZ_GROUP_REMOVEGROUP))
  929. ::SetFocus(GetDlgItem(IDC_NEWRAPWIZ_GROUP_ADDGROUP));
  930. // The user selected nothing, let's disable the remove button.
  931. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_GROUP_REMOVEGROUP), FALSE);
  932. }
  933. else
  934. {
  935. // Yes, enable the remove button.
  936. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_GROUP_REMOVEGROUP), TRUE);
  937. }
  938. // next button
  939. if(bGroup && m_spWizData->m_NTGroups.size() < 1)
  940. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK);
  941. else
  942. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK | PSWIZB_NEXT);
  943. }
  944. //=======================================================================================
  945. //
  946. //
  947. // CPolicyWizard_Authentication
  948. //
  949. //
  950. //=======================================================================================
  951. //+---------------------------------------------------------------------------
  952. //
  953. // Function: CPolicyWizard_Authentication
  954. // History: Created Header 05/04/00 4:31:52 PM
  955. //
  956. //+---------------------------------------------------------------------------
  957. CPolicyWizard_Authentication::CPolicyWizard_Authentication( CRapWizardData* pWizData, LONG_PTR hNotificationHandle,
  958. TCHAR* pTitle, BOOL bOwnsNotificationHandle
  959. )
  960. : m_spWizData(pWizData)
  961. , CIASWizard97Page<CPolicyWizard_Authentication, IDS_NEWRAPWIZ_AUTHENTICATION_TITLE, IDS_NEWRAPWIZ_AUTHENTICATION_SUBTITLE>( hNotificationHandle, pTitle, bOwnsNotificationHandle )
  962. {
  963. TRACE_FUNCTION("CPolicyWizard_Authentication::CPolicyWizard_Authentication");
  964. _ASSERTE(pWizData);
  965. }
  966. //+---------------------------------------------------------------------------
  967. //
  968. // Function: CPolicyWizard_Authentication
  969. // History: Created Header 05/04/00 4:31:52 PM
  970. //
  971. //+---------------------------------------------------------------------------
  972. CPolicyWizard_Authentication::~CPolicyWizard_Authentication()
  973. {
  974. TRACE_FUNCTION("CPolicyWizard_Authentication::~CPolicyWizard_Authentication");
  975. }
  976. //////////////////////////////////////////////////////////////////////////////
  977. /*++
  978. CPolicyWizard_Authentication::OnInitDialog
  979. --*/
  980. //////////////////////////////////////////////////////////////////////////////
  981. LRESULT CPolicyWizard_Authentication::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  982. {
  983. TRACE_FUNCTION("CPolicyWizard_Authentication::OnInitDialog");
  984. // check the default values ...
  985. if (m_spWizData->m_bMSCHAP)
  986. CheckDlgButton(IDC_NEWRAPWIZ_AUTH_MSCHAP, BST_CHECKED);
  987. if (m_spWizData->m_bMSCHAP2)
  988. CheckDlgButton(IDC_NEWRAPWIZ_AUTH_MSCHAP2, BST_CHECKED);
  989. if (m_spWizData->m_bEAP)
  990. CheckDlgButton(IDC_NEWRAPWIZ_AUTH_EAP, BST_CHECKED);
  991. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_AUTH_EAP_COMBO), m_spWizData->m_bEAP);
  992. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_AUTH_CONFIGEAP), m_spWizData->m_bEAP);
  993. // populate EAP providers
  994. HRESULT hr = InternalGetEapProviders(
  995. m_spWizData->m_pPolicyNode->m_pszServerAddress,
  996. &m_EAPProviders);
  997. m_EapBox.Attach(GetDlgItem (IDC_NEWRAPWIZ_AUTH_EAP_COMBO));
  998. ResetEAPList();
  999. // clean dirty bit
  1000. SetModified(FALSE);
  1001. return TRUE;
  1002. }
  1003. //////////////////////////////////////////////////////////////////////////////
  1004. /*++
  1005. CPolicyWizard_Authentication::ResetEAPlist
  1006. --*/
  1007. //////////////////////////////////////////////////////////////////////////////
  1008. void CPolicyWizard_Authentication::ResetEAPList()
  1009. {
  1010. m_EapBox.ResetContent();
  1011. for(int i = 0; i < m_EAPProviders.GetSize(); i++)
  1012. {
  1013. // VPN only shows the ones support encryption
  1014. BOOL bAdd = FALSE;
  1015. if (m_EAPProviders[i].m_fSupportsEncryption && m_spWizData->GetScenario()->m_bAllowEncryptionEAP)
  1016. {
  1017. int iComboIndex = m_EapBox.AddString( m_EAPProviders[i].m_stServerTitle );
  1018. if(iComboIndex != CB_ERR)
  1019. m_EapBox.SetItemData(iComboIndex, i);
  1020. }
  1021. if (!m_EAPProviders[i].m_fSupportsEncryption && m_spWizData->GetScenario()->m_bAllowClearEAP)
  1022. {
  1023. int iComboIndex = m_EapBox.AddString( m_EAPProviders[i].m_stServerTitle );
  1024. if(iComboIndex != CB_ERR)
  1025. m_EapBox.SetItemData(iComboIndex, i);
  1026. }
  1027. };
  1028. if(m_EAPProviders.GetSize() > 0)
  1029. m_EapBox.SetCurSel(0);
  1030. BOOL b;
  1031. OnSelectedEAPChanged(0,0,0, b);
  1032. }
  1033. //////////////////////////////////////////////////////////////////////////////
  1034. /*++
  1035. CPolicyWizard_Authentication::OnUserOrGroup
  1036. --*/
  1037. //////////////////////////////////////////////////////////////////////////////
  1038. LRESULT CPolicyWizard_Authentication::OnAuthSelect(UINT uMsg, WPARAM wParam, HWND hWnd, BOOL& bHandled)
  1039. {
  1040. m_spWizData->m_bEAP = IsDlgButtonChecked(IDC_NEWRAPWIZ_AUTH_EAP);
  1041. m_spWizData->m_bMSCHAP2 = IsDlgButtonChecked(IDC_NEWRAPWIZ_AUTH_MSCHAP2);
  1042. m_spWizData->m_bMSCHAP = IsDlgButtonChecked(IDC_NEWRAPWIZ_AUTH_MSCHAP);
  1043. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_AUTH_EAP_COMBO), m_spWizData->m_bEAP);
  1044. if(m_spWizData->m_bEAP)
  1045. {
  1046. BOOL b;
  1047. OnSelectedEAPChanged(0,0,0, b);
  1048. }
  1049. else
  1050. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_AUTH_CONFIGEAP), m_spWizData->m_bEAP);
  1051. SetModified(TRUE);
  1052. // Find out what's selected.
  1053. int iSelected = m_EapBox.GetCurSel();;
  1054. if ((m_spWizData->m_bEAP && iSelected != -1)|| m_spWizData->m_bMSCHAP2 || m_spWizData->m_bMSCHAP)
  1055. // MSDN docs say you need to use PostMessage here rather than SendMessage.
  1056. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK | PSWIZB_NEXT);
  1057. else
  1058. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK);
  1059. return 0;
  1060. }
  1061. //////////////////////////////////////////////////////////////////////////////
  1062. /*++
  1063. CPolicyWizard_Authentication::OnConfigEAP
  1064. --*/
  1065. //////////////////////////////////////////////////////////////////////////////
  1066. LRESULT CPolicyWizard_Authentication::OnConfigEAP(
  1067. UINT uMsg,
  1068. WPARAM wParam,
  1069. HWND hWnd,
  1070. BOOL& bHandled
  1071. )
  1072. {
  1073. // Find out what's selected.
  1074. int iSelected = m_EapBox.GetCurSel();
  1075. if (iSelected == -1)
  1076. {
  1077. return S_OK;
  1078. }
  1079. DWORD index = m_EapBox.GetItemData(iSelected);
  1080. if (m_EAPProviders[index].m_stConfigCLSID.IsEmpty())
  1081. {
  1082. return S_OK;
  1083. }
  1084. HRESULT hr;
  1085. do
  1086. {
  1087. GUID guid;
  1088. hr = CLSIDFromString(
  1089. const_cast<wchar_t*>(
  1090. static_cast<const wchar_t*>(
  1091. m_EAPProviders[index].m_stConfigCLSID
  1092. )
  1093. ),
  1094. &guid
  1095. );
  1096. if (FAILED(hr))
  1097. {
  1098. break;
  1099. }
  1100. // Create the EAP provider object
  1101. CComPtr<IEAPProviderConfig> spEAPConfig;
  1102. hr = CoCreateInstance(
  1103. guid,
  1104. 0,
  1105. CLSCTX_INPROC_SERVER,
  1106. __uuidof(IEAPProviderConfig),
  1107. reinterpret_cast<void**>(&spEAPConfig)
  1108. );
  1109. if (FAILED(hr))
  1110. {
  1111. break;
  1112. }
  1113. // Configure this EAP provider
  1114. // EAP configure displays its own error message, so no hr is kept
  1115. DWORD dwId = _wtol(m_EAPProviders[index].m_stKey);
  1116. ULONG_PTR uConnection = 0;
  1117. hr = spEAPConfig->Initialize(
  1118. m_spWizData->m_pPolicyNode->m_pszServerAddress,
  1119. dwId,
  1120. &uConnection
  1121. );
  1122. if (SUCCEEDED(hr))
  1123. {
  1124. CComPtr<IEAPProviderConfig2> spEAPConfig2;
  1125. hr = spEAPConfig->QueryInterface(
  1126. __uuidof(IEAPProviderConfig2),
  1127. reinterpret_cast<void**>(&spEAPConfig2)
  1128. );
  1129. if (SUCCEEDED(hr))
  1130. {
  1131. EapProfile::ConstConfigData inData;
  1132. m_spWizData->m_eapProfile.Get(static_cast<BYTE>(dwId), inData);
  1133. EapProfile::ConfigData outData = { 0, 0 };
  1134. hr = spEAPConfig2->ServerInvokeConfigUI2(
  1135. dwId,
  1136. uConnection,
  1137. m_hWnd,
  1138. inData.value,
  1139. inData.length,
  1140. &(outData.value),
  1141. &(outData.length)
  1142. );
  1143. if (SUCCEEDED(hr))
  1144. {
  1145. hr = m_spWizData->m_eapProfile.Set(
  1146. static_cast<BYTE>(dwId),
  1147. outData
  1148. );
  1149. CoTaskMemFree(outData.value);
  1150. }
  1151. }
  1152. else
  1153. {
  1154. // Bring up the configuration UI for this EAP
  1155. hr = spEAPConfig->ServerInvokeConfigUI(
  1156. dwId,
  1157. uConnection,
  1158. m_hWnd,
  1159. 0,
  1160. 0
  1161. );
  1162. }
  1163. spEAPConfig->Uninitialize(dwId, uConnection);
  1164. }
  1165. }
  1166. while (false);
  1167. if (FAILED(hr))
  1168. {
  1169. ShowErrorDialog(m_hWnd, IDS_FAILED_CONFIG_EAP, NULL, hr, 0);
  1170. }
  1171. SetModified(TRUE);
  1172. return 0;
  1173. }
  1174. //////////////////////////////////////////////////////////////////////////////
  1175. /*++
  1176. CPolicyWizard_Authentication::OnWizardNext
  1177. // History: Created Header 05/04/00 4:31:52 PM
  1178. --*/
  1179. //////////////////////////////////////////////////////////////////////////////
  1180. BOOL CPolicyWizard_Authentication::OnWizardNext()
  1181. {
  1182. // reset the dirty bit
  1183. SetModified(FALSE);
  1184. return m_spWizData->GetNextPageId(((PROPSHEETPAGE*)(*this))->pszTemplate);
  1185. }
  1186. //////////////////////////////////////////////////////////////////////////////
  1187. /*++
  1188. CPolicyWizard_Groups::OnSetActive
  1189. Return values:
  1190. TRUE if the page can be made active
  1191. FALSE if the page should be be skipped and the next page should be looked at.
  1192. Remarks:
  1193. If you want to change which pages are visited based on a user's
  1194. choices in a previous page, return FALSE here as appropriate.
  1195. --*/
  1196. //////////////////////////////////////////////////////////////////////////////
  1197. BOOL CPolicyWizard_Authentication::OnSetActive()
  1198. {
  1199. ATLTRACE(_T("# CPolicyWizard_Groups::OnSetActive\n"));
  1200. ResetEAPList();
  1201. // Find out what's selected.
  1202. int iSelected = m_EapBox.GetCurSel();;
  1203. if( m_spWizData->m_bEAP && iSelected == -1)
  1204. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK);
  1205. else
  1206. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK | PSWIZB_NEXT);
  1207. return TRUE;
  1208. }
  1209. //////////////////////////////////////////////////////////////////////////////
  1210. /*++
  1211. CPolicyWizard_Groups::OnListViewItemChanged
  1212. We enable or disable the Remove button depending on whether an item is selected.
  1213. --*/
  1214. //////////////////////////////////////////////////////////////////////////////
  1215. LRESULT CPolicyWizard_Authentication::OnSelectedEAPChanged(
  1216. UINT uMsg
  1217. , WPARAM wParam
  1218. , HWND hwnd
  1219. , BOOL& bHandled
  1220. )
  1221. {
  1222. // Find out what's selected.
  1223. int iSelected = m_EapBox.GetCurSel();;
  1224. if (-1 == iSelected )
  1225. {
  1226. if( ::GetFocus() == GetDlgItem(IDC_NEWRAPWIZ_AUTH_CONFIGEAP))
  1227. ::SetFocus(GetDlgItem(IDC_NEWRAPWIZ_AUTH_EAP_COMBO));
  1228. // The user selected nothing, let's disable the remove button.
  1229. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_AUTH_CONFIGEAP), FALSE);
  1230. m_spWizData->m_dwEAPProvider = 0;
  1231. }
  1232. else
  1233. {
  1234. // enable configure button if it's configrable
  1235. DWORD index = m_EapBox.GetItemData(iSelected);
  1236. m_spWizData->m_dwEAPProvider = _ttol(m_EAPProviders[index].m_stKey);
  1237. m_spWizData->m_strEAPProvider = m_EAPProviders[index].m_stServerTitle;
  1238. ::EnableWindow(GetDlgItem(IDC_NEWRAPWIZ_AUTH_CONFIGEAP), (!m_EAPProviders[index].m_stConfigCLSID.IsEmpty()));
  1239. }
  1240. bHandled = FALSE;
  1241. return 0;
  1242. }
  1243. //=======================================================================================
  1244. //
  1245. //
  1246. // CPolicyWizard_EAP
  1247. //
  1248. //
  1249. //=======================================================================================
  1250. //////////////////////////////////////////////////////////////////////////////
  1251. /*++
  1252. CPolicyWizard_EAP::OnInitDialog
  1253. --*/
  1254. //////////////////////////////////////////////////////////////////////////////
  1255. LRESULT CPolicyWizard_EAP::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1256. {
  1257. TRACE_FUNCTION("CPolicyWizard_EAP::OnInitDialog");
  1258. m_spWizData->m_bEAP = TRUE;
  1259. m_spWizData->m_bMSCHAP2 = FALSE;
  1260. m_spWizData->m_bMSCHAP = FALSE;
  1261. // populate EAP providers
  1262. HRESULT hr = InternalGetEapProviders(
  1263. m_spWizData->m_pPolicyNode->m_pszServerAddress,
  1264. &m_EAPProviders);
  1265. m_EapBox.Attach(GetDlgItem (IDC_NEWRAPWIZ_AUTH_EAP_COMBO));
  1266. ResetEAPList();
  1267. // clean dirty bit
  1268. SetModified(FALSE);
  1269. return TRUE;
  1270. }
  1271. //////////////////////////////////////////////////////////////////////////////
  1272. /*++
  1273. CPolicyWizard_EAP::OnSetActive
  1274. Return values:
  1275. TRUE if the page can be made active
  1276. FALSE if the page should be be skipped and the next page should be looked at.
  1277. Remarks:
  1278. If you want to change which pages are visited based on a user's
  1279. choices in a previous page, return FALSE here as appropriate.
  1280. --*/
  1281. //////////////////////////////////////////////////////////////////////////////
  1282. BOOL CPolicyWizard_EAP::OnSetActive()
  1283. {
  1284. ATLTRACE(_T("# CPolicyWizard_Groups::OnSetActive\n"));
  1285. ResetEAPList();
  1286. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK | PSWIZB_NEXT);
  1287. return TRUE;
  1288. }
  1289. //=======================================================================================
  1290. //
  1291. //
  1292. // CPolicyWizard_Encryption
  1293. //
  1294. //
  1295. //=======================================================================================
  1296. //+---------------------------------------------------------------------------
  1297. //
  1298. // Function: CPolicyWizard_Encryption
  1299. // History: Created Header 05/04/00 4:31:52 PM
  1300. //
  1301. //+---------------------------------------------------------------------------
  1302. CPolicyWizard_Encryption::CPolicyWizard_Encryption( CRapWizardData* pWizData, LONG_PTR hNotificationHandle,
  1303. TCHAR* pTitle, BOOL bOwnsNotificationHandle
  1304. )
  1305. : m_spWizData(pWizData)
  1306. , CIASWizard97Page<CPolicyWizard_Encryption, IDS_NEWRAPWIZ_ENCRYPTION_TITLE, IDS_NEWRAPWIZ_ENCRYPTION_SUBTITLE>( hNotificationHandle, pTitle, bOwnsNotificationHandle )
  1307. {
  1308. TRACE_FUNCTION("CPolicyWizard_Encryption::CPolicyWizard_Encryption");
  1309. _ASSERTE(pWizData);
  1310. }
  1311. //+---------------------------------------------------------------------------
  1312. //
  1313. // Function: CPolicyWizard_Encryption
  1314. // History: Created Header 05/04/00 4:31:52 PM
  1315. //
  1316. //+---------------------------------------------------------------------------
  1317. CPolicyWizard_Encryption::~CPolicyWizard_Encryption()
  1318. {
  1319. TRACE_FUNCTION("CPolicyWizard_Encryption::~CPolicyWizard_Encryption");
  1320. }
  1321. //////////////////////////////////////////////////////////////////////////////
  1322. /*++
  1323. CPolicyWizard_Encryption::OnInitDialog
  1324. --*/
  1325. //////////////////////////////////////////////////////////////////////////////
  1326. LRESULT CPolicyWizard_Encryption::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  1327. {
  1328. TRACE_FUNCTION("CPolicyWizard_Encryption::OnInitDialog");
  1329. // don't show No encryption with VPN IDC_NEWRAPWIZ_ENCRY_NO_STATIC
  1330. if (m_spWizData->GetScenario()->m_bAllowClear)
  1331. {
  1332. ::ShowWindow(GetDlgItem(IDC_NEWRAPWIZ_ENCRY_NO), SW_SHOW);
  1333. }
  1334. else
  1335. {
  1336. ::ShowWindow(GetDlgItem(IDC_NEWRAPWIZ_ENCRY_NO), SW_HIDE);
  1337. }
  1338. // check the default values ...
  1339. if (m_spWizData->m_bEncrypt_No)
  1340. CheckDlgButton(IDC_NEWRAPWIZ_ENCRY_NO, BST_CHECKED);
  1341. if (m_spWizData->m_bEncrypt_Basic)
  1342. CheckDlgButton(IDC_NEWRAPWIZ_ENCRY_BASIC, BST_CHECKED);
  1343. if (m_spWizData->m_bEncrypt_Strong)
  1344. CheckDlgButton(IDC_NEWRAPWIZ_ENCRY_STRONG, BST_CHECKED);
  1345. if (m_spWizData->m_bEncrypt_Strongest)
  1346. CheckDlgButton(IDC_NEWRAPWIZ_ENCRY_STRONGEST, BST_CHECKED);
  1347. // clean dirty bit
  1348. SetModified(FALSE);
  1349. return TRUE;
  1350. }
  1351. //////////////////////////////////////////////////////////////////////////////
  1352. /*++
  1353. CPolicyWizard_Encryption::OnEncryptionSelect
  1354. --*/
  1355. //////////////////////////////////////////////////////////////////////////////
  1356. LRESULT CPolicyWizard_Encryption::OnEncryptionSelect(UINT uMsg, WPARAM wParam, HWND hWnd, BOOL& bHandled)
  1357. {
  1358. m_spWizData->m_bEncrypt_No = IsDlgButtonChecked(IDC_NEWRAPWIZ_ENCRY_NO);
  1359. m_spWizData->m_bEncrypt_Basic = IsDlgButtonChecked(IDC_NEWRAPWIZ_ENCRY_BASIC);
  1360. m_spWizData->m_bEncrypt_Strong = IsDlgButtonChecked(IDC_NEWRAPWIZ_ENCRY_STRONG);
  1361. m_spWizData->m_bEncrypt_Strongest = IsDlgButtonChecked(IDC_NEWRAPWIZ_ENCRY_STRONGEST);
  1362. // reset the dirty bit
  1363. SetModified(TRUE);
  1364. if (m_spWizData->m_bEncrypt_No || m_spWizData->m_bEncrypt_Basic || m_spWizData->m_bEncrypt_Strong || m_spWizData->m_bEncrypt_Strongest)
  1365. // MSDN docs say you need to use PostMessage here rather than SendMessage.
  1366. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK | PSWIZB_NEXT );
  1367. else
  1368. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK);
  1369. return 0;
  1370. }
  1371. //////////////////////////////////////////////////////////////////////////////
  1372. /*++
  1373. CPolicyWizard_Encryption::OnWizardNext
  1374. // History: Created Header 05/04/00 4:31:52 PM
  1375. --*/
  1376. //////////////////////////////////////////////////////////////////////////////
  1377. BOOL CPolicyWizard_Encryption::OnWizardNext()
  1378. {
  1379. m_spWizData->m_bEncrypt_No = IsDlgButtonChecked(IDC_NEWRAPWIZ_ENCRY_NO);
  1380. m_spWizData->m_bEncrypt_Basic = IsDlgButtonChecked(IDC_NEWRAPWIZ_ENCRY_BASIC);
  1381. m_spWizData->m_bEncrypt_Strong = IsDlgButtonChecked(IDC_NEWRAPWIZ_ENCRY_STRONG);
  1382. m_spWizData->m_bEncrypt_Strongest = IsDlgButtonChecked(IDC_NEWRAPWIZ_ENCRY_STRONGEST);
  1383. // reset the dirty bit
  1384. SetModified(FALSE);
  1385. return m_spWizData->GetNextPageId(((PROPSHEETPAGE*)(*this))->pszTemplate);
  1386. }
  1387. //////////////////////////////////////////////////////////////////////////////
  1388. /*++
  1389. CPolicyWizard_Encryption::OnSetActive
  1390. Return values:
  1391. TRUE if the page can be made active
  1392. FALSE if the page should be be skipped and the next page should be looked at.
  1393. Remarks:
  1394. If you want to change which pages are visited based on a user's
  1395. choices in a previous page, return FALSE here as appropriate.
  1396. --*/
  1397. //////////////////////////////////////////////////////////////////////////////
  1398. BOOL CPolicyWizard_Encryption::OnSetActive()
  1399. {
  1400. // MSDN docs say you need to use PostMessage here rather than SendMessage.
  1401. if (m_spWizData->m_bEncrypt_No || m_spWizData->m_bEncrypt_Basic || m_spWizData->m_bEncrypt_Strong || m_spWizData->m_bEncrypt_Strongest)
  1402. // MSDN docs say you need to use PostMessage here rather than SendMessage.
  1403. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK | PSWIZB_NEXT );
  1404. else
  1405. ::PropSheet_SetWizButtons(GetParent(), PSWIZB_BACK);
  1406. // don't show No encryption with VPN IDC_NEWRAPWIZ_ENCRY_NO_STATIC
  1407. if (m_spWizData->GetScenario()->m_bAllowClear)
  1408. {
  1409. ::ShowWindow(GetDlgItem(IDC_NEWRAPWIZ_ENCRY_NO), SW_SHOW);
  1410. }
  1411. else
  1412. {
  1413. ::ShowWindow(GetDlgItem(IDC_NEWRAPWIZ_ENCRY_NO), SW_HIDE);
  1414. }
  1415. return TRUE;
  1416. }
  1417. void SetWizardLargeFont(HWND hWnd, int controlId)
  1418. {
  1419. static CFont largeFont;
  1420. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  1421. CWnd wnd;
  1422. wnd.Attach(::GetDlgItem(hWnd, controlId));
  1423. if (wnd.m_hWnd)
  1424. {
  1425. ::CString FontSize;
  1426. ::CString FontName;
  1427. FontSize.LoadString(IDS_LARGE_FONT_SIZE);
  1428. FontName.LoadString(IDS_LARGE_FONT_NAME);
  1429. // If we don't have the large font yet, ...
  1430. if (!(HFONT)largeFont)
  1431. {
  1432. // ... create it.
  1433. largeFont.CreatePointFont(
  1434. 10 * _wtoi((LPCTSTR)FontSize),
  1435. FontName
  1436. );
  1437. }
  1438. wnd.SetFont(&largeFont);
  1439. wnd.Detach();
  1440. }
  1441. }
  1442. HRESULT InternalGetEapProviders(
  1443. LPCWSTR machineName,
  1444. AuthProviderArray *pProvList
  1445. )
  1446. {
  1447. typedef HRESULT (GET_EAP_PROVIDERS)(
  1448. LPCWSTR machineName,
  1449. AuthProviderArray *pProvList
  1450. );
  1451. GET_EAP_PROVIDERS* pGetEapProviders = NULL;
  1452. HRESULT hr = S_OK;
  1453. HMODULE rasUserDll = LoadLibraryW(L"rasuser.dll");
  1454. if (rasUserDll == NULL)
  1455. {
  1456. hr = HRESULT_FROM_WIN32(GetLastError());
  1457. IASTracePrintf("ERROR InternalGetEapProviders LoadLibrary(rasuser.dll)"
  1458. "failed. hr = %x ", hr);
  1459. ShowErrorDialog(NULL, IDS_ERROR_CANT_FIND_PROFILEDLL, NULL, hr);
  1460. return hr;
  1461. }
  1462. pGetEapProviders = (GET_EAP_PROVIDERS*) GetProcAddress(
  1463. rasUserDll,
  1464. "GetEapProviders");
  1465. if (pGetEapProviders == NULL)
  1466. {
  1467. hr = HRESULT_FROM_WIN32(GetLastError());
  1468. ErrorTrace(ERROR_NAPMMC_POLICYPAGE1, "GetProcAddress() failed, err = %x", hr);
  1469. ShowErrorDialog(NULL, IDS_ERROR_CANT_FIND_PROFILEAPI, NULL, hr);
  1470. }
  1471. else
  1472. {
  1473. hr = pGetEapProviders(machineName, pProvList);
  1474. }
  1475. FreeLibrary(rasUserDll);
  1476. return hr;
  1477. }