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.

162 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. PersonalInfo.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 "Prsinfo.h"
  13. #include <lmerr.h>
  14. #include <lmaccess.h>
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CPersonalInfo dialog
  21. IMPLEMENT_DYNCREATE(CPersonalInfo, CWizBaseDlg)
  22. CPersonalInfo::CPersonalInfo() : CWizBaseDlg(CPersonalInfo::IDD)
  23. {
  24. //{{AFX_DATA_INIT(CPersonalInfo)
  25. m_csDescription = _T("");
  26. m_csFullName = _T("");
  27. m_csUserName = _T("");
  28. //}}AFX_DATA_INIT
  29. }
  30. void CPersonalInfo::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(CPersonalInfo)
  34. DDX_Text(pDX, IDC_DESCRIPTION, m_csDescription);
  35. DDX_Text(pDX, IDC_FULLNAME, m_csFullName);
  36. DDX_Text(pDX, IDC_USERNAME, m_csUserName);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CPersonalInfo, CWizBaseDlg)
  40. //{{AFX_MSG_MAP(CPersonalInfo)
  41. ON_WM_SHOWWINDOW()
  42. ON_EN_CHANGE(IDC_USERNAME, OnChangeUsername)
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CPersonalInfo message handlers
  47. LRESULT CPersonalInfo::OnWizardBack()
  48. {
  49. SetButtonAccess(PSWIZB_NEXT | PSWIZB_BACK);
  50. return CPropertyPage::OnWizardBack();
  51. }
  52. LRESULT CPersonalInfo::OnWizardNext()
  53. {
  54. SetButtonAccess(PSWIZB_NEXT | PSWIZB_BACK);
  55. // eventually this needs to be changed to I_NetNameValidate from private\net\inc\icanon.h from netlib.lib
  56. UpdateData(TRUE);
  57. if (m_csUserName == "")
  58. {
  59. AfxMessageBox(IDS_NO_USERNAME);
  60. GetDlgItem(IDC_USERNAME)->SetFocus();
  61. return -1;
  62. }
  63. if (m_csUserName.GetLength() > 20)
  64. {
  65. AfxMessageBox(IDS_USERNAME_TOOLONG);
  66. GetDlgItem(IDC_USERNAME)->SetFocus();
  67. return -1;
  68. }
  69. if (m_csUserName.FindOneOf(L"\"\\/[];:|=,+*?<>") != -1)
  70. {
  71. AfxMessageBox(IDS_BAD_USERNAME);
  72. GetDlgItem(IDC_USERNAME)->SetFocus();
  73. return -1;
  74. }
  75. CWaitCursor wait;
  76. CSpeckleApp* pApp = (CSpeckleApp*)AfxGetApp();
  77. TCHAR* pServer = pApp->m_csServer.GetBuffer(pApp->m_csServer.GetLength());
  78. pApp->m_csServer.ReleaseBuffer();
  79. TCHAR* pUser = m_csUserName.GetBuffer(m_csUserName.GetLength());
  80. m_csUserName.ReleaseBuffer();
  81. // is username unique?
  82. LPBYTE* pUserInfo = new LPBYTE[256];
  83. NET_API_STATUS nAPI = NetUserGetInfo(pServer,
  84. pUser,
  85. 0,
  86. pUserInfo);
  87. delete (pUserInfo);
  88. if (nAPI == NERR_Success)
  89. {
  90. CString csDup;
  91. csDup.Format(IDS_DUPLICATE_NAME, m_csUserName, m_csUserName, pApp->m_csDomain);
  92. AfxMessageBox(csDup);
  93. GetDlgItem(IDC_USERNAME)->SetFocus();
  94. return -1;
  95. }
  96. pApp->m_csDescription = m_csDescription;
  97. pApp->m_csFullName = m_csFullName;
  98. pApp->m_csUserName = m_csUserName;
  99. return CPropertyPage::OnWizardNext();
  100. }
  101. void CPersonalInfo::OnShowWindow(BOOL bShow, UINT nStatus)
  102. {
  103. CWizBaseDlg::OnShowWindow(bShow, nStatus);
  104. CSpeckleApp* pApp = (CSpeckleApp*)AfxGetApp();
  105. if (bShow && pApp->m_bPRSReset)
  106. {
  107. m_csDescription = L"";
  108. m_csFullName = L"";
  109. m_csUserName = L"";
  110. pApp->m_bPRSReset = FALSE;
  111. UpdateData(FALSE);
  112. }
  113. }
  114. void CPersonalInfo::OnChangeUsername()
  115. {
  116. UpdateData(TRUE);
  117. if (m_csUserName.GetLength() > 20)
  118. {
  119. AfxMessageBox(IDS_USERNAME_TOOLONG);
  120. GetDlgItem(IDC_USERNAME)->SetFocus();
  121. }
  122. if (m_csUserName.FindOneOf(L"\"\\/[];:|=,+*?<>") != -1)
  123. {
  124. AfxMessageBox(IDS_BAD_USERNAME);
  125. GetDlgItem(IDC_USERNAME)->SetFocus();
  126. }
  127. }