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,
switch (uMsg)
{
case WM_INITDIALOG:
- {
/* FIXME: take care of NoDomainUI */
pgContext = (PGINA_CONTEXT)lParam;
SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pgContext);
pgContext->hBitmap = LoadImage(hDllInstance, MAKEINTRESOURCE(IDI_ROSLOGO), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
return TRUE;
- }
+
case WM_PAINT:
{
PAINTSTRUCT ps;
}
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;
}
-BOOL
+NTSTATUS
DoLoginTasks(
IN OUT PGINA_CONTEXT pgContext,
IN PWSTR UserName,
IN PWSTR Domain,
- IN PWSTR Password)
+ IN PWSTR Password,
+ OUT PNTSTATUS SubStatus)
{
- LPWSTR ProfilePath = NULL;
- LPWSTR lpEnvironment = NULL;
- TOKEN_STATISTICS Stats;
- PWLX_PROFILE_V2_0 pProfile = NULL;
- DWORD cbStats, cbSize;
- DWORD dwLength;
- BOOL bResult;
- NTSTATUS SubStatus;
NTSTATUS Status;
Status = ConnectToLsa(pgContext);
if (!NT_SUCCESS(Status))
{
- WARN("ConnectToLsa() failed\n");
- return FALSE;
+ WARN("ConnectToLsa() failed (Status 0x%08lx)\n", Status);
+ return Status;
}
Status = MyLogonUser(pgContext->LsaHandle,
Domain,
Password,
&pgContext->UserToken,
- &SubStatus);
+ SubStatus);
if (!NT_SUCCESS(Status))
{
- WARN("MyLogonUser() failed\n");
- goto cleanup;
+ WARN("MyLogonUser() failed (Status 0x%08lx)\n", Status);
}
+ return Status;
+}
+
+
+BOOL
+CreateProfile(
+ IN OUT PGINA_CONTEXT pgContext,
+ IN PWSTR UserName,
+ IN PWSTR Domain,
+ IN PWSTR Password)
+{
+ LPWSTR ProfilePath = NULL;
+ LPWSTR lpEnvironment = NULL;
+ TOKEN_STATISTICS Stats;
+ PWLX_PROFILE_V2_0 pProfile = NULL;
+ DWORD cbStats, cbSize;
+ DWORD dwLength;
+ BOOL bResult;
+
/* Store the logon time in the context */
GetLocalTime(&pgContext->LogonTime);
LPWSTR Password = NULL;
BOOL result = FALSE;
LONG rc;
+ NTSTATUS Status;
+ NTSTATUS SubStatus = STATUS_SUCCESS;
TRACE("DoAutoLogon(): AutoLogonState = %lu\n",
pgContext->AutoLogonState);
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));
{
WCHAR UserName[256];
WCHAR Password[256];
+ NTSTATUS Status;
+ NTSTATUS SubStatus = STATUS_SUCCESS;
TRACE("TUILoggedOutSAS()\n");
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