Author: ekohl
Date: Fri Jun 1 22:41:43 2012
New Revision: 56687
URL:
http://svn.reactos.org/svn/reactos?rev=56687&view=rev
Log:
[SAMLIB][SAMSRV][SYSSETUP]
- Implement SamSetInformationDomain.DomainNameInformation and
SamrSetInformationDomain.DomainNameInformation.
- Set the account domain name for SAM too.
- Remove the old samlib.h file.
Removed:
trunk/reactos/include/reactos/libs/samlib/
Modified:
trunk/reactos/dll/win32/samlib/samlib.c
trunk/reactos/dll/win32/samlib/samlib.spec
trunk/reactos/dll/win32/samsrv/samrpc.c
trunk/reactos/dll/win32/syssetup/precomp.h
trunk/reactos/dll/win32/syssetup/security.c
trunk/reactos/include/ddk/ntsam.h
trunk/reactos/include/reactos/idl/sam.idl
Modified: trunk/reactos/dll/win32/samlib/samlib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samlib/samlib.c?…
==============================================================================
--- trunk/reactos/dll/win32/samlib/samlib.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samlib/samlib.c [iso-8859-1] Fri Jun 1 22:41:43 2012
@@ -293,6 +293,33 @@
NTSTATUS
NTAPI
+SamSetInformationDomain(IN SAM_HANDLE DomainHandle,
+ IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
+ IN PVOID DomainInformation)
+{
+ NTSTATUS Status;
+
+ TRACE("SamSetInformationDomain(%p %lu %p)\n",
+ DomainHandle, DomainInformationClass, DomainInformation);
+
+ RpcTryExcept
+ {
+ Status = SamrSetInformationDomain((SAMPR_HANDLE)DomainHandle,
+ DomainInformationClass,
+ DomainInformation);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
SamSetInformationUser(IN SAM_HANDLE UserHandle,
IN USER_INFORMATION_CLASS UserInformationClass,
IN PVOID Buffer)
Modified: trunk/reactos/dll/win32/samlib/samlib.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samlib/samlib.sp…
==============================================================================
--- trunk/reactos/dll/win32/samlib/samlib.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samlib/samlib.spec [iso-8859-1] Fri Jun 1 22:41:43 2012
@@ -44,7 +44,7 @@
@ stub SamRemoveMultipleMembersFromAlias
@ stub SamRidToSid
@ stub SamSetInformationAlias
-@ stub SamSetInformationDomain
+@ stdcall SamSetInformationDomain(ptr long ptr)
@ stub SamSetInformationGroup
@ stdcall SamSetInformationUser(ptr long ptr)
@ stub SamSetMemberAttributesOfGroup
Modified: trunk/reactos/dll/win32/samsrv/samrpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/samrpc.c?…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/samrpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/samrpc.c [iso-8859-1] Fri Jun 1 22:41:43 2012
@@ -359,6 +359,21 @@
return STATUS_NOT_IMPLEMENTED;
}
+static NTSTATUS
+SampSetDomainName(PSAM_DB_OBJECT DomainObject,
+ PSAMPR_DOMAIN_NAME_INFORMATION DomainNameInfo)
+{
+ NTSTATUS Status;
+
+ Status = SampSetObjectAttribute(DomainObject,
+ L"Name",
+ REG_SZ,
+ DomainNameInfo->DomainName.Buffer,
+ DomainNameInfo->DomainName.Length +
sizeof(WCHAR));
+
+ return Status;
+}
+
/* Function 9 */
NTSTATUS
NTAPI
@@ -366,8 +381,32 @@
IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
IN PSAMPR_DOMAIN_INFO_BUFFER DomainInformation)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PSAM_DB_OBJECT DomainObject;
+ NTSTATUS Status;
+
+ TRACE("SamrSetInformationDomain(%p %lu %p)\n",
+ DomainHandle, DomainInformationClass, DomainInformation);
+
+ /* Validate the server handle */
+ Status = SampValidateDbObject(DomainHandle,
+ SamDbDomainObject,
+ DOMAIN_WRITE_OTHER_PARAMETERS,
+ &DomainObject);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ switch (DomainInformationClass)
+ {
+ case DomainNameInformation:
+ Status = SampSetDomainName(DomainObject,
+
(PSAMPR_DOMAIN_NAME_INFORMATION)DomainInformation);
+ break;
+
+ default:
+ Status = STATUS_NOT_IMPLEMENTED;
+ }
+
+ return Status;
}
/* Function 10 */
Modified: trunk/reactos/dll/win32/syssetup/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/syssetup/precomp…
==============================================================================
--- trunk/reactos/dll/win32/syssetup/precomp.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/precomp.h [iso-8859-1] Fri Jun 1 22:41:43 2012
@@ -13,7 +13,6 @@
#include <io.h>
#include <tchar.h>
#include <stdlib.h>
-#include <samlib/samlib.h>
#include <syssetup/syssetup.h>
#include <userenv.h>
#include <shlobj.h>
@@ -24,6 +23,7 @@
#include <time.h>
#include <ntlsa.h>
#include <ntsecapi.h>
+#include <ntsam.h>
#include <sddl.h>
#include "globals.h"
Modified: 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 [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/syssetup/security.c [iso-8859-1] Fri Jun 1 22:41:43 2012
@@ -24,6 +24,11 @@
POLICY_ACCOUNT_DOMAIN_INFO Info;
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle;
+
+ SAM_HANDLE ServerHandle = NULL;
+ SAM_HANDLE DomainHandle = NULL;
+ DOMAIN_NAME_INFORMATION DomainNameInfo;
+
NTSTATUS Status;
DPRINT1("SYSSETUP: SetAccountDomain\n");
@@ -84,6 +89,40 @@
LsaFreeMemory(OrigInfo);
LsaClose(PolicyHandle);
+
+ DomainNameInfo.DomainName.Length = wcslen(DomainName) * sizeof(WCHAR);
+ DomainNameInfo.DomainName.MaximumLength = (wcslen(DomainName) + 1) * sizeof(WCHAR);
+ DomainNameInfo.DomainName.Buffer = (LPWSTR)DomainName;
+
+ Status = SamConnect(NULL,
+ &ServerHandle,
+ SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
+ NULL);
+ if (NT_SUCCESS(Status))
+ {
+ Status = SamOpenDomain(ServerHandle,
+ DOMAIN_WRITE_OTHER_PARAMETERS,
+ Info.DomainSid,
+ &DomainHandle);
+ if (NT_SUCCESS(Status))
+ {
+ Status = SamSetInformationDomain(DomainHandle,
+ DomainNameInformation,
+ (PVOID)&DomainNameInfo);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("SamSetInformationDomain failed (Status: 0x%08lx)\n",
Status);
+ }
+
+ SamCloseHandle(DomainHandle);
+ }
+ else
+ {
+ DPRINT1("SamOpenDomain failed (Status: 0x%08lx)\n", Status);
+ }
+
+ SamCloseHandle(ServerHandle);
+ }
return Status;
}
Modified: trunk/reactos/include/ddk/ntsam.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/ntsam.h?rev=56…
==============================================================================
--- trunk/reactos/include/ddk/ntsam.h [iso-8859-1] (original)
+++ trunk/reactos/include/ddk/ntsam.h [iso-8859-1] Fri Jun 1 22:41:43 2012
@@ -38,6 +38,28 @@
#define USER_WRITE_GROUP_INFORMATION 1024
typedef PVOID SAM_HANDLE, *PSAM_HANDLE;
+
+typedef enum _DOMAIN_INFORMATION_CLASS
+{
+ DomainPasswordInformation = 1,
+ DomainGeneralInformation,
+ DomainLogoffInformation,
+ DomainOemInformation,
+ DomainNameInformation,
+ DomainReplicationInformation,
+ DomainServerRoleInformation,
+ DomainModifiedInformation,
+ DomainStateInformation,
+ DomainUasInformation,
+ DomainGeneralInformation2,
+ DomainLockoutInformation,
+ DomainModifiedInformation2
+} DOMAIN_INFORMATION_CLASS;
+
+typedef struct _DOMAIN_NAME_INFORMATION
+{
+ UNICODE_STRING DomainName;
+} DOMAIN_NAME_INFORMATION, *PDOMAIN_NAME_INFORMATION;
typedef enum _USER_INFORMATION_CLASS
{
@@ -130,6 +152,12 @@
NTSTATUS
NTAPI
+SamSetInformationDomain(IN SAM_HANDLE DomainHandle,
+ IN DOMAIN_INFORMATION_CLASS DomainInformationClass,
+ IN PVOID DomainInformation);
+
+NTSTATUS
+NTAPI
SamSetInformationUser(IN SAM_HANDLE UserHandle,
IN USER_INFORMATION_CLASS UserInformationClass,
IN PVOID Buffer);
Modified: trunk/reactos/include/reactos/idl/sam.idl
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/idl/sam.id…
==============================================================================
--- trunk/reactos/include/reactos/idl/sam.idl [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/idl/sam.idl [iso-8859-1] Fri Jun 1 22:41:43 2012
@@ -233,6 +233,7 @@
unsigned short LockoutThreshold;
} SAMPR_DOMAIN_LOCKOUT_INFORMATION, *PSAMPR_DOMAIN_LOCKOUT_INFORMATION;
+cpp_quote("#ifndef _NTSAM_")
typedef enum _DOMAIN_INFORMATION_CLASS
{
DomainPasswordInformation = 1,
@@ -248,6 +249,7 @@
DomainLockoutInformation = 12,
DomainModifiedInformation2 = 13
} DOMAIN_INFORMATION_CLASS;
+cpp_quote("#endif")
typedef [switch_type(DOMAIN_INFORMATION_CLASS)] union _SAMPR_DOMAIN_INFO_BUFFER
{