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.

207 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. PasswordInfo.cpp : implementation file
  5. CPropertyPage support for User mgmt wizard
  6. File History:
  7. JonY Apr-96 created
  8. --*/
  9. #include "stdafx.h"
  10. #include "Speckle.h"
  11. #include "wizbased.h"
  12. #include "PwInfo.h"
  13. #include <lmaccess.h>
  14. #include <lmerr.h>
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CPasswordInfo property page
  21. IMPLEMENT_DYNCREATE(CPasswordInfo, CWizBaseDlg)
  22. CPasswordInfo::CPasswordInfo() : CWizBaseDlg(CPasswordInfo::IDD)
  23. {
  24. //{{AFX_DATA_INIT(CPasswordInfo)
  25. m_csPassword1 = _T("");
  26. m_csPassword2 = _T("");
  27. m_nPWOptions = 0;
  28. m_bNeverExpirePW = FALSE;
  29. m_csCaption = _T("");
  30. //}}AFX_DATA_INIT
  31. }
  32. CPasswordInfo::~CPasswordInfo()
  33. {
  34. }
  35. void CPasswordInfo::DoDataExchange(CDataExchange* pDX)
  36. {
  37. CPropertyPage::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(CPasswordInfo)
  39. DDX_Text(pDX, IDC_PASSWORD1, m_csPassword1);
  40. DDX_Text(pDX, IDC_PASSWORD2, m_csPassword2);
  41. DDX_Radio(pDX, IDC_PWOPTIONS_RADIO, m_nPWOptions);
  42. DDX_Check(pDX, IDC_EXPIREPW_CHECK, m_bNeverExpirePW);
  43. DDX_Text(pDX, IDC_STATIC1, m_csCaption);
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(CPasswordInfo, CWizBaseDlg)
  47. //{{AFX_MSG_MAP(CPasswordInfo)
  48. ON_WM_SHOWWINDOW()
  49. ON_EN_CHANGE(IDC_PASSWORD1, OnChangePassword1)
  50. ON_EN_CHANGE(IDC_PASSWORD2, OnChangePassword2)
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CPasswordInfo message handlers
  55. LRESULT CPasswordInfo::OnWizardNext()
  56. {
  57. CSpeckleApp* pApp = (CSpeckleApp*)AfxGetApp();
  58. UpdateData(TRUE);
  59. SetButtonAccess(PSWIZB_NEXT | PSWIZB_BACK);
  60. TCHAR* pServer = pApp->m_csServer.GetBuffer(pApp->m_csServer.GetLength());
  61. pApp->m_csServer.ReleaseBuffer();
  62. if (m_csPassword1 != m_csPassword2)
  63. {
  64. CString csPW;
  65. csPW.Format(IDS_PW_NOMATCH, pApp->m_csUserName);
  66. AfxMessageBox(csPW);
  67. GetDlgItem(IDC_PASSWORD1)->SetFocus();
  68. return -1;
  69. }
  70. if (m_csPassword1.GetLength() > 14)
  71. {
  72. AfxMessageBox(IDS_PW_TOOLONG);
  73. GetDlgItem(IDC_PASSWORD1)->SetFocus();
  74. return -1;
  75. }
  76. if (m_csPassword2.GetLength() > 14)
  77. {
  78. AfxMessageBox(IDS_PW_TOOLONG);
  79. GetDlgItem(IDC_PASSWORD2)->SetFocus();
  80. return -1;
  81. }
  82. LPBYTE pBuf;
  83. NET_API_STATUS nAPI = NetUserModalsGet(
  84. pServer,
  85. 0,
  86. &pBuf);
  87. PUSER_MODALS_INFO_0 pModals = (PUSER_MODALS_INFO_0)pBuf;
  88. if (nAPI != NERR_Success)
  89. {
  90. AfxMessageBox(IDS_BAD_GETMODALS);
  91. ExitProcess(1);
  92. }
  93. if (m_csPassword1.GetLength() < (int)pModals->usrmod0_min_passwd_len)
  94. {
  95. CString csMin;
  96. csMin.Format(IDS_PW_TOOSHORT,
  97. pModals->usrmod0_min_passwd_len);
  98. AfxMessageBox(csMin);
  99. GetDlgItem(IDC_PASSWORD1)->SetFocus();
  100. return -1;
  101. }
  102. pApp->m_csPassword1 = m_csPassword1;
  103. m_csPassword1 = L"";
  104. if (m_nPWOptions == 0 && m_bNeverExpirePW) AfxMessageBox(IDS_WONT_REQUIRE);
  105. pApp->m_bPW_Never_Expires = m_bNeverExpirePW;
  106. if (m_nPWOptions == 0)
  107. {
  108. pApp->m_bMust_Change_PW = TRUE;
  109. pApp->m_bChange_Password = TRUE;
  110. }
  111. else if (m_nPWOptions == 1)
  112. {
  113. pApp->m_bChange_Password = TRUE;
  114. pApp->m_bMust_Change_PW = FALSE;
  115. }
  116. else pApp->m_bChange_Password = FALSE;
  117. return CPropertyPage::OnWizardNext();
  118. }
  119. void CPasswordInfo::OnShowWindow(BOOL bShow, UINT nStatus)
  120. {
  121. CWizBaseDlg::OnShowWindow(bShow, nStatus);
  122. if (bShow)
  123. {
  124. CSpeckleApp* pApp = (CSpeckleApp*)AfxGetApp();
  125. CString csTemp;
  126. csTemp.LoadString(IDS_PASSWORD_CAPTION);
  127. CString csTemp2;
  128. csTemp2.Format(csTemp, pApp->m_csUserName);
  129. m_csCaption = csTemp2;
  130. if (pApp->m_bPWReset)
  131. {
  132. m_csPassword1 = L"";
  133. m_csPassword2 = L"";
  134. m_nPWOptions = 0;
  135. m_bNeverExpirePW = FALSE;
  136. pApp->m_bPWReset = FALSE;
  137. }
  138. UpdateData(FALSE);
  139. }
  140. }
  141. void CPasswordInfo::OnChangePassword1()
  142. {
  143. UpdateData(TRUE);
  144. if (m_csPassword1.GetLength() > 14)
  145. {
  146. AfxMessageBox(IDS_PW_TOOLONG);
  147. GetDlgItem(IDC_PASSWORD1)->SetFocus();
  148. }
  149. }
  150. void CPasswordInfo::OnChangePassword2()
  151. {
  152. UpdateData(TRUE);
  153. if (m_csPassword2.GetLength() > 14)
  154. {
  155. AfxMessageBox(IDS_PW_TOOLONG);
  156. GetDlgItem(IDC_PASSWORD2)->SetFocus();
  157. }
  158. }