Author: ekohl
Date: Tue Jun 11 21:09:26 2013
New Revision: 59204
URL:
http://svn.reactos.org/svn/reactos?rev=59204&view=rev
Log:
[SAMSRV]
Fix group renaming code. It is not enough to set the name attribute. The domain object
also need a new name-id mapping. Also fail if the new group name is already used by any
account object in the domain.
Modified:
trunk/reactos/dll/win32/samsrv/samrpc.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] Tue Jun 11 21:09:26 2013
@@ -3963,6 +3963,76 @@
static NTSTATUS
+SampSetGroupName(PSAM_DB_OBJECT GroupObject,
+ PSAMPR_GROUP_INFO_BUFFER Buffer)
+{
+ UNICODE_STRING OldGroupName = {0, 0, NULL};
+ UNICODE_STRING NewGroupName;
+ NTSTATUS Status;
+
+ Status = SampGetObjectAttributeString(GroupObject,
+ L"Name",
+ (PRPC_UNICODE_STRING)&OldGroupName);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampGetObjectAttributeString failed (Status 0x%08lx)\n",
Status);
+ goto done;
+ }
+
+ NewGroupName.Length = Buffer->Name.Name.Length;
+ NewGroupName.MaximumLength = Buffer->Name.Name.MaximumLength;
+ NewGroupName.Buffer = Buffer->Name.Name.Buffer;
+
+ if (!RtlEqualUnicodeString(&OldGroupName, &NewGroupName, TRUE))
+ {
+ Status = SampCheckAccountNameInDomain(GroupObject->ParentObject,
+ NewGroupName.Buffer);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Group name \'%S\' already exists in domain (Status
0x%08lx)\n",
+ NewGroupName.Buffer, Status);
+ goto done;
+ }
+ }
+
+ Status = SampSetAccountNameInDomain(GroupObject->ParentObject,
+ L"Groups",
+ NewGroupName.Buffer,
+ GroupObject->RelativeId);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampSetAccountNameInDomain failed (Status 0x%08lx)\n", Status);
+ goto done;
+ }
+
+ Status = SampRemoveAccountNameFromDomain(GroupObject->ParentObject,
+ L"Groups",
+ OldGroupName.Buffer);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRemoveAccountNameFromDomain failed (Status 0x%08lx)\n",
Status);
+ goto done;
+ }
+
+ Status = SampSetObjectAttribute(GroupObject,
+ L"Name",
+ REG_SZ,
+ NewGroupName.Buffer,
+ NewGroupName.Length + sizeof(WCHAR));
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampSetObjectAttribute failed (Status 0x%08lx)\n", Status);
+ }
+
+done:
+ if (OldGroupName.Buffer != NULL)
+ midl_user_free(OldGroupName.Buffer);
+
+ return Status;
+}
+
+
+static NTSTATUS
SampSetGroupAttribute(PSAM_DB_OBJECT GroupObject,
PSAMPR_GROUP_INFO_BUFFER Buffer)
{
@@ -4016,11 +4086,8 @@
switch (GroupInformationClass)
{
case GroupNameInformation:
- Status = SampSetObjectAttribute(GroupObject,
- L"Name",
- REG_SZ,
- Buffer->Name.Name.Buffer,
- Buffer->Name.Name.Length +
sizeof(WCHAR));
+ Status = SampSetGroupName(GroupObject,
+ Buffer);
break;
case GroupAttributeInformation: