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.

1685 lines
45 KiB

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