Add debug message logging (disabled by default).

Store user account data in Account\Users.

svn path=/trunk/; revision=8027
This commit is contained in:
Eric Kohl 2004-02-04 17:57:56 +00:00
parent 4986ea13b8
commit 2dae92de89
3 changed files with 189 additions and 126 deletions

View file

@ -0,0 +1,16 @@
#ifdef NDEBUG
#define DPRINT(args...)
#define CHECKPOINT
#else
#define DPRINT(args...) do { DebugPrint("(SAMLIB:%s:%d) ",__FILE__,__LINE__); DebugPrint(args); } while(0)
#define CHECKPOINT do { DebugPrint("(SAMLIB:%s:%d) Checkpoint\n",__FILE__,__LINE__); } while(0)
#endif
#define DPRINT1(args...) do { DebugPrint("(SAMLIB:%s:%d) ",__FILE__,__LINE__); DebugPrint(args); } while(0)
#define CHECKPOINT1 do { DebugPrint("(SAMLIB:%s:%d) Checkpoint\n",__FILE__,__LINE__); } while(0)
void
DebugPrint(char* fmt,...);
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dllmain.c,v 1.1 2004/01/23 10:33:21 ekohl Exp $ /* $Id: dllmain.c,v 1.2 2004/02/04 17:57:56 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
@ -28,7 +28,11 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <windows.h> #include <windows.h>
#include <stdio.h>
#include "debug.h"
//#define LOG_DEBUG_MESSAGES
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
@ -44,4 +48,50 @@ DllMain (HINSTANCE hInstance,
return TRUE; return TRUE;
} }
void
DebugPrint (char* fmt,...)
{
#ifdef LOG_DEBUG_MESSAGES
char FileName[MAX_PATH];
HANDLE hLogFile;
DWORD dwBytesWritten;
#endif
char buffer[512];
va_list ap;
va_start (ap, fmt);
vsprintf (buffer, fmt, ap);
va_end (ap);
OutputDebugStringA (buffer);
#ifdef LOG_DEBUG_MESSAGES
strcpy (FileName, "C:\\reactos\\samlib.log");
hLogFile = CreateFileA (FileName,
GENERIC_WRITE,
0,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hLogFile == INVALID_HANDLE_VALUE)
return;
if (SetFilePointer(hLogFile, 0, NULL, FILE_END) == 0xFFFFFFFF)
{
CloseHandle (hLogFile);
return;
}
WriteFile (hLogFile,
buffer,
strlen(buffer),
&dwBytesWritten,
NULL);
CloseHandle (hLogFile);
#endif
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: samlib.c,v 1.1 2004/01/23 10:33:21 ekohl Exp $ /* $Id: samlib.c,v 1.2 2004/02/04 17:57:56 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
@ -28,28 +28,39 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <windows.h> #include <windows.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <samlib.h> #include <samlib.h>
#define NDEBUG
#include "debug.h"
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
void
DebugPrint(char* fmt,...) static BOOL
CreateBuiltinAliases (HKEY hAliasesKey)
{ {
char buffer[512]; return TRUE;
va_list ap; }
va_start(ap, fmt);
vsprintf(buffer, fmt, ap);
va_end(ap);
OutputDebugStringA(buffer); static BOOL
CreateBuiltinGroups (HKEY hGroupsKey)
{
return TRUE;
}
static BOOL
CreateBuiltinUsers (HKEY hUsersKey)
{
return TRUE;
} }
@ -65,6 +76,8 @@ SamInitializeSAM (VOID)
HKEY hGroupsKey; HKEY hGroupsKey;
HKEY hUsersKey; HKEY hUsersKey;
DPRINT1("SamInitializeSAM() called\n");
if (RegCreateKeyExW (HKEY_LOCAL_MACHINE, if (RegCreateKeyExW (HKEY_LOCAL_MACHINE,
L"SAM\\SAM", L"SAM\\SAM",
0, 0,
@ -75,9 +88,7 @@ SamInitializeSAM (VOID)
&hSamKey, &hSamKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Sam' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Sam' key! (Error %lu)\n", GetLastError());
//#endif
return FALSE; return FALSE;
} }
@ -91,9 +102,7 @@ SamInitializeSAM (VOID)
&hDomainsKey, &hDomainsKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Domains' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Domains' key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hSamKey); RegCloseKey (hSamKey);
return FALSE; return FALSE;
} }
@ -111,9 +120,7 @@ SamInitializeSAM (VOID)
&hAccountKey, &hAccountKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Domains\\Account' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Domains\\Account' key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
return FALSE; return FALSE;
} }
@ -130,9 +137,7 @@ SamInitializeSAM (VOID)
&hAliasesKey, &hAliasesKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Account\\Aliases' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Account\\Aliases' key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hAccountKey); RegCloseKey (hAccountKey);
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
return FALSE; return FALSE;
@ -152,9 +157,7 @@ SamInitializeSAM (VOID)
&hGroupsKey, &hGroupsKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Account\\Groups' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Account\\Groups' key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hAccountKey); RegCloseKey (hAccountKey);
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
return FALSE; return FALSE;
@ -174,9 +177,7 @@ SamInitializeSAM (VOID)
&hUsersKey, &hUsersKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Account\\Users' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Account\\Users' key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hAccountKey); RegCloseKey (hAccountKey);
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
return FALSE; return FALSE;
@ -198,9 +199,7 @@ SamInitializeSAM (VOID)
&hBuiltinKey, &hBuiltinKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create Builtin key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create Builtin key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
return FALSE; return FALSE;
} }
@ -217,15 +216,21 @@ SamInitializeSAM (VOID)
&hAliasesKey, &hAliasesKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Builtin\\Aliases' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Builtin\\Aliases' key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hBuiltinKey); RegCloseKey (hBuiltinKey);
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
return FALSE; return FALSE;
} }
/* FIXME: Create builtin aliases */ /* Create builtin aliases */
if (!CreateBuiltinAliases (hAliasesKey))
{
DPRINT1 ("Failed to create builtin aliases!\n");
RegCloseKey (hAliasesKey);
RegCloseKey (hBuiltinKey);
RegCloseKey (hDomainsKey);
return FALSE;
}
RegCloseKey (hAliasesKey); RegCloseKey (hAliasesKey);
@ -241,15 +246,21 @@ SamInitializeSAM (VOID)
&hGroupsKey, &hGroupsKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Builtin\\Groups' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Builtin\\Groups' key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hBuiltinKey); RegCloseKey (hBuiltinKey);
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
return FALSE; return FALSE;
} }
/* FIXME: Create builtin groups */ /* Create builtin groups */
if (!CreateBuiltinGroups (hGroupsKey))
{
DPRINT1 ("Failed to create builtin groups!\n");
RegCloseKey (hGroupsKey);
RegCloseKey (hBuiltinKey);
RegCloseKey (hDomainsKey);
return FALSE;
}
RegCloseKey (hGroupsKey); RegCloseKey (hGroupsKey);
@ -265,15 +276,21 @@ SamInitializeSAM (VOID)
&hUsersKey, &hUsersKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create 'Builtin\\Users' key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create 'Builtin\\Users' key! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hBuiltinKey); RegCloseKey (hBuiltinKey);
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
return FALSE; return FALSE;
} }
/* FIXME: Create builtin users */ /* Create builtin users */
if (!CreateBuiltinUsers (hUsersKey))
{
DPRINT1 ("Failed to create builtin users!\n");
RegCloseKey (hUsersKey);
RegCloseKey (hBuiltinKey);
RegCloseKey (hDomainsKey);
return FALSE;
}
RegCloseKey (hUsersKey); RegCloseKey (hUsersKey);
@ -281,6 +298,8 @@ SamInitializeSAM (VOID)
RegCloseKey (hDomainsKey); RegCloseKey (hDomainsKey);
DPRINT1 ("SamInitializeSAM() done\n");
return TRUE; return TRUE;
} }
@ -288,6 +307,8 @@ SamInitializeSAM (VOID)
BOOL STDCALL BOOL STDCALL
SamGetDomainSid (PSID *Sid) SamGetDomainSid (PSID *Sid)
{ {
DPRINT1 ("SamGetDomainSid() called\n");
return FALSE; return FALSE;
} }
@ -297,15 +318,15 @@ SamSetDomainSid (PSID Sid)
{ {
HKEY hAccountKey; HKEY hAccountKey;
DPRINT1 ("SamSetDomainSid() called\n");
if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, if (RegOpenKeyExW (HKEY_LOCAL_MACHINE,
L"SAM\\SAM\\Domains\\Account", L"SAM\\SAM\\Domains\\Account",
0, 0,
KEY_ALL_ACCESS, KEY_ALL_ACCESS,
&hAccountKey)) &hAccountKey))
{ {
//#if 0 DPRINT1 ("Failed to open the Account key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to open the Account key! (Error %lu)\n", GetLastError());
//#endif
return FALSE; return FALSE;
} }
@ -316,15 +337,15 @@ SamSetDomainSid (PSID Sid)
(LPBYTE)Sid, (LPBYTE)Sid,
RtlLengthSid (Sid))) RtlLengthSid (Sid)))
{ {
//#if 0 DPRINT1 ("Failed to set Domain-SID value! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to set Domain-SID value! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hAccountKey); RegCloseKey (hAccountKey);
return FALSE; return FALSE;
} }
RegCloseKey (hAccountKey); RegCloseKey (hAccountKey);
DPRINT1 ("SamSetDomainSid() called\n");
return TRUE; return TRUE;
} }
@ -338,28 +359,26 @@ SamCreateUser (PWSTR UserName,
PSID UserSid) PSID UserSid)
{ {
DWORD dwDisposition; DWORD dwDisposition;
HKEY hAccountKey; HKEY hUsersKey;
HKEY hUserKey; HKEY hUserKey;
DebugPrint ("SamCreateUser() called\n"); DPRINT1 ("SamCreateUser() called\n");
/* FIXME: Check whether the SID is a real user sid */ /* FIXME: Check whether the SID is a real user sid */
/* 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_ALL_ACCESS, KEY_ALL_ACCESS,
&hAccountKey)) &hUsersKey))
{ {
//#if 0 DPRINT1 ("Failed to open Account key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to open Account key! (Error %lu)\n", GetLastError());
//#endif
return FALSE; return FALSE;
} }
/* Create user name key */ /* Create user name key */
if (RegCreateKeyExW (hAccountKey, if (RegCreateKeyExW (hUsersKey,
UserName, UserName,
0, 0,
NULL, NULL,
@ -369,20 +388,16 @@ SamCreateUser (PWSTR UserName,
&hUserKey, &hUserKey,
&dwDisposition)) &dwDisposition))
{ {
//#if 0 DPRINT1 ("Failed to create/open the user key! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to create/open the user key! (Error %lu)\n", GetLastError()); RegCloseKey (hUsersKey);
//#endif
RegCloseKey (hAccountKey);
return FALSE; return FALSE;
} }
RegCloseKey (hAccountKey); RegCloseKey (hUsersKey);
if (dwDisposition == REG_OPENED_EXISTING_KEY) if (dwDisposition == REG_OPENED_EXISTING_KEY)
{ {
//#if 0 DPRINT1 ("User alredy exists!\n");
DebugPrint ("User alredy exists!\n");
//#endif
RegCloseKey (hUserKey); RegCloseKey (hUserKey);
SetLastError (ERROR_USER_EXISTS); SetLastError (ERROR_USER_EXISTS);
return FALSE; return FALSE;
@ -397,9 +412,7 @@ SamCreateUser (PWSTR UserName,
(LPBYTE)UserName, (LPBYTE)UserName,
(wcslen (UserName) + 1) * sizeof (WCHAR))) (wcslen (UserName) + 1) * sizeof (WCHAR)))
{ {
//#if 0 DPRINT1 ("Failed to set the user name value! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to set the user name value! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hUserKey); RegCloseKey (hUserKey);
return FALSE; return FALSE;
} }
@ -412,9 +425,7 @@ SamCreateUser (PWSTR UserName,
(LPBYTE)UserPassword, (LPBYTE)UserPassword,
(wcslen (UserPassword) + 1) * sizeof (WCHAR))) (wcslen (UserPassword) + 1) * sizeof (WCHAR)))
{ {
//#if 0 DPRINT1 ("Failed to set the user name value! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to set the user name value! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hUserKey); RegCloseKey (hUserKey);
return FALSE; return FALSE;
} }
@ -427,15 +438,15 @@ SamCreateUser (PWSTR UserName,
(LPBYTE)UserSid, (LPBYTE)UserSid,
RtlLengthSid (UserSid))) RtlLengthSid (UserSid)))
{ {
//#if 0 DPRINT1 ("Failed to set the user SID value! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to set the user SID value! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hUserKey); RegCloseKey (hUserKey);
return FALSE; return FALSE;
} }
RegCloseKey (hUserKey); RegCloseKey (hUserKey);
DPRINT1 ("SamCreateUser() done\n");
return TRUE; return TRUE;
} }
@ -450,24 +461,24 @@ SamCheckUserPassword (PWSTR UserName,
{ {
WCHAR szPassword[256]; WCHAR szPassword[256];
DWORD dwLength; DWORD dwLength;
HKEY hAccountKey; HKEY hUsersKey;
HKEY hUserKey; HKEY hUserKey;
/* Open the Account key */ DPRINT1 ("SamCheckUserPassword() called\n");
/* 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,
@ -475,25 +486,21 @@ SamCheckUserPassword (PWSTR 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 profiles path */ /* Get the password */
dwLength = 256 * sizeof(WCHAR); dwLength = 256 * sizeof(WCHAR);
if (RegQueryValueExW (hUserKey, if (RegQueryValueExW (hUserKey,
L"Password", L"Password",
@ -502,9 +509,7 @@ SamCheckUserPassword (PWSTR UserName,
(LPBYTE)szPassword, (LPBYTE)szPassword,
&dwLength)) &dwLength))
{ {
//#if 0 DPRINT1 ("Failed to read the password! (Error %lu)\n", GetLastError());
DebugPrint ("Failed to read the password! (Error %lu)\n", GetLastError());
//#endif
RegCloseKey (hUserKey); RegCloseKey (hUserKey);
return FALSE; return FALSE;
} }
@ -515,10 +520,13 @@ SamCheckUserPassword (PWSTR UserName,
if ((wcslen (szPassword) != wcslen (UserPassword)) || if ((wcslen (szPassword) != wcslen (UserPassword)) ||
(wcscmp (szPassword, UserPassword) != 0)) (wcscmp (szPassword, UserPassword) != 0))
{ {
DPRINT1 ("Wrong password!\n");
SetLastError (ERROR_WRONG_PASSWORD); SetLastError (ERROR_WRONG_PASSWORD);
return FALSE; return FALSE;
} }
DPRINT1 ("SamCheckUserPassword() done\n");
return TRUE; return TRUE;
} }
@ -529,27 +537,27 @@ SamGetUserSid (PWSTR UserName,
{ {
PSID lpSid; PSID lpSid;
DWORD dwLength; DWORD dwLength;
HKEY hAccountKey; HKEY hUsersKey;
HKEY hUserKey; HKEY hUserKey;
DPRINT1 ("SamGetUserSid() called\n");
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 (hUserKey,
UserName, UserName,
0, 0,
KEY_READ, KEY_READ,
@ -557,23 +565,19 @@ SamGetUserSid (PWSTR 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;
@ -584,26 +588,19 @@ SamGetUserSid (PWSTR 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 DPRINT1 ("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;
} }
@ -616,9 +613,7 @@ SamGetUserSid (PWSTR 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);
@ -630,6 +625,8 @@ SamGetUserSid (PWSTR UserName,
*Sid = lpSid; *Sid = lpSid;
DPRINT1 ("SamGetUserSid() done\n");
return TRUE; return TRUE;
} }