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.

220 lines
5.5 KiB

  1. // peap.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "nfaa.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CPEAPSetting dialog
  12. CPEAPSetting::CPEAPSetting(CWnd* pParent /*=NULL*/)
  13. : CDialog(CPEAPSetting::IDD, pParent)
  14. {
  15. //{{AFX_DATA_INIT(CPEAPSetting)
  16. //m_dwValidateServerCertificate = FALSE;
  17. //}}AFX_DATA_INIT
  18. m_bReadOnly = FALSE;
  19. }
  20. void CPEAPSetting::DoDataExchange(CDataExchange* pDX)
  21. {
  22. CDialog::DoDataExchange(pDX);
  23. //{{AFX_DATA_MAP(CPEAPSetting)
  24. DDX_Control(pDX, IDC_COMBO_PEAP_AUTH_TYPE, m_cbPEAPAuthType);
  25. DDX_Check(pDX, IDC_PEAP_VALIDATE_SERVER_CERT, m_dwValidateServerCertificate);
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(CPEAPSetting, CDialog)
  29. //{{AFX_MSG_MAP(CPEAPSetting)
  30. ON_WM_HELPINFO()
  31. ON_CBN_SELENDOK(IDC_COMBO_PEAP_AUTH_TYPE, OnSelPEAPAuthType)
  32. ON_BN_CLICKED(IDC_PEAP_VALIDATE_SERVER_CERT, OnCheckValidateServerCert)
  33. ON_BN_CLICKED(IDC_PEAP_AUTH_CONFIGURE, OnConfigure)
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CPEAPSetting message handlers
  38. BOOL CPEAPSetting::OnInitDialog()
  39. {
  40. CDialog::OnInitDialog();
  41. CString pszTemp;
  42. DWORD dwPEAPAuthTypeIndex = 0;
  43. if (!pPEAPProperties) {
  44. return FALSE;
  45. }
  46. pszTemp.LoadString(IDS_PEAP_AUTH_TYPE_MSCHAP_V2);
  47. m_cbPEAPAuthType.AddString(pszTemp);
  48. pszTemp.LoadString(IDS_EAP_TYPE_TLS);
  49. m_cbPEAPAuthType.AddString(pszTemp);
  50. switch (pPEAPProperties->dwPEAPAuthType)
  51. {
  52. case EAP_TYPE_MSCHAP_V2:
  53. dwPEAPAuthTypeIndex = 0;
  54. break;
  55. case WIRELESS_EAP_TYPE_TLS:
  56. dwPEAPAuthTypeIndex = 1;
  57. break;
  58. default:
  59. dwPEAPAuthTypeIndex = 0;
  60. break;
  61. }
  62. m_cbPEAPAuthType.SetCurSel(dwPEAPAuthTypeIndex);
  63. m_dwValidateServerCertificate =
  64. pPEAPProperties->dwValidateServerCert ? TRUE : FALSE;
  65. dwAutoWinLogin = pPEAPProperties->dwAutoLogin;
  66. TLSProperties.dwCertType =
  67. pPEAPProperties->dwPEAPTLSCertificateType;
  68. TLSProperties.dwValidateServerCert =
  69. pPEAPProperties->dwPEAPTLSValidateServerCertificate;
  70. if (m_bReadOnly) {
  71. SAFE_ENABLEWINDOW(IDC_COMBO_PEAP_AUTH_TYPE, FALSE);
  72. SAFE_ENABLEWINDOW(IDC_PEAP_VALIDATE_SERVER_CERT, FALSE);
  73. SAFE_ENABLEWINDOW(IDC_PEAP_AUTH_TYPE, FALSE);
  74. }
  75. UpdateData(FALSE);
  76. return TRUE; // return TRUE unless you set the focus to a control
  77. // EXCEPTION: OCX Property Pages should return FALSE
  78. }
  79. void CPEAPSetting::ControlsValuesToSM (PPEAP_PROPERTIES pPEAPProperties)
  80. {
  81. // pull all our data from the controls
  82. UpdateData(TRUE);
  83. DWORD dwPEAPAuthTypeIndex = 0;
  84. DWORD dwPEAPAuthType = 0;
  85. DWORD dwValidateServerCertificate = 0;
  86. dwPEAPAuthTypeIndex = m_cbPEAPAuthType.GetCurSel();
  87. switch (dwPEAPAuthTypeIndex) {
  88. case 0 :
  89. dwPEAPAuthType =
  90. EAP_TYPE_MSCHAP_V2;
  91. pPEAPProperties->dwAutoLogin = dwAutoWinLogin;
  92. break;
  93. case 1:
  94. dwPEAPAuthType =
  95. WIRELESS_EAP_TYPE_TLS;
  96. pPEAPProperties->dwPEAPTLSCertificateType =
  97. TLSProperties.dwCertType;
  98. pPEAPProperties->dwPEAPTLSValidateServerCertificate =
  99. TLSProperties.dwValidateServerCert;
  100. break;
  101. }
  102. dwValidateServerCertificate =
  103. m_dwValidateServerCertificate ? 1 : 0;
  104. pPEAPProperties->dwPEAPAuthType = dwPEAPAuthType;
  105. pPEAPProperties->dwValidateServerCert = dwValidateServerCertificate;
  106. }
  107. void CPEAPSetting::OnOK()
  108. {
  109. UpdateData (TRUE);
  110. ControlsValuesToSM(pPEAPProperties);
  111. CDialog::OnOK();
  112. }
  113. BOOL CPEAPSetting::OnHelpInfo(HELPINFO* pHelpInfo)
  114. {
  115. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  116. {
  117. DWORD* pdwHelp = (DWORD*) &g_aHelpIDs_IDD_PEAP_SETTINGS[0];
  118. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  119. c_szWlsnpHelpFile,
  120. HELP_WM_HELP,
  121. (DWORD_PTR)(LPVOID)pdwHelp);
  122. }
  123. return TRUE;
  124. }
  125. void CPEAPSetting::OnSelPEAPAuthType()
  126. {
  127. UpdateData(TRUE);
  128. }
  129. void CPEAPSetting::OnCheckValidateServerCert()
  130. {
  131. UpdateData(TRUE);
  132. }
  133. BOOL CPEAPSetting::Initialize(
  134. PPEAP_PROPERTIES paPEAPProperties,
  135. BOOL bReadOnly
  136. )
  137. {
  138. pPEAPProperties = paPEAPProperties;
  139. m_bReadOnly = bReadOnly;
  140. if (!pPEAPProperties) {
  141. return(FALSE);
  142. }
  143. return(TRUE);
  144. }
  145. void CPEAPSetting::OnConfigure()
  146. {
  147. CMSCHAPSetting CHAPdlg;
  148. DWORD dwPEAPAuthTypeIndex = 0;
  149. DWORD dwPEAPAuthType = 0;
  150. CTLSSetting TLSDlg;
  151. // Get the Current Selection
  152. dwPEAPAuthTypeIndex = m_cbPEAPAuthType.GetCurSel();
  153. switch (dwPEAPAuthTypeIndex) {
  154. case 0:
  155. dwPEAPAuthType = EAP_TYPE_MSCHAP_V2;
  156. break;
  157. case 1:
  158. dwPEAPAuthType = WIRELESS_EAP_TYPE_TLS;
  159. break;
  160. }
  161. if (dwPEAPAuthType == EAP_TYPE_MSCHAP_V2) {
  162. CHAPdlg.Initialize (&dwAutoWinLogin, m_bReadOnly);
  163. if (IDCANCEL == CHAPdlg.DoModal())
  164. return;
  165. UpdateData( FALSE );
  166. }
  167. if (dwPEAPAuthType == WIRELESS_EAP_TYPE_TLS) {
  168. TLSDlg.Initialize(&TLSProperties, m_bReadOnly);
  169. if (IDCANCEL == TLSDlg.DoModal())
  170. return;
  171. }
  172. return;
  173. }