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.

405 lines
7.1 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. anondlg.cpp
  5. Abstract:
  6. WWW Anonymous account dialog
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "resource.h"
  18. #include "common.h"
  19. #include "inetprop.h"
  20. #include "inetmgrapp.h"
  21. //#include "supdlgs.h"
  22. #include "anondlg.h"
  23. #ifdef _DEBUG
  24. #define new DEBUG_NEW
  25. #undef THIS_FILE
  26. static char THIS_FILE[] = __FILE__;
  27. #endif
  28. CAnonymousDlg::CAnonymousDlg(
  29. IN CString & strServerName,
  30. IN CString & strUserName,
  31. IN CString & strPassword,
  32. IN BOOL & fPasswordSync,
  33. IN CWnd * pParent OPTIONAL
  34. )
  35. /*++
  36. Routine Description:
  37. Constructor
  38. Arguments:
  39. CString & strServerName : Server name
  40. CString & strUserName : User name
  41. CString & strPassword : Password
  42. BOOL & fPasswordSync : TRUE for password sync
  43. CWnd * pParent : Optional parent window
  44. Return Value:
  45. N/A
  46. --*/
  47. : CDialog(CAnonymousDlg::IDD, pParent),
  48. m_strServerName(strServerName),
  49. m_strUserName(strUserName),
  50. m_strPassword(strPassword),
  51. m_fPasswordSync(fPasswordSync),
  52. m_fPasswordSyncChanged(FALSE),
  53. m_fUserNameChanged(FALSE),
  54. m_fPasswordSyncMsgShown(FALSE)
  55. {
  56. #if 0 // Keep class wizard happy
  57. //{{AFX_DATA_INIT(CAnonymousDlg)
  58. m_strUserName = _T("");
  59. m_fPasswordSync = FALSE;
  60. //}}AFX_DATA_INIT
  61. m_strPassword = _T("");
  62. #endif // 0
  63. }
  64. void
  65. CAnonymousDlg::DoDataExchange(
  66. IN CDataExchange * pDX
  67. )
  68. /*++
  69. Routine Description:
  70. Initialise/Store control data
  71. Arguments:
  72. CDataExchange * pDX - DDX/DDV control structure
  73. Return Value:
  74. None
  75. --*/
  76. {
  77. CDialog::DoDataExchange(pDX);
  78. //{{AFX_DATA_MAP(CAnonymousDlg)
  79. DDX_Check(pDX, IDC_CHECK_ENABLE_PW_SYNCHRONIZATION, m_fPasswordSync);
  80. DDX_Control(pDX, IDC_EDIT_USERNAME, m_edit_UserName);
  81. DDX_Control(pDX, IDC_EDIT_PASSWORD, m_edit_Password);
  82. DDX_Control(pDX, IDC_STATIC_USERNAME, m_static_Username);
  83. DDX_Control(pDX, IDC_STATIC_PASSWORD, m_static_Password);
  84. DDX_Control(pDX, IDC_STATIC_ANONYMOUS_LOGON, m_group_AnonymousLogon);
  85. DDX_Control(pDX, IDC_CHECK_ENABLE_PW_SYNCHRONIZATION, m_chk_PasswordSync);
  86. DDX_Control(pDX, IDC_BUTTON_CHECK_PASSWORD, m_button_CheckPassword);
  87. //}}AFX_DATA_MAP
  88. DDX_Text(pDX, IDC_EDIT_USERNAME, m_strUserName);
  89. DDV_MinMaxChars(pDX, m_strUserName, 1, UNLEN);
  90. //
  91. // Some people have a tendency to add "\\" before
  92. // the computer name in user accounts. Fix this here.
  93. //
  94. m_strUserName.TrimLeft();
  95. while (*m_strUserName == '\\')
  96. {
  97. m_strUserName = m_strUserName.Mid(2);
  98. }
  99. //
  100. // Display the remote password sync message if
  101. // password sync is on, the account is not local,
  102. // password sync has changed or username has changed
  103. // and the message hasn't already be shown.
  104. //
  105. if (pDX->m_bSaveAndValidate && m_fPasswordSync
  106. && !IsLocalAccount(m_strUserName)
  107. && (m_fPasswordSyncChanged || m_fUserNameChanged)
  108. && !m_fPasswordSyncMsgShown
  109. )
  110. {
  111. if (::AfxMessageBox(
  112. IDS_WRN_PWSYNC,
  113. MB_YESNO | MB_DEFBUTTON2 | MB_ICONQUESTION
  114. ) != IDYES)
  115. {
  116. pDX->Fail();
  117. }
  118. //
  119. // Don't show it again
  120. //
  121. m_fPasswordSyncMsgShown = TRUE;
  122. }
  123. if (!m_fPasswordSync || !pDX->m_bSaveAndValidate)
  124. {
  125. DDX_Password(
  126. pDX,
  127. IDC_EDIT_PASSWORD,
  128. m_strPassword,
  129. g_lpszDummyPassword
  130. );
  131. }
  132. if (!m_fPasswordSync)
  133. {
  134. DDV_MaxChars(pDX, m_strPassword, PWLEN);
  135. }
  136. }
  137. //
  138. // Message Map
  139. //
  140. BEGIN_MESSAGE_MAP(CAnonymousDlg, CDialog)
  141. //{{AFX_MSG_MAP(CAnonymousDlg)
  142. ON_BN_CLICKED(IDC_BUTTON_BROWSE_USERS, OnButtonBrowseUsers)
  143. ON_BN_CLICKED(IDC_BUTTON_CHECK_PASSWORD, OnButtonCheckPassword)
  144. ON_BN_CLICKED(IDC_CHECK_ENABLE_PW_SYNCHRONIZATION, OnCheckEnablePwSynchronization)
  145. ON_EN_CHANGE(IDC_EDIT_USERNAME, OnChangeEditUsername)
  146. //}}AFX_MSG_MAP
  147. ON_EN_CHANGE(IDC_EDIT_PASSWORD, OnItemChanged)
  148. ON_EN_CHANGE(IDC_EDIT_DOMAIN_NAME, OnItemChanged)
  149. ON_EN_CHANGE(IDC_EDIT_BASIC_DOMAIN, OnItemChanged)
  150. END_MESSAGE_MAP()
  151. void
  152. CAnonymousDlg::SetControlStates()
  153. /*++
  154. Routine Description:
  155. Set the states of the dialog control depending on its current
  156. values.
  157. Arguments:
  158. None
  159. Return Value:
  160. None
  161. --*/
  162. {
  163. m_static_Password.EnableWindow(!m_fPasswordSync);
  164. m_edit_Password.EnableWindow(!m_fPasswordSync);
  165. m_button_CheckPassword.EnableWindow(!m_fPasswordSync);
  166. }
  167. //
  168. // Message Handlers
  169. //
  170. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  171. BOOL
  172. CAnonymousDlg::OnInitDialog()
  173. /*++
  174. Routine Description:
  175. WM_INITDIALOG handler. Initialize the dialog.
  176. Arguments:
  177. None.
  178. Return Value:
  179. TRUE if no focus is to be set automatically, FALSE if the focus
  180. is already set.
  181. --*/
  182. {
  183. CDialog::OnInitDialog();
  184. SetControlStates();
  185. return TRUE;
  186. }
  187. void
  188. CAnonymousDlg::OnItemChanged()
  189. /*++
  190. Routine Description:
  191. All EN_CHANGE and BN_CLICKED messages map to this function
  192. Arguments:
  193. None
  194. Return Value:
  195. None
  196. --*/
  197. {
  198. SetControlStates();
  199. }
  200. void
  201. CAnonymousDlg::OnButtonBrowseUsers()
  202. /*++
  203. Routine Description:
  204. User browse dialog pressed, bring up
  205. the user browser
  206. Arguments:
  207. None
  208. Return Value:
  209. None
  210. --*/
  211. {
  212. CString str;
  213. if (GetIUsrAccount(m_strServerName, this, str))
  214. {
  215. //
  216. // If the name is non-local (determined by having
  217. // a slash in the name, password sync is disabled,
  218. // and a password should be entered.
  219. //
  220. m_edit_UserName.SetWindowText(str);
  221. if (!(m_fPasswordSync = IsLocalAccount(str)))
  222. {
  223. m_edit_Password.SetWindowText(_T(""));
  224. m_edit_Password.SetFocus();
  225. }
  226. m_chk_PasswordSync.SetCheck(m_fPasswordSync);
  227. OnItemChanged();
  228. }
  229. }
  230. void
  231. CAnonymousDlg::OnButtonCheckPassword()
  232. /*++
  233. Routine Description:
  234. Check password button has been pressed.
  235. Arguments:
  236. None
  237. Return Value:
  238. None
  239. --*/
  240. {
  241. if (!UpdateData(TRUE))
  242. {
  243. return;
  244. }
  245. CError err(CComAuthInfo::VerifyUserPassword(m_strUserName, m_strPassword));
  246. if (!err.MessageBoxOnFailure())
  247. {
  248. ::AfxMessageBox(IDS_PASSWORD_OK);
  249. }
  250. }
  251. void
  252. CAnonymousDlg::OnCheckEnablePwSynchronization()
  253. /*++
  254. Routine Description:
  255. Handler for 'enable password synchronization' checkbox press
  256. Arguments:
  257. None
  258. Return Value:
  259. None
  260. --*/
  261. {
  262. m_fPasswordSyncChanged = TRUE;
  263. m_fPasswordSync = !m_fPasswordSync;
  264. OnItemChanged();
  265. SetControlStates();
  266. if (!m_fPasswordSync )
  267. {
  268. m_edit_Password.SetSel(0,-1);
  269. m_edit_Password.SetFocus();
  270. }
  271. }
  272. void
  273. CAnonymousDlg::OnChangeEditUsername()
  274. /*++
  275. Routine description:
  276. Handler for 'username' edit box change messages
  277. Arguments:
  278. None
  279. Return Value:
  280. None
  281. --*/
  282. {
  283. m_fUserNameChanged = TRUE;
  284. OnItemChanged();
  285. }