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.

149 lines
4.2 KiB

  1. /*++
  2. Module Name:
  3. brwsdlg.cpp
  4. Abstract:
  5. Intermediate dialog class that provides basic NT user account browsing.
  6. It assumes that the dialog resource contains BOTH a IDC_BROWSE button
  7. and a IDC_ACCOUNT_NAME edit field. It maintains both of these items.
  8. Author:
  9. Boyd Multerer boydm
  10. --*/
  11. #include "stdafx.h"
  12. #include "certmap.h"
  13. #include "brwsdlg.h"
  14. #include "cnfrmpsd.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CEditOne11MapDlg dialog
  22. //---------------------------------------------------------------------------
  23. CNTBrowsingDialog::CNTBrowsingDialog( UINT nIDTemplate, CWnd* pParentWnd )
  24. : CDialog( nIDTemplate, pParentWnd )
  25. {
  26. //{{AFX_DATA_INIT(CNTBrowsingDialog)
  27. m_sz_accountname = _T("");
  28. m_sz_password = _T("");
  29. //}}AFX_DATA_INIT
  30. }
  31. //---------------------------------------------------------------------------
  32. void CNTBrowsingDialog::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CNTBrowsingDialog)
  36. DDX_Control(pDX, IDC_PASSWORD, m_cedit_password);
  37. DDX_Control(pDX, IDC_NTACCOUNT, m_cedit_accountname);
  38. DDX_Text(pDX, IDC_NTACCOUNT, m_sz_accountname);
  39. DDX_Text(pDX, IDC_PASSWORD, m_sz_password);
  40. //}}AFX_DATA_MAP
  41. // DDX_Control(pDX, IDC_PASSWORD, m_cedit_password);
  42. }
  43. //---------------------------------------------------------------------------
  44. BEGIN_MESSAGE_MAP(CNTBrowsingDialog, CDialog)
  45. //{{AFX_MSG_MAP(CNTBrowsingDialog)
  46. ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
  47. ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CNTBrowsingDialog message handlers
  52. //---------------------------------------------------------------------------
  53. BOOL CNTBrowsingDialog::OnInitDialog()
  54. {
  55. m_bPassTyped = FALSE;
  56. m_szOrigPass = m_sz_password;
  57. if ( !m_sz_password.IsEmpty() )
  58. {
  59. m_sz_password.LoadString( IDS_SHOWN_PASSWORD );
  60. }
  61. return CDialog::OnInitDialog();
  62. }
  63. //---------------------------------------------------------------------------
  64. // run the user browser
  65. void CNTBrowsingDialog::OnBrowse()
  66. {
  67. GetIUsrAccount(NULL, this, m_sz_accountname);
  68. UpdateData(FALSE);
  69. // CSingleUserBrowser browser(m_hWnd, IDS_NTBROWSE_TITLE);
  70. // if ( browser.DoModal() == IDOK )
  71. // {
  72. // UpdateData( TRUE );
  73. // m_sz_accountname = browser.m_sz_account;
  74. // UpdateData( FALSE );
  75. // }
  76. }
  77. //---------------------------------------------------------------------------
  78. // make sure that the selected NT acount is, in fact, a valid account
  79. //
  80. void CNTBrowsingDialog::OnOK()
  81. {
  82. // update the data
  83. UpdateData( TRUE );
  84. // see if the account name is empty
  85. if ( m_sz_accountname.IsEmpty() )
  86. {
  87. AfxMessageBox( IDS_WANTACCOUNT );
  88. m_cedit_accountname.SetFocus();
  89. m_cedit_accountname.SetSel(0, -1);
  90. return;
  91. }
  92. // validate the password
  93. if ( m_bPassTyped )
  94. {
  95. CConfirmPassDlg dlgPass;
  96. dlgPass.m_szOrigPass = m_sz_password;
  97. if ( dlgPass.DoModal() != IDOK )
  98. {
  99. m_cedit_password.SetFocus();
  100. m_cedit_password.SetSel(0, -1);
  101. return;
  102. }
  103. }
  104. else
  105. {
  106. // restore the original password instead of the
  107. // standard ****** string
  108. m_sz_password = m_szOrigPass;
  109. UpdateData( FALSE );
  110. }
  111. // although it would seem to be a nice thing to do to verify the password and
  112. // account - it is VERY difficult, if not impossible, to do on a remote machine
  113. // it is valid
  114. CDialog::OnOK();
  115. }
  116. //---------------------------------------------------------------------------
  117. void CNTBrowsingDialog::OnChangePassword()
  118. {
  119. // TODO: If this is a RICHEDIT control, the control will not
  120. // send this notification unless you override the CNTBrowsingDialog::OnInitDialog()
  121. // function to send the EM_SETEVENTMASK message to the control
  122. // with the ENM_CHANGE flag ORed into the lParam mask.
  123. m_bPassTyped = TRUE;
  124. }