mirror of
https://github.com/reactos/reactos.git
synced 2025-05-13 22:30:21 +00:00
[SYSSETUP]
Set the account domain name and account domain sid by using LSA functions instead of the samlib hack. svn path=/trunk/; revision=56573
This commit is contained in:
parent
dadcc449dd
commit
b209ab9884
5 changed files with 95 additions and 43 deletions
|
@ -8,6 +8,7 @@ list(APPEND SOURCE
|
||||||
dllmain.c
|
dllmain.c
|
||||||
install.c
|
install.c
|
||||||
logfile.c
|
logfile.c
|
||||||
|
security.c
|
||||||
wizard.c
|
wizard.c
|
||||||
syssetup.rc
|
syssetup.rc
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/syssetup_stubs.c
|
${CMAKE_CURRENT_BINARY_DIR}/syssetup_stubs.c
|
||||||
|
|
|
@ -61,6 +61,10 @@ extern HINSTANCE hDllInstance;
|
||||||
extern HINF hSysSetupInf;
|
extern HINF hSysSetupInf;
|
||||||
extern SETUPDATA SetupData;
|
extern SETUPDATA SetupData;
|
||||||
|
|
||||||
|
/* security.c */
|
||||||
|
NTSTATUS SetAccountDomain(LPCWSTR DomainName,
|
||||||
|
PSID DomainSid);
|
||||||
|
|
||||||
/* wizard.c */
|
/* wizard.c */
|
||||||
VOID InstallWizard (VOID);
|
VOID InstallWizard (VOID);
|
||||||
|
|
||||||
|
|
|
@ -908,9 +908,9 @@ InstallReactOS(HINSTANCE hInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the Domain SID (aka Computer SID) */
|
/* Set the Domain SID (aka Computer SID) */
|
||||||
if (!SamSetDomainSid(DomainSid))
|
if (SetAccountDomain(NULL, DomainSid) != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
FatalError("SamSetDomainSid() failed!");
|
FatalError("SetAccountDomain() failed!");
|
||||||
RtlFreeSid(DomainSid);
|
RtlFreeSid(DomainSid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
87
reactos/dll/win32/syssetup/security.c
Normal file
87
reactos/dll/win32/syssetup/security.c
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* PURPOSE: System setup
|
||||||
|
* FILE: dll/win32/syssetup/security.c
|
||||||
|
* PROGRAMER: Eric Kohl
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include "precomp.h"
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
SetAccountDomain(LPCWSTR DomainName,
|
||||||
|
PSID DomainSid)
|
||||||
|
{
|
||||||
|
PPOLICY_ACCOUNT_DOMAIN_INFO OrigInfo = NULL;
|
||||||
|
POLICY_ACCOUNT_DOMAIN_INFO Info;
|
||||||
|
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
LSA_HANDLE PolicyHandle;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES));
|
||||||
|
ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES);
|
||||||
|
|
||||||
|
Status = LsaOpenPolicy(NULL,
|
||||||
|
&ObjectAttributes,
|
||||||
|
POLICY_TRUST_ADMIN,
|
||||||
|
&PolicyHandle);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("LsaOpenPolicy failed (Status: 0x%08lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = LsaQueryInformationPolicy(PolicyHandle,
|
||||||
|
PolicyAccountDomainInformation,
|
||||||
|
(PVOID *)&OrigInfo);
|
||||||
|
if (Status == STATUS_SUCCESS && OrigInfo != NULL)
|
||||||
|
{
|
||||||
|
if (DomainName == NULL)
|
||||||
|
{
|
||||||
|
Info.DomainName.Buffer = OrigInfo->DomainName.Buffer;
|
||||||
|
Info.DomainName.Length = OrigInfo->DomainName.Length;
|
||||||
|
Info.DomainName.MaximumLength = OrigInfo->DomainName.MaximumLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info.DomainName.Buffer = (LPWSTR)DomainName;
|
||||||
|
Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR);
|
||||||
|
Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DomainSid == NULL)
|
||||||
|
Info.DomainSid = OrigInfo->DomainSid;
|
||||||
|
else
|
||||||
|
Info.DomainSid = DomainSid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info.DomainName.Buffer = (LPWSTR)DomainName;
|
||||||
|
Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR);
|
||||||
|
Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
|
||||||
|
Info.DomainSid = DomainSid;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = LsaSetInformationPolicy(PolicyHandle,
|
||||||
|
PolicyAccountDomainInformation,
|
||||||
|
(PVOID)&Info);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("LsaSetInformationPolicy failed (Status: 0x%08lx)\n", Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OrigInfo != NULL)
|
||||||
|
LsaFreeMemory(OrigInfo);
|
||||||
|
|
||||||
|
LsaClose(PolicyHandle);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -521,46 +521,6 @@ OwnerPageDlgProc(HWND hwndDlg,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
NTSTATUS
|
|
||||||
SetAccountDomain(LPWSTR DomainName)
|
|
||||||
{
|
|
||||||
POLICY_ACCOUNT_DOMAIN_INFO Info;
|
|
||||||
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
LSA_HANDLE PolicyHandle;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
memset(&ObjectAttributes, 0, sizeof(LSA_OBJECT_ATTRIBUTES));
|
|
||||||
ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES);
|
|
||||||
|
|
||||||
Status = LsaOpenPolicy(NULL,
|
|
||||||
&ObjectAttributes,
|
|
||||||
POLICY_TRUST_ADMIN,
|
|
||||||
&PolicyHandle);
|
|
||||||
if (Status != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
DPRINT("LsaOpenPolicy failed (Status: 0x%08lx)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Info.DomainName.Buffer = DomainName;
|
|
||||||
Info.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR);
|
|
||||||
Info.DomainName.MaximumLength = Info.DomainName.Length + sizeof(WCHAR);
|
|
||||||
Info.DomainSid = NULL;
|
|
||||||
|
|
||||||
Status = LsaSetInformationPolicy(PolicyHandle,
|
|
||||||
PolicyAccountDomainInformation,
|
|
||||||
(PVOID)&Info);
|
|
||||||
if (Status != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
DPRINT("LsaSetInformationPolicy failed (Status: 0x%08lx)\n", Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
LsaClose(PolicyHandle);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
static
|
||||||
BOOL
|
BOOL
|
||||||
WriteComputerSettings(WCHAR * ComputerName, HWND hwndDlg)
|
WriteComputerSettings(WCHAR * ComputerName, HWND hwndDlg)
|
||||||
|
@ -587,7 +547,7 @@ WriteComputerSettings(WCHAR * ComputerName, HWND hwndDlg)
|
||||||
SetComputerNameExW(ComputerNamePhysicalDnsHostname, ComputerName);
|
SetComputerNameExW(ComputerNamePhysicalDnsHostname, ComputerName);
|
||||||
|
|
||||||
/* Set the account domain name */
|
/* Set the account domain name */
|
||||||
SetAccountDomain(ComputerName);
|
SetAccountDomain(ComputerName, NULL);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue