[ros-diffs] [ekohl] 53794: [SYSSETUP] Set the account domain name.

ekohl at svn.reactos.org ekohl at svn.reactos.org
Wed Sep 21 20:53:47 UTC 2011


Author: ekohl
Date: Wed Sep 21 20:53:46 2011
New Revision: 53794

URL: http://svn.reactos.org/svn/reactos?rev=53794&view=rev
Log:
[SYSSETUP]
Set the account domain name.

Modified:
    trunk/reactos/dll/win32/syssetup/wizard.c

Modified: trunk/reactos/dll/win32/syssetup/wizard.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/wizard.c?rev=53794&r1=53793&r2=53794&view=diff
==============================================================================
--- trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/wizard.c [iso-8859-1] Wed Sep 21 20:53:46 2011
@@ -520,6 +520,47 @@
 
   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
 BOOL
 WriteComputerSettings(WCHAR * ComputerName, HWND hwndDlg)
@@ -544,6 +585,9 @@
 
   /* Try to also set DNS hostname */
   SetComputerNameExW(ComputerNamePhysicalDnsHostname, ComputerName);
+
+  /* Set the account domain name */
+  SetAccountDomain(ComputerName);
 
   return TRUE;
 }




More information about the Ros-diffs mailing list