Author: ekohl
Date: Sun May 13 16:16:18 2012
New Revision: 56573
URL:
http://svn.reactos.org/svn/reactos?rev=56573&view=rev
Log:
[SYSSETUP]
Set the account domain name and account domain sid by using LSA functions instead of the
samlib hack.
Added:
trunk/reactos/dll/win32/syssetup/security.c (with props)
Modified:
trunk/reactos/dll/win32/syssetup/CMakeLists.txt
trunk/reactos/dll/win32/syssetup/globals.h
trunk/reactos/dll/win32/syssetup/install.c
trunk/reactos/dll/win32/syssetup/wizard.c
Modified: trunk/reactos/dll/win32/syssetup/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/CMakeLi…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/CMakeLists.txt [iso-8859-1] Sun May 13 16:16:18 2012
@@ -8,6 +8,7 @@
dllmain.c
install.c
logfile.c
+ security.c
wizard.c
syssetup.rc
${CMAKE_CURRENT_BINARY_DIR}/syssetup_stubs.c
Modified: trunk/reactos/dll/win32/syssetup/globals.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/globals…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/globals.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/globals.h [iso-8859-1] Sun May 13 16:16:18 2012
@@ -61,6 +61,10 @@
extern HINF hSysSetupInf;
extern SETUPDATA SetupData;
+/* security.c */
+NTSTATUS SetAccountDomain(LPCWSTR DomainName,
+ PSID DomainSid);
+
/* wizard.c */
VOID InstallWizard (VOID);
Modified: trunk/reactos/dll/win32/syssetup/install.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/install…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/install.c [iso-8859-1] Sun May 13 16:16:18 2012
@@ -908,9 +908,9 @@
}
/* Set the Domain SID (aka Computer SID) */
- if (!SamSetDomainSid(DomainSid))
- {
- FatalError("SamSetDomainSid() failed!");
+ if (SetAccountDomain(NULL, DomainSid) != STATUS_SUCCESS)
+ {
+ FatalError("SetAccountDomain() failed!");
RtlFreeSid(DomainSid);
return 0;
}
Added: trunk/reactos/dll/win32/syssetup/security.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/securit…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/security.c (added)
+++ trunk/reactos/dll/win32/syssetup/security.c [iso-8859-1] Sun May 13 16:16:18 2012
@@ -1,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;
+}
Propchange: trunk/reactos/dll/win32/syssetup/security.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/reactos/dll/win32/syssetup/security.c
------------------------------------------------------------------------------
svn:keywords = author date id revision
Modified: trunk/reactos/dll/win32/syssetup/wizard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/wizard.…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] Sun May 13 16:16:18 2012
@@ -522,46 +522,6 @@
}
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
BOOL
WriteComputerSettings(WCHAR * ComputerName, HWND hwndDlg)
{
@@ -587,7 +547,7 @@
SetComputerNameExW(ComputerNamePhysicalDnsHostname, ComputerName);
/* Set the account domain name */
- SetAccountDomain(ComputerName);
+ SetAccountDomain(ComputerName, NULL);
return TRUE;
}