[MSGINA]
authorEric Kohl <eric.kohl@reactos.org>
Sat, 1 Mar 2014 20:45:10 +0000 (20:45 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 1 Mar 2014 20:45:10 +0000 (20:45 +0000)
MyLogonUser: Pass the sub status to the caller.

svn path=/trunk/; revision=62369

reactos/dll/win32/msgina/lsa.c
reactos/dll/win32/msgina/msgina.c
reactos/dll/win32/msgina/msgina.h
reactos/dll/win32/msgina/tui.c

index 126a55a..174378f 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "msgina.h"
 
-BOOL
+NTSTATUS
 ConnectToLsa(
     PGINA_CONTEXT pgContext)
 {
@@ -18,7 +18,7 @@ ConnectToLsa(
 
     /* We are already connected to the LSA */
     if (pgContext->LsaHandle != NULL)
-        return TRUE;
+        return STATUS_SUCCESS;
 
     /* Connect to the LSA server */
     RtlInitAnsiString((PANSI_STRING)&LogonProcessName,
@@ -30,7 +30,7 @@ ConnectToLsa(
     if (!NT_SUCCESS(Status))
     {
         ERR("LsaRegisterLogonProcess failed (Status 0x%08lx)\n", Status);
-        return FALSE;
+        return Status;
     }
 
     /* Get the authentication package */
@@ -43,21 +43,21 @@ ConnectToLsa(
     if (!NT_SUCCESS(Status))
     {
         ERR("LsaLookupAuthenticationPackage failed (Status 0x%08lx)\n", Status);
-        return FALSE;
     }
 
-    return TRUE;
+    return Status;
 }
 
 
-BOOL
+NTSTATUS
 MyLogonUser(
     HANDLE LsaHandle,
     ULONG AuthenticationPackage,
     LPWSTR lpszUsername,
     LPWSTR lpszDomain,
     LPWSTR lpszPassword,
-    PHANDLE phToken)
+    PHANDLE phToken,
+    PNTSTATUS SubStatus)
 {
     SID_IDENTIFIER_AUTHORITY LocalAuthority = {SECURITY_LOCAL_SID_AUTHORITY};
     SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY};
@@ -78,7 +78,6 @@ MyLogonUser(
     LUID LogonId = {0, 0};
     HANDLE TokenHandle = NULL;
     QUOTA_LIMITS QuotaLimits;
-    NTSTATUS SubStatus = STATUS_SUCCESS;
     NTSTATUS Status;
 
     *phToken = NULL;
@@ -209,7 +208,7 @@ MyLogonUser(
                           &Luid,
                           &TokenHandle,
                           &QuotaLimits,
-                          &SubStatus);
+                          SubStatus);
     if (!NT_SUCCESS(Status))
     {
         ERR("LsaLogonUser failed (Status 0x%08lx)\n", Status);
@@ -259,13 +258,7 @@ done:
     if (AuthInfo != NULL)
         RtlFreeHeap(RtlGetProcessHeap(), 0, AuthInfo);
 
-    if (!NT_SUCCESS(Status))
-    {
-        SetLastError(RtlNtStatusToDosError(Status));
-        return FALSE;
-    }
-
-    return TRUE;
+    return Status;
 }
 
 /* EOF */
index 6f54e20..6480cbe 100644 (file)
@@ -612,20 +612,27 @@ DoAdminUnlock(
     ULONG Size;
     ULONG i;
     NTSTATUS Status;
+    NTSTATUS SubStatus = STATUS_SUCCESS;
 
     TRACE("(%S %S %S)\n", UserName, Domain, Password);
 
-    if (!ConnectToLsa(pgContext))
+    Status = ConnectToLsa(pgContext);
+    if (!NT_SUCCESS(Status))
+    {
+        WARN("ConnectToLsa() failed\n");
         return FALSE;
+    }
 
-    if (!MyLogonUser(pgContext->LsaHandle,
-                     pgContext->AuthenticationPackage,
-                     UserName,
-                     Domain,
-                     Password,
-                     &pgContext->UserToken))
+    Status = MyLogonUser(pgContext->LsaHandle,
+                         pgContext->AuthenticationPackage,
+                         UserName,
+                         Domain,
+                         Password,
+                         &pgContext->UserToken,
+                         &SubStatus);
+    if (!NT_SUCCESS(Status))
     {
-        WARN("LogonUserW() failed\n");
+        WARN("MyLogonUser() failed\n");
         return FALSE;
     }
 
@@ -693,18 +700,26 @@ DoLoginTasks(
     DWORD cbStats, cbSize;
     DWORD dwLength;
     BOOL bResult;
+    NTSTATUS SubStatus;
+    NTSTATUS Status;
 
-    if (!ConnectToLsa(pgContext))
+    Status = ConnectToLsa(pgContext);
+    if (!NT_SUCCESS(Status))
+    {
+        WARN("ConnectToLsa() failed\n");
         return FALSE;
+    }
 
-    if (!MyLogonUser(pgContext->LsaHandle,
-                     pgContext->AuthenticationPackage,
-                     UserName,
-                     Domain,
-                     Password,
-                     &pgContext->UserToken))
+    Status = MyLogonUser(pgContext->LsaHandle,
+                         pgContext->AuthenticationPackage,
+                         UserName,
+                         Domain,
+                         Password,
+                         &pgContext->UserToken,
+                         &SubStatus);
+    if (!NT_SUCCESS(Status))
     {
-        WARN("LogonUserW() failed\n");
+        WARN("MyLogonUser() failed\n");
         goto cleanup;
     }
 
index 5507b10..a6ba264 100644 (file)
@@ -81,18 +81,19 @@ typedef struct _GINA_UI
 
 /* lsa.c */
 
-BOOL
+NTSTATUS
 ConnectToLsa(
     PGINA_CONTEXT pgContext);
 
-BOOL
+NTSTATUS
 MyLogonUser(
     HANDLE LsaHandle,
     ULONG AuthenticationPackage,
     LPWSTR lpszUsername,
     LPWSTR lpszDomain,
     LPWSTR lpszPassword,
-    PHANDLE phToken);
+    PHANDLE phToken,
+    PNTSTATUS SubStatus);
 
 /* msgina.c */
 
index fb40c42..aa26223 100644 (file)
@@ -221,6 +221,8 @@ TUILockedSAS(
     HANDLE hToken;
     WCHAR UserName[256];
     WCHAR Password[256];
+    NTSTATUS SubStatus;
+    NTSTATUS Status;
 
     TRACE("TUILockedSAS()\n");
 
@@ -235,17 +237,23 @@ TUILockedSAS(
     if (!ReadString(IDS_ASKFORPASSWORD, Password, 256, FALSE))
         return WLX_SAS_ACTION_NONE;
 
-    if (!ConnectToLsa(pgContext))
+    Status = ConnectToLsa(pgContext);
+    if (!NT_SUCCESS(Status))
+    {
+        WARN("ConnectToLsa() failed\n");
         return WLX_SAS_ACTION_NONE;
+    }
 
-    if (!MyLogonUser(pgContext->LsaHandle,
-                     pgContext->AuthenticationPackage,
-                     UserName,
-                     NULL,
-                     Password,
-                     &hToken))
+    Status = MyLogonUser(pgContext->LsaHandle,
+                         pgContext->AuthenticationPackage,
+                         UserName,
+                         NULL,
+                         Password,
+                         &hToken,
+                         &SubStatus);
+    if (!NT_SUCCESS(Status))
     {
-        WARN("LogonUserW() failed\n");
+        WARN("MyLogonUser() failed\n");
         return WLX_SAS_ACTION_NONE;
     }