Author: ekohl
Date: Sat Mar 8 22:13:19 2014
New Revision: 62464
URL:
http://svn.reactos.org/svn/reactos?rev=62464&view=rev
Log:
[MSGINA]
- Split DoLoginTasks into DoLoginTasks and CreateProfile, and fix all callers of
DoLoginTasks accordingly.
- Make DoLoginTasks pass the SubStatus from MyLogonUser to its caller.
- Move the logon code from LoggedOutWindowProc to a new function DoLogon and add some
experimental code to report logon errors to the user (still WIP).
Modified:
trunk/reactos/dll/win32/msgina/gui.c
trunk/reactos/dll/win32/msgina/msgina.c
trunk/reactos/dll/win32/msgina/msgina.h
trunk/reactos/dll/win32/msgina/tui.c
Modified: trunk/reactos/dll/win32/msgina/gui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/gui.c?rev…
==============================================================================
--- trunk/reactos/dll/win32/msgina/gui.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msgina/gui.c [iso-8859-1] Sat Mar 8 22:13:19 2014
@@ -920,6 +920,90 @@
return result;
}
+
+static
+INT
+DoLogon(
+ IN HWND hwndDlg,
+ IN OUT PGINA_CONTEXT pgContext)
+{
+ LPWSTR UserName = NULL;
+ LPWSTR Password = NULL;
+ LPWSTR Domain = NULL;
+ INT result = WLX_SAS_ACTION_NONE;
+ NTSTATUS Status, SubStatus = STATUS_SUCCESS;
+
+ if (GetTextboxText(hwndDlg, IDC_USERNAME, &UserName) && *UserName ==
'\0')
+ goto done;
+
+ if (GetTextboxText(hwndDlg, IDC_LOGON_TO, &Domain) && *Domain ==
'\0')
+ goto done;
+
+ if (!GetTextboxText(hwndDlg, IDC_PASSWORD, &Password))
+ goto done;
+
+ Status = DoLoginTasks(pgContext, UserName, Domain, Password, &SubStatus);
+ if (!NT_SUCCESS(Status))
+ {
+TRACE("DoLoginTasks failed! Status 0x%08lx SubStatus 0x%08lx\n", Status,
SubStatus);
+
+ if (SubStatus == STATUS_ACCOUNT_DISABLED)
+ {
+TRACE("Account disabled!\n");
+ pgContext->pWlxFuncs->WlxMessageBox(pgContext->hWlx,
+ hwndDlg,
+ L"Account disabled!",
+ L"Logon error",
+ MB_OK | MB_ICONERROR);
+
+ goto done;
+ }
+ else if (SubStatus == STATUS_ACCOUNT_LOCKED_OUT)
+ {
+TRACE("Account locked!\n");
+ pgContext->pWlxFuncs->WlxMessageBox(pgContext->hWlx,
+ hwndDlg,
+ L"Account locked!",
+ L"Logon error",
+ MB_OK | MB_ICONERROR);
+ goto done;
+ }
+ else
+ {
+TRACE("Other error!\n");
+ pgContext->pWlxFuncs->WlxMessageBox(pgContext->hWlx,
+ hwndDlg,
+ L"Other error!",
+ L"Logon error",
+ MB_OK | MB_ICONERROR);
+ goto done;
+ }
+ }
+
+ if (!CreateProfile(pgContext, UserName, Domain, Password))
+ {
+ ERR("Failed to create the profile!\n");
+ goto done;
+ }
+
+ ZeroMemory(pgContext->Password, 256 * sizeof(WCHAR));
+ wcscpy(pgContext->Password, Password);
+
+ result = WLX_SAS_ACTION_LOGON;
+
+done:
+ if (UserName != NULL)
+ HeapFree(GetProcessHeap(), 0, UserName);
+
+ if (Password != NULL)
+ HeapFree(GetProcessHeap(), 0, Password);
+
+ if (Domain != NULL)
+ HeapFree(GetProcessHeap(), 0, Domain);
+
+ return result;
+}
+
static INT_PTR CALLBACK
LoggedOutWindowProc(
IN HWND hwndDlg,
@@ -934,7 +1018,6 @@
switch (uMsg)
{
case WM_INITDIALOG:
- {
/* FIXME: take care of NoDomainUI */
pgContext = (PGINA_CONTEXT)lParam;
SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
@@ -955,7 +1038,7 @@
pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO),
IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
return TRUE;
- }
+
case WM_PAINT:
{
PAINTSTRUCT ps;
@@ -968,51 +1051,27 @@
}
return TRUE;
}
+
case WM_DESTROY:
- {
DeleteObject(pgContext->hBitmap);
return TRUE;
- }
+
case WM_COMMAND:
- {
switch (LOWORD(wParam))
{
case IDOK:
- {
- LPWSTR UserName = NULL, Password = NULL, Domain = NULL;
- INT result = WLX_SAS_ACTION_NONE;
-
- if (GetTextboxText(hwndDlg, IDC_USERNAME, &UserName) &&
*UserName == '\0')
- break;
- if (GetTextboxText(hwndDlg, IDC_LOGON_TO, &Domain) &&
*Domain == '\0')
- break;
- if (GetTextboxText(hwndDlg, IDC_PASSWORD, &Password) &&
- DoLoginTasks(pgContext, UserName, Domain, Password))
- {
- ZeroMemory(pgContext->Password, 256 * sizeof(WCHAR));
- wcscpy(pgContext->Password, Password);
-
- result = WLX_SAS_ACTION_LOGON;
- }
- HeapFree(GetProcessHeap(), 0, UserName);
- HeapFree(GetProcessHeap(), 0, Password);
- HeapFree(GetProcessHeap(), 0, Domain);
- EndDialog(hwndDlg, result);
- return TRUE;
- }
+ EndDialog(hwndDlg, DoLogon(hwndDlg, pgContext));
+ return TRUE;
+
case IDCANCEL:
- {
EndDialog(hwndDlg, WLX_SAS_ACTION_NONE);
return TRUE;
- }
+
case IDC_SHUTDOWN:
- {
EndDialog(hwndDlg, WLX_SAS_ACTION_SHUTDOWN);
return TRUE;
- }
}
break;
- }
}
return FALSE;
Modified: trunk/reactos/dll/win32/msgina/msgina.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/msgina.c?…
==============================================================================
--- trunk/reactos/dll/win32/msgina/msgina.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msgina/msgina.c [iso-8859-1] Sat Mar 8 22:13:19 2014
@@ -686,8 +686,41 @@
}
+NTSTATUS
+DoLoginTasks(
+ IN OUT PGINA_CONTEXT pgContext,
+ IN PWSTR UserName,
+ IN PWSTR Domain,
+ IN PWSTR Password,
+ OUT PNTSTATUS SubStatus)
+{
+ NTSTATUS Status;
+
+ Status = ConnectToLsa(pgContext);
+ if (!NT_SUCCESS(Status))
+ {
+ WARN("ConnectToLsa() failed (Status 0x%08lx)\n", Status);
+ return Status;
+ }
+
+ Status = MyLogonUser(pgContext->LsaHandle,
+ pgContext->AuthenticationPackage,
+ UserName,
+ Domain,
+ Password,
+ &pgContext->UserToken,
+ SubStatus);
+ if (!NT_SUCCESS(Status))
+ {
+ WARN("MyLogonUser() failed (Status 0x%08lx)\n", Status);
+ }
+
+ return Status;
+}
+
+
BOOL
-DoLoginTasks(
+CreateProfile(
IN OUT PGINA_CONTEXT pgContext,
IN PWSTR UserName,
IN PWSTR Domain,
@@ -700,28 +733,6 @@
DWORD cbStats, cbSize;
DWORD dwLength;
BOOL bResult;
- NTSTATUS SubStatus;
- NTSTATUS Status;
-
- Status = ConnectToLsa(pgContext);
- if (!NT_SUCCESS(Status))
- {
- WARN("ConnectToLsa() failed\n");
- return FALSE;
- }
-
- Status = MyLogonUser(pgContext->LsaHandle,
- pgContext->AuthenticationPackage,
- UserName,
- Domain,
- Password,
- &pgContext->UserToken,
- &SubStatus);
- if (!NT_SUCCESS(Status))
- {
- WARN("MyLogonUser() failed\n");
- goto cleanup;
- }
/* Store the logon time in the context */
GetLocalTime(&pgContext->LogonTime);
@@ -822,6 +833,8 @@
LPWSTR Password = NULL;
BOOL result = FALSE;
LONG rc;
+ NTSTATUS Status;
+ NTSTATUS SubStatus = STATUS_SUCCESS;
TRACE("DoAutoLogon(): AutoLogonState = %lu\n",
pgContext->AutoLogonState);
@@ -884,8 +897,15 @@
if (rc != ERROR_SUCCESS)
goto cleanup;
- result = DoLoginTasks(pgContext, UserName, Domain, Password);
-
+ Status = DoLoginTasks(pgContext, UserName, Domain, Password, &SubStatus);
+ if (!NT_SUCCESS(Status))
+ {
+ /* FIXME: Handle errors!!! */
+ result = FALSE;
+ goto cleanup;
+ }
+
+ result = CreateProfile(pgContext, UserName, Domain, Password);
if (result == TRUE)
{
ZeroMemory(pgContext->Password, 256 * sizeof(WCHAR));
Modified: trunk/reactos/dll/win32/msgina/msgina.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/msgina.h?…
==============================================================================
--- trunk/reactos/dll/win32/msgina/msgina.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msgina/msgina.h [iso-8859-1] Sat Mar 8 22:13:19 2014
@@ -104,8 +104,16 @@
IN PWSTR Domain,
IN PWSTR Password);
+NTSTATUS
+DoLoginTasks(
+ IN OUT PGINA_CONTEXT pgContext,
+ IN PWSTR UserName,
+ IN PWSTR Domain,
+ IN PWSTR Password,
+ OUT PNTSTATUS SubStatus);
+
BOOL
-DoLoginTasks(
+CreateProfile(
IN OUT PGINA_CONTEXT pgContext,
IN PWSTR UserName,
IN PWSTR Domain,
Modified: trunk/reactos/dll/win32/msgina/tui.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/tui.c?rev…
==============================================================================
--- trunk/reactos/dll/win32/msgina/tui.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msgina/tui.c [iso-8859-1] Sat Mar 8 22:13:19 2014
@@ -199,6 +199,8 @@
{
WCHAR UserName[256];
WCHAR Password[256];
+ NTSTATUS Status;
+ NTSTATUS SubStatus = STATUS_SUCCESS;
TRACE("TUILoggedOutSAS()\n");
@@ -208,10 +210,14 @@
if (!ReadString(IDS_ASKFORPASSWORD, Password, 256, FALSE))
return WLX_SAS_ACTION_NONE;
- if (DoLoginTasks(pgContext, UserName, NULL, Password))
- return WLX_SAS_ACTION_LOGON;
- else
- return WLX_SAS_ACTION_NONE;
+ Status = DoLoginTasks(pgContext, UserName, NULL, Password, &SubStatus);
+ if (Status == STATUS_SUCCESS)
+ {
+ if (CreateProfile(pgContext, UserName, NULL, Password))
+ return WLX_SAS_ACTION_LOGON;
+ }
+
+ return WLX_SAS_ACTION_NONE;
}
static INT