mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 05:05:09 +00:00
[SAMSRV]
Add Names sub keys to the Alias, Groups and Users keys of the Account an Builtin domains. These will later contain the 'Name to SID' entries that will simplify lookup by name operations. svn path=/trunk/; revision=56670
This commit is contained in:
parent
f07bb17c73
commit
14c472ac5d
|
@ -55,6 +55,28 @@ SampIsSetupRunning(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static BOOL
|
||||||
|
CreateNamesKey(HKEY hParentKey)
|
||||||
|
{
|
||||||
|
DWORD dwDisposition;
|
||||||
|
HKEY hNamesKey;
|
||||||
|
|
||||||
|
if (RegCreateKeyExW(hParentKey,
|
||||||
|
L"Names",
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
REG_OPTION_NON_VOLATILE,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
&hNamesKey,
|
||||||
|
&dwDisposition))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
RegCloseKey(hNamesKey);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static BOOL
|
static BOOL
|
||||||
CreateBuiltinAliases(HKEY hAliasesKey)
|
CreateBuiltinAliases(HKEY hAliasesKey)
|
||||||
{
|
{
|
||||||
|
@ -80,13 +102,14 @@ BOOL
|
||||||
SampInitializeSAM(VOID)
|
SampInitializeSAM(VOID)
|
||||||
{
|
{
|
||||||
DWORD dwDisposition;
|
DWORD dwDisposition;
|
||||||
HKEY hSamKey;
|
HKEY hSamKey = NULL;
|
||||||
HKEY hDomainsKey;
|
HKEY hDomainsKey = NULL;
|
||||||
HKEY hAccountKey;
|
HKEY hAccountKey = NULL;
|
||||||
HKEY hBuiltinKey;
|
HKEY hBuiltinKey = NULL;
|
||||||
HKEY hAliasesKey;
|
HKEY hAliasesKey = NULL;
|
||||||
HKEY hGroupsKey;
|
HKEY hGroupsKey = NULL;
|
||||||
HKEY hUsersKey;
|
HKEY hUsersKey = NULL;
|
||||||
|
BOOL bResult = TRUE;
|
||||||
|
|
||||||
TRACE("SampInitializeSAM() called\n");
|
TRACE("SampInitializeSAM() called\n");
|
||||||
|
|
||||||
|
@ -115,11 +138,12 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create 'Domains' key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create 'Domains' key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hSamKey);
|
bResult = FALSE;
|
||||||
return FALSE;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey (hSamKey);
|
RegCloseKey(hSamKey);
|
||||||
|
hSamKey = NULL;
|
||||||
|
|
||||||
/* Create the 'Domains\\Account' key */
|
/* Create the 'Domains\\Account' key */
|
||||||
if (RegCreateKeyExW(hDomainsKey,
|
if (RegCreateKeyExW(hDomainsKey,
|
||||||
|
@ -133,8 +157,8 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create 'Domains\\Account' key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create 'Domains\\Account' key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hDomainsKey);
|
bResult = FALSE;
|
||||||
return FALSE;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -150,13 +174,19 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create 'Account\\Aliases' key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create 'Account\\Aliases' key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hAccountKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hDomainsKey);
|
goto done;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey (hAliasesKey);
|
if (!CreateNamesKey(hAliasesKey))
|
||||||
|
{
|
||||||
|
ERR("Failed to create 'Account\\Aliases\\Names' key! (Error %lu)\n", GetLastError());
|
||||||
|
bResult = FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hAliasesKey);
|
||||||
|
hAliasesKey = NULL;
|
||||||
|
|
||||||
/* Create the 'Account\Groups' key */
|
/* Create the 'Account\Groups' key */
|
||||||
if (RegCreateKeyExW(hAccountKey,
|
if (RegCreateKeyExW(hAccountKey,
|
||||||
|
@ -170,12 +200,19 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create 'Account\\Groups' key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create 'Account\\Groups' key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hAccountKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hDomainsKey);
|
goto done;
|
||||||
return FALSE;
|
}
|
||||||
|
|
||||||
|
if (!CreateNamesKey(hGroupsKey))
|
||||||
|
{
|
||||||
|
ERR("Failed to create 'Account\\Groups\\Names' key! (Error %lu)\n", GetLastError());
|
||||||
|
bResult = FALSE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hGroupsKey);
|
RegCloseKey(hGroupsKey);
|
||||||
|
hGroupsKey = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* Create the 'Account\Users' key */
|
/* Create the 'Account\Users' key */
|
||||||
|
@ -190,15 +227,22 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create 'Account\\Users' key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create 'Account\\Users' key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hAccountKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hDomainsKey);
|
goto done;
|
||||||
return FALSE;
|
}
|
||||||
|
|
||||||
|
if (!CreateNamesKey(hUsersKey))
|
||||||
|
{
|
||||||
|
ERR("Failed to create 'Account\\Aliases\\Users' key! (Error %lu)\n", GetLastError());
|
||||||
|
bResult = FALSE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hUsersKey);
|
RegCloseKey(hUsersKey);
|
||||||
|
hUsersKey = NULL;
|
||||||
|
|
||||||
RegCloseKey(hAccountKey);
|
RegCloseKey(hAccountKey);
|
||||||
|
hAccountKey = NULL;
|
||||||
|
|
||||||
/* Create the 'Domains\\Builtin' */
|
/* Create the 'Domains\\Builtin' */
|
||||||
if (RegCreateKeyExW(hDomainsKey,
|
if (RegCreateKeyExW(hDomainsKey,
|
||||||
|
@ -212,8 +256,8 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create Builtin key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create Builtin key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hDomainsKey);
|
bResult = FALSE;
|
||||||
return FALSE;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -229,23 +273,27 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create 'Builtin\\Aliases' key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create 'Builtin\\Aliases' key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hBuiltinKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hDomainsKey);
|
goto done;
|
||||||
return FALSE;
|
}
|
||||||
|
|
||||||
|
if (!CreateNamesKey(hAliasesKey))
|
||||||
|
{
|
||||||
|
ERR("Failed to create 'Builtin\\Aliases\\Names' key! (Error %lu)\n", GetLastError());
|
||||||
|
bResult = FALSE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create builtin aliases */
|
/* Create builtin aliases */
|
||||||
if (!CreateBuiltinAliases(hAliasesKey))
|
if (!CreateBuiltinAliases(hAliasesKey))
|
||||||
{
|
{
|
||||||
ERR("Failed to create builtin aliases!\n");
|
ERR("Failed to create builtin aliases!\n");
|
||||||
RegCloseKey(hAliasesKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hBuiltinKey);
|
goto done;
|
||||||
RegCloseKey(hDomainsKey);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hAliasesKey);
|
RegCloseKey(hAliasesKey);
|
||||||
|
hAliasesKey = NULL;
|
||||||
|
|
||||||
/* Create the 'Builtin\Groups' key */
|
/* Create the 'Builtin\Groups' key */
|
||||||
if (RegCreateKeyExW(hBuiltinKey,
|
if (RegCreateKeyExW(hBuiltinKey,
|
||||||
|
@ -259,22 +307,27 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create 'Builtin\\Groups' key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create 'Builtin\\Groups' key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hBuiltinKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hDomainsKey);
|
goto done;
|
||||||
return FALSE;
|
}
|
||||||
|
|
||||||
|
if (!CreateNamesKey(hGroupsKey))
|
||||||
|
{
|
||||||
|
ERR("Failed to create 'Builtin\\Groups\\Names' key! (Error %lu)\n", GetLastError());
|
||||||
|
bResult = FALSE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create builtin groups */
|
/* Create builtin groups */
|
||||||
if (!CreateBuiltinGroups(hGroupsKey))
|
if (!CreateBuiltinGroups(hGroupsKey))
|
||||||
{
|
{
|
||||||
ERR("Failed to create builtin groups!\n");
|
ERR("Failed to create builtin groups!\n");
|
||||||
RegCloseKey(hGroupsKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hBuiltinKey);
|
goto done;
|
||||||
RegCloseKey(hDomainsKey);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hGroupsKey);
|
RegCloseKey(hGroupsKey);
|
||||||
|
hGroupsKey = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* Create the 'Builtin\Users' key */
|
/* Create the 'Builtin\Users' key */
|
||||||
|
@ -289,28 +342,48 @@ SampInitializeSAM(VOID)
|
||||||
&dwDisposition))
|
&dwDisposition))
|
||||||
{
|
{
|
||||||
ERR("Failed to create 'Builtin\\Users' key! (Error %lu)\n", GetLastError());
|
ERR("Failed to create 'Builtin\\Users' key! (Error %lu)\n", GetLastError());
|
||||||
RegCloseKey(hBuiltinKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hDomainsKey);
|
goto done;
|
||||||
return FALSE;
|
}
|
||||||
|
|
||||||
|
if (!CreateNamesKey(hUsersKey))
|
||||||
|
{
|
||||||
|
ERR("Failed to create 'Builtin\\Users\\Names' key! (Error %lu)\n", GetLastError());
|
||||||
|
bResult = FALSE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create builtin users */
|
/* Create builtin users */
|
||||||
if (!CreateBuiltinUsers(hUsersKey))
|
if (!CreateBuiltinUsers(hUsersKey))
|
||||||
{
|
{
|
||||||
ERR("Failed to create builtin users!\n");
|
ERR("Failed to create builtin users!\n");
|
||||||
RegCloseKey(hUsersKey);
|
bResult = FALSE;
|
||||||
RegCloseKey(hBuiltinKey);
|
goto done;
|
||||||
RegCloseKey(hDomainsKey);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (hAliasesKey)
|
||||||
|
RegCloseKey(hAliasesKey);
|
||||||
|
|
||||||
|
if (hGroupsKey)
|
||||||
|
RegCloseKey(hGroupsKey);
|
||||||
|
|
||||||
|
if (hUsersKey)
|
||||||
RegCloseKey(hUsersKey);
|
RegCloseKey(hUsersKey);
|
||||||
|
|
||||||
|
if (hAccountKey)
|
||||||
|
RegCloseKey(hAccountKey);
|
||||||
|
|
||||||
|
if (hBuiltinKey)
|
||||||
RegCloseKey(hBuiltinKey);
|
RegCloseKey(hBuiltinKey);
|
||||||
|
|
||||||
|
if (hDomainsKey)
|
||||||
RegCloseKey(hDomainsKey);
|
RegCloseKey(hDomainsKey);
|
||||||
|
|
||||||
|
if (hSamKey)
|
||||||
|
RegCloseKey(hSamKey);
|
||||||
|
|
||||||
TRACE("SampInitializeSAM() done\n");
|
TRACE("SampInitializeSAM() done\n");
|
||||||
|
|
||||||
return TRUE;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue