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.

271 lines
7.3 KiB

  1. // WWzThree.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include <iadmw.h>
  5. #include "certmap.h"
  6. #include "ListRow.h"
  7. #include "ChkLstCt.h"
  8. extern "C"
  9. {
  10. #include <wincrypt.h>
  11. #include <sslsp.h>
  12. }
  13. #include "Iismap.hxx"
  14. #include "Iiscmr.hxx"
  15. #include "brwsdlg.h"
  16. #include "EdWldRul.h"
  17. #include "EdtRulEl.h"
  18. #include "WWzThree.h"
  19. #include "cnfrmpsd.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. #define ACCESS_DENY 0
  26. #define ACCESS_ACCEPT 1
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CWildWizThree property page
  29. IMPLEMENT_DYNCREATE(CWildWizThree, CPropertyPage)
  30. CWildWizThree::CWildWizThree() : CPropertyPage(CWildWizThree::IDD)
  31. {
  32. //{{AFX_DATA_INIT(CWildWizThree)
  33. m_int_DenyAccess = -1;
  34. m_sz_accountname = _T("");
  35. m_sz_password = _T("");
  36. //}}AFX_DATA_INIT
  37. m_bPassTyped = FALSE;
  38. }
  39. CWildWizThree::~CWildWizThree()
  40. {
  41. }
  42. void CWildWizThree::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CPropertyPage::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CWildWizThree)
  46. DDX_Control(pDX, IDC_STATIC_PASSWORD, m_static_password);
  47. DDX_Control(pDX, IDC_STATIC_ACCOUNT, m_static_account);
  48. DDX_Control(pDX, IDC_BROWSE, m_btn_browse);
  49. DDX_Control(pDX, IDC_PASSWORD, m_cedit_password);
  50. DDX_Control(pDX, IDC_NTACCOUNT, m_cedit_accountname);
  51. DDX_Radio(pDX, IDC_REFUSE_LOGON, m_int_DenyAccess);
  52. DDX_Text(pDX, IDC_NTACCOUNT, m_sz_accountname);
  53. DDX_Text(pDX, IDC_PASSWORD, m_sz_password);
  54. //}}AFX_DATA_MAP
  55. }
  56. BEGIN_MESSAGE_MAP(CWildWizThree, CPropertyPage)
  57. //{{AFX_MSG_MAP(CWildWizThree)
  58. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  59. ON_EN_CHANGE(IDC_NTACCOUNT, OnChangeNtaccount)
  60. ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
  61. ON_BN_CLICKED(IDC_ACCEPT_LOGON, OnAcceptLogon)
  62. ON_BN_CLICKED(IDC_REFUSE_LOGON, OnRefuseLogon)
  63. //}}AFX_MSG_MAP
  64. ON_COMMAND(ID_HELP_FINDER, DoHelp)
  65. ON_COMMAND(ID_HELP, DoHelp)
  66. ON_COMMAND(ID_CONTEXT_HELP, DoHelp)
  67. ON_COMMAND(ID_DEFAULT_HELP, DoHelp)
  68. END_MESSAGE_MAP()
  69. //---------------------------------------------------------------------------
  70. void CWildWizThree::DoHelp()
  71. {
  72. WinHelp( HIDD_CERTMAP_ADV_RUL_MAPPING );
  73. }
  74. //---------------------------------------------------------------------------
  75. void CWildWizThree::EnableButtons()
  76. {
  77. UpdateData( TRUE );
  78. // if the access is set to refuse access, then disable the account
  79. // and password stuff.
  80. if ( m_int_DenyAccess == 0 )
  81. {
  82. // deny access
  83. m_static_password.EnableWindow( FALSE );
  84. m_static_account.EnableWindow( FALSE );
  85. m_btn_browse.EnableWindow( FALSE );
  86. m_cedit_password.EnableWindow( FALSE );
  87. m_cedit_accountname.EnableWindow( FALSE );
  88. }
  89. else
  90. {
  91. // give access
  92. m_static_password.EnableWindow( TRUE );
  93. m_static_account.EnableWindow( TRUE );
  94. m_btn_browse.EnableWindow( TRUE );
  95. m_cedit_password.EnableWindow( TRUE );
  96. m_cedit_accountname.EnableWindow( TRUE );
  97. }
  98. }
  99. /////////////////////////////////////////////////////////////////////////////
  100. // CWildWizThree message handlers
  101. //---------------------------------------------------------------------------
  102. BOOL CWildWizThree::OnApply()
  103. {
  104. //
  105. // UNICODE/ANSI Conversion -- RonaldM
  106. //
  107. USES_CONVERSION;
  108. // update the data
  109. UpdateData( TRUE );
  110. // only do the account checks if the option is set to accept
  111. if ( m_int_DenyAccess == ACCESS_ACCEPT )
  112. {
  113. // see if the account name is empty
  114. if ( m_sz_accountname.IsEmpty() )
  115. {
  116. AfxMessageBox( IDS_WANTACCOUNT );
  117. m_cedit_accountname.SetFocus();
  118. m_cedit_accountname.SetSel(0, -1);
  119. return FALSE;
  120. }
  121. }
  122. // confirm the password
  123. if ( m_bPassTyped && (m_int_DenyAccess == ACCESS_ACCEPT) )
  124. {
  125. CConfirmPassDlg dlgPass;
  126. dlgPass.m_szOrigPass = m_sz_password;
  127. if ( dlgPass.DoModal() != IDOK )
  128. {
  129. m_cedit_password.SetFocus();
  130. m_cedit_password.SetSel(0, -1);
  131. return FALSE;
  132. }
  133. }
  134. else
  135. {
  136. // restore the original password instead of the
  137. // standard ****** string
  138. m_sz_password = m_szOrigPass;
  139. UpdateData( FALSE );
  140. }
  141. // store the deny access radio buttons
  142. m_pRule->SetRuleDenyAccess( m_int_DenyAccess == ACCESS_DENY );
  143. // we have to set the account name into place here
  144. m_pRule->SetRuleAccount( T2A((LPTSTR)(LPCTSTR)m_sz_accountname) );
  145. // store the password
  146. m_pRule->SetRulePassword( T2A((LPTSTR)(LPCTSTR)m_sz_password) );
  147. // reset the password flags
  148. m_szOrigPass = m_sz_password;
  149. m_bPassTyped = FALSE;
  150. SetModified( FALSE );
  151. return TRUE;
  152. }
  153. //---------------------------------------------------------------------------
  154. BOOL CWildWizThree::OnInitDialog()
  155. {
  156. // call the parental oninitdialog
  157. BOOL f = CPropertyPage::OnInitDialog();
  158. // set the easy default strings
  159. m_sz_accountname = m_pRule->GetRuleAccount(); // managed by CNTBrowsingDialog from here on
  160. // set up the deny access radio buttons
  161. if ( m_pRule->GetRuleDenyAccess() )
  162. m_int_DenyAccess = ACCESS_DENY;
  163. else
  164. m_int_DenyAccess = ACCESS_ACCEPT;
  165. // initialize the password
  166. m_sz_password = m_pRule->GetRulePassword();
  167. m_szOrigPass = m_sz_password;
  168. if ( !m_sz_password.IsEmpty() )
  169. m_sz_password.LoadString( IDS_SHOWN_PASSWORD );
  170. // exchange the data
  171. UpdateData( FALSE );
  172. EnableButtons();
  173. // success
  174. return TRUE;
  175. }
  176. //---------------------------------------------------------------------------
  177. BOOL CWildWizThree::OnSetActive()
  178. {
  179. // if this is a wizard, gray out the back button
  180. if ( m_fIsWizard )
  181. m_pPropSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  182. return CPropertyPage::OnSetActive();
  183. }
  184. //---------------------------------------------------------------------------
  185. BOOL CWildWizThree::OnWizardFinish()
  186. {
  187. for ( int i = 0; i < m_pPropSheet->GetPageCount( ); i++ )
  188. {
  189. if ( !m_pPropSheet->GetPage(i)->OnApply() )
  190. return FALSE;
  191. }
  192. return TRUE;
  193. }
  194. //---------------------------------------------------------------------------
  195. // run the user browser
  196. void CWildWizThree::OnBrowse()
  197. {
  198. LPTSTR buf = m_sz_accountname.GetBuffer(MAX_PATH);
  199. GetIUsrAccount(NULL, this, buf, MAX_PATH);
  200. m_sz_accountname.ReleaseBuffer(-1);
  201. SetModified();
  202. UpdateData(FALSE);
  203. }
  204. //---------------------------------------------------------------------------
  205. void CWildWizThree::OnChangeNtaccount()
  206. {
  207. // we can now apply
  208. SetModified();
  209. }
  210. //---------------------------------------------------------------------------
  211. void CWildWizThree::OnChangePassword()
  212. {
  213. m_bPassTyped = TRUE;
  214. // we can now apply
  215. SetModified();
  216. }
  217. //---------------------------------------------------------------------------
  218. void CWildWizThree::OnAcceptLogon()
  219. {
  220. EnableButtons();
  221. // we can now apply
  222. SetModified();
  223. }
  224. //---------------------------------------------------------------------------
  225. void CWildWizThree::OnRefuseLogon()
  226. {
  227. EnableButtons();
  228. // we can now apply
  229. SetModified();
  230. }