Author: ekohl
Date: Sun Jul 15 19:17:19 2012
New Revision: 56901
URL:
http://svn.reactos.org/svn/reactos?rev=56901&view=rev
Log:
SAMLIB: Implement SamQueryInformatioGroup and SamSetInformationGroup.
SAMSRV: Implement SamrQueryInformatioGroup and SamrSetInformationGroup.
Modified:
trunk/reactos/dll/win32/samlib/samlib.c
trunk/reactos/dll/win32/samlib/samlib.spec
trunk/reactos/dll/win32/samsrv/samrpc.c
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] Sun Jul 15 19:17:19 2012
@@ -687,6 +687,33 @@
NTSTATUS
NTAPI
+SamQueryInformationGroup(IN SAM_HANDLE GroupHandle,
+ IN GROUP_INFORMATION_CLASS GroupInformationClass,
+ OUT PVOID *Buffer)
+{
+ NTSTATUS Status;
+
+ TRACE("SamQueryInformationGroup(%p %lu %p)\n",
+ GroupHandle, GroupInformationClass, Buffer);
+
+ RpcTryExcept
+ {
+ Status = SamrQueryInformationGroup((SAMPR_HANDLE)GroupHandle,
+ GroupInformationClass,
+ (PSAMPR_GROUP_INFO_BUFFER *)Buffer);
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
+}
+
+
+NTSTATUS
+NTAPI
SamQueryInformationUser(IN SAM_HANDLE UserHandle,
IN USER_INFORMATION_CLASS UserInformationClass,
OUT PVOID *Buffer)
@@ -768,6 +795,33 @@
NTSTATUS
NTAPI
+SamSetInformationGroup(IN SAM_HANDLE GroupHandle,
+ IN GROUP_INFORMATION_CLASS GroupInformationClass,
+ IN PVOID Buffer)
+{
+ NTSTATUS Status;
+
+ TRACE("SamSetInformationGroup(%p %lu %p)\n",
+ GroupHandle, GroupInformationClass, Buffer);
+
+ RpcTryExcept
+ {
+ Status = SamrSetInformationGroup((SAMPR_HANDLE)GroupHandle,
+ GroupInformationClass,
+ Buffer);
+ }
+ 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] Sun Jul 15 19:17:19 2012
@@ -35,7 +35,7 @@
@ stub SamQueryDisplayInformation
@ stdcall SamQueryInformationAlias(ptr long ptr)
@ stdcall SamQueryInformationDomain(ptr long ptr)
-@ stub SamQueryInformationGroup
+@ stdcall SamQueryInformationGroup(ptr long ptr)
@ stdcall SamQueryInformationUser(ptr long ptr)
@ stub SamQuerySecurityObject
@ stub SamRemoveMemberFromAlias
@@ -45,7 +45,7 @@
@ stub SamRidToSid
@ stdcall SamSetInformationAlias(ptr long ptr)
@ stdcall SamSetInformationDomain(ptr long ptr)
-@ stub SamSetInformationGroup
+@ stdcall SamSetInformationGroup(ptr long ptr)
@ stdcall SamSetInformationUser(ptr long ptr)
@ stub SamSetMemberAttributesOfGroup
@ stub SamSetSecurityObject
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] Sun Jul 15 19:17:19 2012
@@ -2550,6 +2550,217 @@
}
+static NTSTATUS
+SampQueryGroupGeneral(PSAM_DB_OBJECT GroupObject,
+ PSAMPR_GROUP_INFO_BUFFER *Buffer)
+{
+ PSAMPR_GROUP_INFO_BUFFER InfoBuffer = NULL;
+ HANDLE MembersKeyHandle = NULL;
+ SAM_GROUP_FIXED_DATA FixedData;
+ ULONG Length = 0;
+ NTSTATUS Status;
+
+ *Buffer = NULL;
+
+ InfoBuffer = midl_user_allocate(sizeof(SAMPR_GROUP_INFO_BUFFER));
+ if (InfoBuffer == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ Status = SampGetObjectAttributeString(GroupObject,
+ L"Name",
+ &InfoBuffer->General.Name);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Status = SampGetObjectAttributeString(GroupObject,
+ L"Description",
+ &InfoBuffer->General.AdminComment);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ Length = sizeof(SAM_GROUP_FIXED_DATA);
+ Status = SampGetObjectAttribute(GroupObject,
+ L"F",
+ NULL,
+ (PVOID)&FixedData,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ InfoBuffer->General.Attributes = FixedData.Attributes;
+
+ /* Open the Members subkey */
+ Status = SampRegOpenKey(GroupObject->KeyHandle,
+ L"Members",
+ KEY_READ,
+ &MembersKeyHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ /* Retrieve the number of members of the alias */
+ Status = SampRegQueryKeyInfo(MembersKeyHandle,
+ NULL,
+ &InfoBuffer->General.MemberCount);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ *Buffer = InfoBuffer;
+
+done:
+ if (MembersKeyHandle != NULL)
+ SampRegCloseKey(MembersKeyHandle);
+
+ if (!NT_SUCCESS(Status))
+ {
+ if (InfoBuffer != NULL)
+ {
+ if (InfoBuffer->General.Name.Buffer != NULL)
+ midl_user_free(InfoBuffer->General.Name.Buffer);
+
+ if (InfoBuffer->General.AdminComment.Buffer != NULL)
+ midl_user_free(InfoBuffer->General.AdminComment.Buffer);
+
+ midl_user_free(InfoBuffer);
+ }
+ }
+
+ return Status;
+}
+
+
+static NTSTATUS
+SampQueryGroupName(PSAM_DB_OBJECT GroupObject,
+ PSAMPR_GROUP_INFO_BUFFER *Buffer)
+{
+ PSAMPR_GROUP_INFO_BUFFER InfoBuffer = NULL;
+ NTSTATUS Status;
+
+ *Buffer = NULL;
+
+ InfoBuffer = midl_user_allocate(sizeof(SAMPR_GROUP_INFO_BUFFER));
+ if (InfoBuffer == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ Status = SampGetObjectAttributeString(GroupObject,
+ L"Name",
+ &InfoBuffer->Name.Name);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ *Buffer = InfoBuffer;
+
+done:
+ if (!NT_SUCCESS(Status))
+ {
+ if (InfoBuffer != NULL)
+ {
+ if (InfoBuffer->Name.Name.Buffer != NULL)
+ midl_user_free(InfoBuffer->Name.Name.Buffer);
+
+ midl_user_free(InfoBuffer);
+ }
+ }
+
+ return Status;
+}
+
+
+static NTSTATUS
+SampQueryGroupAttribute(PSAM_DB_OBJECT GroupObject,
+ PSAMPR_GROUP_INFO_BUFFER *Buffer)
+{
+ PSAMPR_GROUP_INFO_BUFFER InfoBuffer = NULL;
+ SAM_GROUP_FIXED_DATA FixedData;
+ ULONG Length = 0;
+ NTSTATUS Status;
+
+ *Buffer = NULL;
+
+ InfoBuffer = midl_user_allocate(sizeof(SAMPR_GROUP_INFO_BUFFER));
+ if (InfoBuffer == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ Length = sizeof(SAM_GROUP_FIXED_DATA);
+ Status = SampGetObjectAttribute(GroupObject,
+ L"F",
+ NULL,
+ (PVOID)&FixedData,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ InfoBuffer->Attribute.Attributes = FixedData.Attributes;
+
+ *Buffer = InfoBuffer;
+
+done:
+ if (!NT_SUCCESS(Status))
+ {
+ if (InfoBuffer != NULL)
+ {
+ midl_user_free(InfoBuffer);
+ }
+ }
+
+ return Status;
+}
+
+
+static NTSTATUS
+SampQueryGroupAdminComment(PSAM_DB_OBJECT GroupObject,
+ PSAMPR_GROUP_INFO_BUFFER *Buffer)
+{
+ PSAMPR_GROUP_INFO_BUFFER InfoBuffer = NULL;
+ NTSTATUS Status;
+
+ *Buffer = NULL;
+
+ InfoBuffer = midl_user_allocate(sizeof(SAMPR_GROUP_INFO_BUFFER));
+ if (InfoBuffer == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ Status = SampGetObjectAttributeString(GroupObject,
+ L"Description",
+
&InfoBuffer->AdminComment.AdminComment);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Status 0x%08lx\n", Status);
+ goto done;
+ }
+
+ *Buffer = InfoBuffer;
+
+done:
+ if (!NT_SUCCESS(Status))
+ {
+ if (InfoBuffer != NULL)
+ {
+ if (InfoBuffer->AdminComment.AdminComment.Buffer != NULL)
+ midl_user_free(InfoBuffer->AdminComment.AdminComment.Buffer);
+
+ midl_user_free(InfoBuffer);
+ }
+ }
+
+ return Status;
+}
+
+
/* Function 20 */
NTSTATUS
NTAPI
@@ -2557,9 +2768,80 @@
IN GROUP_INFORMATION_CLASS GroupInformationClass,
OUT PSAMPR_GROUP_INFO_BUFFER *Buffer)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
+ PSAM_DB_OBJECT GroupObject;
+ NTSTATUS Status;
+
+ TRACE("SamrQueryInformationGroup(%p %lu %p)\n",
+ GroupHandle, GroupInformationClass, Buffer);
+
+ /* Validate the group handle */
+ Status = SampValidateDbObject(GroupHandle,
+ SamDbGroupObject,
+ GROUP_READ_INFORMATION,
+ &GroupObject);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ switch (GroupInformationClass)
+ {
+ case GroupGeneralInformation:
+ Status = SampQueryGroupGeneral(GroupObject,
+ Buffer);
+ break;
+
+ case GroupNameInformation:
+ Status = SampQueryGroupName(GroupObject,
+ Buffer);
+ break;
+
+ case GroupAttributeInformation:
+ Status = SampQueryGroupAttribute(GroupObject,
+ Buffer);
+ break;
+
+ case GroupAdminCommentInformation:
+ Status = SampQueryGroupAdminComment(GroupObject,
+ Buffer);
+ break;
+
+ default:
+ Status = STATUS_INVALID_INFO_CLASS;
+ break;
+ }
+
+ return Status;
+}
+
+
+static NTSTATUS
+SampSetGroupAttribute(PSAM_DB_OBJECT GroupObject,
+ PSAMPR_GROUP_INFO_BUFFER Buffer)
+{
+ SAM_GROUP_FIXED_DATA FixedData;
+ ULONG Length = 0;
+ NTSTATUS Status;
+
+ Length = sizeof(SAM_GROUP_FIXED_DATA);
+ Status = SampGetObjectAttribute(GroupObject,
+ L"F",
+ NULL,
+ (PVOID)&FixedData,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ FixedData.Attributes = Buffer->Attribute.Attributes;
+
+ Status = SampSetObjectAttribute(GroupObject,
+ L"F",
+ REG_BINARY,
+ &FixedData,
+ Length);
+
+done:
+ return Status;
+}
+
/* Function 21 */
NTSTATUS
@@ -2568,9 +2850,51 @@
IN GROUP_INFORMATION_CLASS GroupInformationClass,
IN PSAMPR_GROUP_INFO_BUFFER Buffer)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
-}
+ PSAM_DB_OBJECT GroupObject;
+ NTSTATUS Status;
+
+ TRACE("SamrSetInformationGroup(%p %lu %p)\n",
+ GroupHandle, GroupInformationClass, Buffer);
+
+ /* Validate the group handle */
+ Status = SampValidateDbObject(GroupHandle,
+ SamDbGroupObject,
+ GROUP_WRITE_ACCOUNT,
+ &GroupObject);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ switch (GroupInformationClass)
+ {
+ case GroupNameInformation:
+ Status = SampSetObjectAttribute(GroupObject,
+ L"Name",
+ REG_SZ,
+ Buffer->Name.Name.Buffer,
+ Buffer->Name.Name.Length +
sizeof(WCHAR));
+ break;
+
+ case GroupAttributeInformation:
+ Status = SampSetGroupAttribute(GroupObject,
+ Buffer);
+ break;
+
+ case GroupAdminCommentInformation:
+ Status = SampSetObjectAttribute(GroupObject,
+ L"Description",
+ REG_SZ,
+ Buffer->AdminComment.AdminComment.Buffer,
+ Buffer->AdminComment.AdminComment.Length +
sizeof(WCHAR));
+ break;
+
+ default:
+ Status = STATUS_INVALID_INFO_CLASS;
+ break;
+ }
+
+ return Status;
+}
+
/* Function 22 */
NTSTATUS
@@ -2622,6 +2946,7 @@
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
+
/* Function 27 */
NTSTATUS
@@ -2875,6 +3200,7 @@
return Status;
}
+
/* Function 29 */
NTSTATUS
NTAPI
@@ -2922,6 +3248,7 @@
return Status;
}
+
/* Function 30 */
NTSTATUS
NTAPI
@@ -2930,6 +3257,7 @@
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
+
/* Function 31 */
NTSTATUS
@@ -3017,6 +3345,7 @@
return Status;
}
+
/* Function 32 */
NTSTATUS