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.

144 lines
4.0 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. TCHAR * pUser = m_sz_accountname.GetBuffer(MAX_PATH);
  68. GetIUsrAccount(NULL, this, pUser, MAX_PATH);
  69. m_sz_accountname.ReleaseBuffer(-1);
  70. UpdateData(FALSE);
  71. }
  72. //---------------------------------------------------------------------------
  73. // make sure that the selected NT acount is, in fact, a valid account
  74. //
  75. void CNTBrowsingDialog::OnOK()
  76. {
  77. // update the data
  78. UpdateData( TRUE );
  79. // see if the account name is empty
  80. if ( m_sz_accountname.IsEmpty() )
  81. {
  82. AfxMessageBox( IDS_WANTACCOUNT );
  83. m_cedit_accountname.SetFocus();
  84. m_cedit_accountname.SetSel(0, -1);
  85. return;
  86. }
  87. // validate the password
  88. if ( m_bPassTyped )
  89. {
  90. CConfirmPassDlg dlgPass;
  91. dlgPass.m_szOrigPass = m_sz_password;
  92. if ( dlgPass.DoModal() != IDOK )
  93. {
  94. m_cedit_password.SetFocus();
  95. m_cedit_password.SetSel(0, -1);
  96. return;
  97. }
  98. }
  99. else
  100. {
  101. // restore the original password instead of the
  102. // standard ****** string
  103. m_sz_password = m_szOrigPass;
  104. UpdateData( FALSE );
  105. }
  106. // although it would seem to be a nice thing to do to verify the password and
  107. // account - it is VERY difficult, if not impossible, to do on a remote machine
  108. // it is valid
  109. CDialog::OnOK();
  110. }
  111. //---------------------------------------------------------------------------
  112. void CNTBrowsingDialog::OnChangePassword()
  113. {
  114. // TODO: If this is a RICHEDIT control, the control will not
  115. // send this notification unless you override the CNTBrowsingDialog::OnInitDialog()
  116. // function to send the EM_SETEVENTMASK message to the control
  117. // with the ENM_CHANGE flag ORed into the lParam mask.
  118. m_bPassTyped = TRUE;
  119. }