LogonUserW(): Fix key name.

svn path=/trunk/; revision=8607
This commit is contained in:
Eric Kohl 2004-03-09 15:04:28 +00:00
parent bea52f9dbe
commit e380640f44

View file

@ -1,4 +1,4 @@
/* $Id: logon.c,v 1.4 2004/02/25 14:25:10 ekohl Exp $ /* $Id: logon.c,v 1.5 2004/03/09 15:04:28 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -7,13 +7,15 @@
* PROGRAMMER: Eric Kohl * PROGRAMMER: Eric Kohl
*/ */
#include <windows.h>
#define NTOS_MODE_USER #define NTOS_MODE_USER
#include <ntos.h> #include <ntos.h>
#include <windows.h>
#include <string.h> #include <string.h>
#define NDEBUG
#include <debug.h>
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
/* /*
@ -145,27 +147,25 @@ SamGetUserSid (LPCWSTR UserName,
{ {
PSID lpSid; PSID lpSid;
DWORD dwLength; DWORD dwLength;
HKEY hAccountKey; HKEY hUsersKey;
HKEY hUserKey; HKEY hUserKey;
if (Sid != NULL) if (Sid != NULL)
*Sid = NULL; *Sid = NULL;
/* Open the Account key */ /* Open the Users key */
if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
L"SAM\\SAM\\Domains\\Account", L"SAM\\SAM\\Domains\\Account\\Users",
0, 0,
KEY_READ, KEY_READ,
&hAccountKey)) &hUsersKey))
{ {
//#if 0 DPRINT1 ("Failed to open Users key! (Error %lu)\n", GetLastError());
// DebugPrint ("Failed to open Account key! (Error %lu)\n", GetLastError());
//#endif
return FALSE; return FALSE;
} }
/* Open the user key */ /* Open the user key */
if (RegOpenKeyExW (hAccountKey, if (RegOpenKeyExW (hUsersKey,
UserName, UserName,
0, 0,
KEY_READ, KEY_READ,
@ -173,23 +173,19 @@ SamGetUserSid (LPCWSTR UserName,
{ {
if (GetLastError () == ERROR_FILE_NOT_FOUND) if (GetLastError () == ERROR_FILE_NOT_FOUND)
{ {
//#if 0 DPRINT1 ("Invalid user name!\n");
// DebugPrint ("Invalid user name!\n");
//#endif
SetLastError (ERROR_NO_SUCH_USER); SetLastError (ERROR_NO_SUCH_USER);
} }
else else
{ {
//#if 0 DPRINT1 ("Failed to open user key! (Error %lu)\n", GetLastError());
// DebugPrint ("Failed to open user key! (Error %lu)\n", GetLastError());
//#endif
} }
RegCloseKey (hAccountKey); RegCloseKey (hUsersKey);
return FALSE; return FALSE;
} }
RegCloseKey (hAccountKey); RegCloseKey (hUsersKey);
/* Get SID size */ /* Get SID size */
dwLength = 0; dwLength = 0;
@ -200,26 +196,19 @@ SamGetUserSid (LPCWSTR UserName,
NULL, NULL,
&dwLength)) &dwLength))
{ {
//#if 0 DPRINT1 ("Failed to read the SID size! (Error %lu)\n", GetLastError());
// DebugPrint ("Failed to read the SID size! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hUserKey); RegCloseKey (hUserKey);
return FALSE; return FALSE;
} }
/* FIXME: Allocate sid buffer */ /* Allocate sid buffer */
//#if 0 DPRINT ("Required SID buffer size: %lu\n", dwLength);
// DebugPrint ("Required SID buffer size: %lu\n", dwLength);
//#endif
lpSid = (PSID)RtlAllocateHeap (RtlGetProcessHeap (), lpSid = (PSID)RtlAllocateHeap (RtlGetProcessHeap (),
0, 0,
dwLength); dwLength);
if (lpSid == NULL) if (lpSid == NULL)
{ {
//#if 0 DPRINT1 ("Failed to allocate SID buffer!\n");
// DebugPrint ("Failed to allocate SID buffer!\n");
//#endif
RegCloseKey (hUserKey); RegCloseKey (hUserKey);
return FALSE; return FALSE;
} }
@ -232,9 +221,7 @@ SamGetUserSid (LPCWSTR UserName,
(LPBYTE)lpSid, (LPBYTE)lpSid,
&dwLength)) &dwLength))
{ {
//#if 0 DPRINT1 ("Failed to read the SID! (Error %lu)\n", GetLastError());
// DebugPrint ("Failed to read the SID! (Error %lu)\n", GetLastError());
//#endif
RtlFreeHeap (RtlGetProcessHeap (), RtlFreeHeap (RtlGetProcessHeap (),
0, 0,
lpSid); lpSid);
@ -300,17 +287,18 @@ LogonUserW (LPCWSTR lpszUsername,
/* Get the user SID from the registry */ /* Get the user SID from the registry */
if (!SamGetUserSid (lpszUsername, &UserSid)) if (!SamGetUserSid (lpszUsername, &UserSid))
{ {
RtlAllocateAndInitializeSid (&SystemAuthority, DPRINT ("SamGetUserSid() failed\n");
5, RtlAllocateAndInitializeSid (&SystemAuthority,
SECURITY_NT_NON_UNIQUE_RID, 5,
0x12345678, SECURITY_NT_NON_UNIQUE_RID,
0x12345678, 0x12345678,
0x12345678, 0x12345678,
DOMAIN_USER_RID_ADMIN, 0x12345678,
SECURITY_NULL_RID, DOMAIN_USER_RID_ADMIN,
SECURITY_NULL_RID, SECURITY_NULL_RID,
SECURITY_NULL_RID, SECURITY_NULL_RID,
&UserSid); SECURITY_NULL_RID,
&UserSid);
} }
TokenUser.User.Sid = UserSid; TokenUser.User.Sid = UserSid;