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.

404 lines
7.7 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(pDX, IDC_EDIT_PASSWORD, m_strPassword, g_lpszDummyPassword);
  126. DDX_Password_SecuredString(pDX, IDC_EDIT_PASSWORD, m_strPassword, g_lpszDummyPassword);
  127. }
  128. if (!m_fPasswordSync)
  129. {
  130. //DDV_MinMaxChars(pDX, m_strPassword, 1, PWLEN);
  131. DDV_MinMaxChars_SecuredString(pDX, m_strPassword, 1, PWLEN);
  132. }
  133. }
  134. //
  135. // Message Map
  136. //
  137. BEGIN_MESSAGE_MAP(CAnonymousDlg, CDialog)
  138. //{{AFX_MSG_MAP(CAnonymousDlg)
  139. ON_BN_CLICKED(IDC_BUTTON_BROWSE_USERS, OnButtonBrowseUsers)
  140. ON_BN_CLICKED(IDC_BUTTON_CHECK_PASSWORD, OnButtonCheckPassword)
  141. ON_BN_CLICKED(IDC_CHECK_ENABLE_PW_SYNCHRONIZATION, OnCheckEnablePwSynchronization)
  142. ON_EN_CHANGE(IDC_EDIT_USERNAME, OnChangeEditUsername)
  143. //}}AFX_MSG_MAP
  144. ON_EN_CHANGE(IDC_EDIT_PASSWORD, OnItemChanged)
  145. ON_EN_CHANGE(IDC_EDIT_DOMAIN_NAME, OnItemChanged)
  146. ON_EN_CHANGE(IDC_EDIT_BASIC_DOMAIN, OnItemChanged)
  147. END_MESSAGE_MAP()
  148. void
  149. CAnonymousDlg::SetControlStates()
  150. /*++
  151. Routine Description:
  152. Set the states of the dialog control depending on its current
  153. values.
  154. Arguments:
  155. None
  156. Return Value:
  157. None
  158. --*/
  159. {
  160. m_static_Password.EnableWindow(!m_fPasswordSync);
  161. m_edit_Password.EnableWindow(!m_fPasswordSync);
  162. m_button_CheckPassword.EnableWindow(!m_fPasswordSync);
  163. }
  164. //
  165. // Message Handlers
  166. //
  167. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  168. BOOL
  169. CAnonymousDlg::OnInitDialog()
  170. /*++
  171. Routine Description:
  172. WM_INITDIALOG handler. Initialize the dialog.
  173. Arguments:
  174. None.
  175. Return Value:
  176. TRUE if no focus is to be set automatically, FALSE if the focus
  177. is already set.
  178. --*/
  179. {
  180. CDialog::OnInitDialog();
  181. SetControlStates();
  182. return TRUE;
  183. }
  184. void
  185. CAnonymousDlg::OnItemChanged()
  186. /*++
  187. Routine Description:
  188. All EN_CHANGE and BN_CLICKED messages map to this function
  189. Arguments:
  190. None
  191. Return Value:
  192. None
  193. --*/
  194. {
  195. SetControlStates();
  196. }
  197. void
  198. CAnonymousDlg::OnButtonBrowseUsers()
  199. /*++
  200. Routine Description:
  201. User browse dialog pressed, bring up
  202. the user browser
  203. Arguments:
  204. None
  205. Return Value:
  206. None
  207. --*/
  208. {
  209. CString str;
  210. if (GetIUsrAccount(m_strServerName, this, str))
  211. {
  212. //
  213. // If the name is non-local (determined by having
  214. // a slash in the name, password sync is disabled,
  215. // and a password should be entered.
  216. //
  217. m_edit_UserName.SetWindowText(str);
  218. if (!(m_fPasswordSync = IsLocalAccount(str)))
  219. {
  220. m_edit_Password.SetWindowText(_T(""));
  221. m_edit_Password.SetFocus();
  222. }
  223. m_chk_PasswordSync.SetCheck(m_fPasswordSync);
  224. OnItemChanged();
  225. }
  226. }
  227. void
  228. CAnonymousDlg::OnButtonCheckPassword()
  229. /*++
  230. Routine Description:
  231. Check password button has been pressed.
  232. Arguments:
  233. None
  234. Return Value:
  235. None
  236. --*/
  237. {
  238. if (!UpdateData(TRUE))
  239. {
  240. return;
  241. }
  242. CString csTempPassword;
  243. m_strPassword.CopyTo(csTempPassword);
  244. CError err(CComAuthInfo::VerifyUserPassword(m_strUserName, csTempPassword));
  245. if (!err.MessageBoxOnFailure(m_hWnd))
  246. {
  247. DoHelpMessageBox(m_hWnd,IDS_PASSWORD_OK, MB_APPLMODAL | MB_OK | MB_ICONINFORMATION, 0);
  248. }
  249. }
  250. void
  251. CAnonymousDlg::OnCheckEnablePwSynchronization()
  252. /*++
  253. Routine Description:
  254. Handler for 'enable password synchronization' checkbox press
  255. Arguments:
  256. None
  257. Return Value:
  258. None
  259. --*/
  260. {
  261. m_fPasswordSyncChanged = TRUE;
  262. m_fPasswordSync = !m_fPasswordSync;
  263. OnItemChanged();
  264. SetControlStates();
  265. if (!m_fPasswordSync )
  266. {
  267. m_edit_Password.SetSel(0,-1);
  268. m_edit_Password.SetFocus();
  269. }
  270. }
  271. void
  272. CAnonymousDlg::OnChangeEditUsername()
  273. /*++
  274. Routine description:
  275. Handler for 'username' edit box change messages
  276. Arguments:
  277. None
  278. Return Value:
  279. None
  280. --*/
  281. {
  282. m_fUserNameChanged = TRUE;
  283. OnItemChanged();
  284. }