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.

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