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.

283 lines
7.9 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 <schannel.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. DDX_Text_SecuredString(pDX, IDC_PASSWORD, m_sz_password);
  55. //}}AFX_DATA_MAP
  56. }
  57. BEGIN_MESSAGE_MAP(CWildWizThree, CPropertyPage)
  58. //{{AFX_MSG_MAP(CWildWizThree)
  59. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  60. ON_EN_CHANGE(IDC_NTACCOUNT, OnChangeNtaccount)
  61. ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
  62. ON_BN_CLICKED(IDC_ACCEPT_LOGON, OnAcceptLogon)
  63. ON_BN_CLICKED(IDC_REFUSE_LOGON, OnRefuseLogon)
  64. //}}AFX_MSG_MAP
  65. ON_COMMAND(ID_HELP_FINDER, DoHelp)
  66. ON_COMMAND(ID_HELP, DoHelp)
  67. ON_COMMAND(ID_CONTEXT_HELP, DoHelp)
  68. ON_COMMAND(ID_DEFAULT_HELP, DoHelp)
  69. END_MESSAGE_MAP()
  70. //---------------------------------------------------------------------------
  71. void CWildWizThree::DoHelp()
  72. {
  73. WinHelpDebug(HIDD_CERTMAP_ADV_RUL_MAPPING);
  74. WinHelp( HIDD_CERTMAP_ADV_RUL_MAPPING );
  75. }
  76. //---------------------------------------------------------------------------
  77. void CWildWizThree::EnableButtons()
  78. {
  79. UpdateData( TRUE );
  80. // if the access is set to refuse access, then disable the account
  81. // and password stuff.
  82. if ( m_int_DenyAccess == 0 )
  83. {
  84. // deny access
  85. m_static_password.EnableWindow( FALSE );
  86. m_static_account.EnableWindow( FALSE );
  87. m_btn_browse.EnableWindow( FALSE );
  88. m_cedit_password.EnableWindow( FALSE );
  89. m_cedit_accountname.EnableWindow( FALSE );
  90. }
  91. else
  92. {
  93. // give access
  94. m_static_password.EnableWindow( TRUE );
  95. m_static_account.EnableWindow( TRUE );
  96. m_btn_browse.EnableWindow( TRUE );
  97. m_cedit_password.EnableWindow( TRUE );
  98. m_cedit_accountname.EnableWindow( TRUE );
  99. }
  100. }
  101. /////////////////////////////////////////////////////////////////////////////
  102. // CWildWizThree message handlers
  103. //---------------------------------------------------------------------------
  104. BOOL CWildWizThree::OnApply()
  105. {
  106. //
  107. // UNICODE/ANSI Conversion -- RonaldM
  108. //
  109. USES_CONVERSION;
  110. // update the data
  111. UpdateData( TRUE );
  112. // only do the account checks if the option is set to accept
  113. if ( m_int_DenyAccess == ACCESS_ACCEPT )
  114. {
  115. // see if the account name is empty
  116. if ( m_sz_accountname.IsEmpty() )
  117. {
  118. AfxMessageBox( IDS_WANTACCOUNT );
  119. m_cedit_accountname.SetFocus();
  120. m_cedit_accountname.SetSel(0, -1);
  121. return FALSE;
  122. }
  123. }
  124. // confirm the password
  125. if ( m_bPassTyped && (m_int_DenyAccess == ACCESS_ACCEPT) )
  126. {
  127. CConfirmPassDlg dlgPass;
  128. dlgPass.m_szOrigPass = m_sz_password;
  129. if ( dlgPass.DoModal() != IDOK )
  130. {
  131. m_cedit_password.SetFocus();
  132. m_cedit_password.SetSel(0, -1);
  133. return FALSE;
  134. }
  135. }
  136. else
  137. {
  138. // restore the original password instead of the
  139. // standard ****** string
  140. m_sz_password = m_szOrigPass;
  141. UpdateData( FALSE );
  142. }
  143. // store the deny access radio buttons
  144. m_pRule->SetRuleDenyAccess( m_int_DenyAccess == ACCESS_DENY );
  145. // we have to set the account name into place here
  146. m_pRule->SetRuleAccount( T2A((LPTSTR)(LPCTSTR)m_sz_accountname) );
  147. // store the password
  148. CString csTempPassword;
  149. m_sz_password.CopyTo(csTempPassword);
  150. m_pRule->SetRulePassword( T2A((LPTSTR)(LPCTSTR)csTempPassword) );
  151. // reset the password flags
  152. m_szOrigPass = m_sz_password;
  153. m_bPassTyped = FALSE;
  154. SetModified( FALSE );
  155. return TRUE;
  156. }
  157. //---------------------------------------------------------------------------
  158. BOOL CWildWizThree::OnInitDialog()
  159. {
  160. // call the parental oninitdialog
  161. BOOL f = CPropertyPage::OnInitDialog();
  162. // set the easy default strings
  163. m_sz_accountname = m_pRule->GetRuleAccount(); // managed by CNTBrowsingDialog from here on
  164. // set up the deny access radio buttons
  165. if ( m_pRule->GetRuleDenyAccess() )
  166. m_int_DenyAccess = ACCESS_DENY;
  167. else
  168. m_int_DenyAccess = ACCESS_ACCEPT;
  169. // initialize the password
  170. CString csTempPassword;
  171. csTempPassword = m_pRule->GetRulePassword();
  172. m_sz_password = csTempPassword;
  173. m_szOrigPass = m_sz_password;
  174. if ( !m_sz_password.IsEmpty() )
  175. {
  176. CString csTempPassword;
  177. csTempPassword.LoadString( IDS_SHOWN_PASSWORD );
  178. m_sz_password = csTempPassword;
  179. }
  180. // exchange the data
  181. UpdateData( FALSE );
  182. EnableButtons();
  183. // success
  184. return TRUE;
  185. }
  186. //---------------------------------------------------------------------------
  187. BOOL CWildWizThree::OnSetActive()
  188. {
  189. // if this is a wizard, gray out the back button
  190. if ( m_fIsWizard )
  191. m_pPropSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
  192. return CPropertyPage::OnSetActive();
  193. }
  194. //---------------------------------------------------------------------------
  195. BOOL CWildWizThree::OnWizardFinish()
  196. {
  197. for ( int i = 0; i < m_pPropSheet->GetPageCount( ); i++ )
  198. {
  199. if ( !m_pPropSheet->GetPage(i)->OnApply() )
  200. return FALSE;
  201. }
  202. return TRUE;
  203. }
  204. //---------------------------------------------------------------------------
  205. // run the user browser
  206. void CWildWizThree::OnBrowse()
  207. {
  208. UpdateData(TRUE);
  209. LPTSTR buf = m_sz_accountname.GetBuffer(MAX_PATH);
  210. GetIUsrAccount(NULL, this, buf, MAX_PATH);
  211. m_sz_accountname.ReleaseBuffer(-1);
  212. SetModified();
  213. UpdateData(FALSE);
  214. }
  215. //---------------------------------------------------------------------------
  216. void CWildWizThree::OnChangeNtaccount()
  217. {
  218. // we can now apply
  219. SetModified();
  220. }
  221. //---------------------------------------------------------------------------
  222. void CWildWizThree::OnChangePassword()
  223. {
  224. m_bPassTyped = TRUE;
  225. // we can now apply
  226. SetModified();
  227. }
  228. //---------------------------------------------------------------------------
  229. void CWildWizThree::OnAcceptLogon()
  230. {
  231. EnableButtons();
  232. // we can now apply
  233. SetModified();
  234. }
  235. //---------------------------------------------------------------------------
  236. void CWildWizThree::OnRefuseLogon()
  237. {
  238. EnableButtons();
  239. // we can now apply
  240. SetModified();
  241. }