Author: ekohl
Date: Mon Jan 14 21:56:45 2013
New Revision: 58176
URL:
http://svn.reactos.org/svn/reactos?rev=58176&view=rev
Log:
[SAMSRV]
Implement SamrSetMemberAttributesOfGroup.
Modified:
trunk/reactos/dll/win32/samsrv/samrpc.c
trunk/reactos/dll/win32/samsrv/samsrv.h
trunk/reactos/dll/win32/samsrv/user.c
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] Mon Jan 14 21:56:45 2013
@@ -4158,8 +4158,30 @@
IN unsigned long MemberId,
IN unsigned long Attributes)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ PSAM_DB_OBJECT GroupObject;
+ NTSTATUS Status;
+
+ /* Validate the group handle */
+ Status = SampValidateDbObject(GroupHandle,
+ SamDbGroupObject,
+ GROUP_ADD_MEMBER,
+ &GroupObject);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampValidateDbObject failed with status 0x%08lx\n", Status);
+ return Status;
+ }
+
+ Status = SampSetUserGroupAttributes(GroupObject->ParentObject,
+ MemberId,
+ GroupObject->RelativeId,
+ Attributes);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampSetUserGroupAttributes failed with status 0x%08lx\n",
Status);
+ }
+
+ return Status;
}
Modified: trunk/reactos/dll/win32/samsrv/samsrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/samsrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/samsrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/samsrv.h [iso-8859-1] Mon Jan 14 21:56:45 2013
@@ -285,4 +285,10 @@
IN ULONG GroupId,
OUT PULONG GroupAttributes);
+NTSTATUS
+SampSetUserGroupAttributes(IN PSAM_DB_OBJECT DomainObject,
+ IN ULONG UserId,
+ IN ULONG GroupId,
+ IN ULONG GroupAttributes);
+
/* EOF */
Modified: trunk/reactos/dll/win32/samsrv/user.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/samsrv/user.c?re…
==============================================================================
--- trunk/reactos/dll/win32/samsrv/user.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/samsrv/user.c [iso-8859-1] Mon Jan 14 21:56:45 2013
@@ -214,10 +214,7 @@
&Length);
if (Length == 0)
- {
- *GroupAttributes = 0;
- return STATUS_SUCCESS;
- }
+ return STATUS_UNSUCCESSFUL; /* FIXME */
GroupsBuffer = midl_user_allocate(Length);
if (GroupsBuffer == NULL)
@@ -253,4 +250,75 @@
return Status;
}
+
+NTSTATUS
+SampSetUserGroupAttributes(IN PSAM_DB_OBJECT DomainObject,
+ IN ULONG UserId,
+ IN ULONG GroupId,
+ IN ULONG GroupAttributes)
+{
+ PSAM_DB_OBJECT UserObject = NULL;
+ PGROUP_MEMBERSHIP GroupsBuffer = NULL;
+ ULONG Length = 0;
+ ULONG i;
+ NTSTATUS Status;
+
+ Status = SampOpenUserObject(DomainObject,
+ UserId,
+ 0,
+ &UserObject);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+
+ SampGetObjectAttribute(UserObject,
+ L"Groups",
+ NULL,
+ NULL,
+ &Length);
+
+ if (Length == 0)
+ return STATUS_UNSUCCESSFUL; /* FIXME */
+
+ GroupsBuffer = midl_user_allocate(Length);
+ if (GroupsBuffer == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+ Status = SampGetObjectAttribute(UserObject,
+ L"Groups",
+ NULL,
+ GroupsBuffer,
+ &Length);
+ if (!NT_SUCCESS(Status))
+ goto done;
+
+ for (i = 0; i < (Length / sizeof(GROUP_MEMBERSHIP)); i++)
+ {
+ if (GroupsBuffer[i].RelativeId == GroupId)
+ {
+ GroupsBuffer[i].Attributes = GroupAttributes;
+ break;
+ }
+ }
+
+ Status = SampSetObjectAttribute(UserObject,
+ L"Groups",
+ REG_BINARY,
+ GroupsBuffer,
+ Length);
+
+done:
+ if (GroupsBuffer != NULL)
+ midl_user_free(GroupsBuffer);
+
+ if (UserObject != NULL)
+ SampCloseDbObject(UserObject);
+
+ return Status;
+}
+
/* EOF */