Author: ekohl
Date: Mon Jun 10 16:20:43 2013
New Revision: 59200
URL:
http://svn.reactos.org/svn/reactos?rev=59200&view=rev
Log:
[SAMSRV]
Fix alias 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 alias 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] Mon Jun 10 16:20:43 2013
@@ -4622,6 +4622,76 @@
}
+static NTSTATUS
+SampSetAliasName(PSAM_DB_OBJECT AliasObject,
+ PSAMPR_ALIAS_INFO_BUFFER Buffer)
+{
+ UNICODE_STRING OldAliasName = {0, 0, NULL};
+ UNICODE_STRING NewAliasName;
+ NTSTATUS Status;
+
+ Status = SampGetObjectAttributeString(AliasObject,
+ L"Name",
+ (PRPC_UNICODE_STRING)&OldAliasName);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampGetObjectAttributeString failed (Status 0x%08lx)\n",
Status);
+ goto done;
+ }
+
+ NewAliasName.Length = Buffer->Name.Name.Length;
+ NewAliasName.MaximumLength = Buffer->Name.Name.MaximumLength;
+ NewAliasName.Buffer = Buffer->Name.Name.Buffer;
+
+ if (!RtlEqualUnicodeString(&OldAliasName, &NewAliasName, TRUE))
+ {
+ Status = SampCheckAccountNameInDomain(AliasObject->ParentObject,
+ NewAliasName.Buffer);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("Alias name \'%S\' already exists in domain (Status
0x%08lx)\n",
+ NewAliasName.Buffer, Status);
+ goto done;
+ }
+ }
+
+ Status = SampSetAccountNameInDomain(AliasObject->ParentObject,
+ L"Aliases",
+ NewAliasName.Buffer,
+ AliasObject->RelativeId);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampSetAccountNameInDomain failed (Status 0x%08lx)\n", Status);
+ goto done;
+ }
+
+ Status = SampRemoveAccountNameFromDomain(AliasObject->ParentObject,
+ L"Aliases",
+ OldAliasName.Buffer);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampRemoveAccountNameFromDomain failed (Status 0x%08lx)\n",
Status);
+ goto done;
+ }
+
+ Status = SampSetObjectAttribute(AliasObject,
+ L"Name",
+ REG_SZ,
+ NewAliasName.Buffer,
+ NewAliasName.Length + sizeof(WCHAR));
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("SampSetObjectAttribute failed (Status 0x%08lx)\n", Status);
+ }
+
+done:
+ if (OldAliasName.Buffer != NULL)
+ midl_user_free(OldAliasName.Buffer);
+
+ return Status;
+}
+
+
/* Function 29 */
NTSTATUS
NTAPI
@@ -4646,11 +4716,8 @@
switch (AliasInformationClass)
{
case AliasNameInformation:
- Status = SampSetObjectAttribute(AliasObject,
- L"Name",
- REG_SZ,
- Buffer->Name.Name.Buffer,
- Buffer->Name.Name.Length +
sizeof(WCHAR));
+ Status = SampSetAliasName(AliasObject,
+ Buffer);
break;
case AliasAdminCommentInformation: