mirror of
https://github.com/reactos/reactos.git
synced 2024-10-02 15:34:13 +00:00
[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). svn path=/trunk/; revision=62464
This commit is contained in:
parent
e4fbb93e96
commit
88a9cdffba
|
@ -920,6 +920,90 @@ GUILoggedOnSAS(
|
|||
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 @@ LoggedOutWindowProc(
|
|||
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 @@ LoggedOutWindowProc(
|
|||
|
||||
pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
|
@ -968,52 +1051,28 @@ LoggedOutWindowProc(
|
|||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -686,8 +686,41 @@ done:
|
|||
}
|
||||
|
||||
|
||||
BOOL
|
||||
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
|
||||
CreateProfile(
|
||||
IN OUT PGINA_CONTEXT pgContext,
|
||||
IN PWSTR UserName,
|
||||
IN PWSTR Domain,
|
||||
|
@ -700,28 +733,6 @@ DoLoginTasks(
|
|||
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 @@ DoAutoLogon(
|
|||
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 @@ DoAutoLogon(
|
|||
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));
|
||||
|
|
|
@ -104,8 +104,16 @@ DoAdminUnlock(
|
|||
IN PWSTR Domain,
|
||||
IN PWSTR Password);
|
||||
|
||||
BOOL
|
||||
NTSTATUS
|
||||
DoLoginTasks(
|
||||
IN OUT PGINA_CONTEXT pgContext,
|
||||
IN PWSTR UserName,
|
||||
IN PWSTR Domain,
|
||||
IN PWSTR Password,
|
||||
OUT PNTSTATUS SubStatus);
|
||||
|
||||
BOOL
|
||||
CreateProfile(
|
||||
IN OUT PGINA_CONTEXT pgContext,
|
||||
IN PWSTR UserName,
|
||||
IN PWSTR Domain,
|
||||
|
|
|
@ -199,6 +199,8 @@ TUILoggedOutSAS(
|
|||
{
|
||||
WCHAR UserName[256];
|
||||
WCHAR Password[256];
|
||||
NTSTATUS Status;
|
||||
NTSTATUS SubStatus = STATUS_SUCCESS;
|
||||
|
||||
TRACE("TUILoggedOutSAS()\n");
|
||||
|
||||
|
@ -208,9 +210,13 @@ TUILoggedOutSAS(
|
|||
if (!ReadString(IDS_ASKFORPASSWORD, Password, 256, FALSE))
|
||||
return WLX_SAS_ACTION_NONE;
|
||||
|
||||
if (DoLoginTasks(pgContext, UserName, NULL, Password))
|
||||
Status = DoLoginTasks(pgContext, UserName, NULL, Password, &SubStatus);
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
if (CreateProfile(pgContext, UserName, NULL, Password))
|
||||
return WLX_SAS_ACTION_LOGON;
|
||||
else
|
||||
}
|
||||
|
||||
return WLX_SAS_ACTION_NONE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue