mirror of
https://github.com/reactos/reactos.git
synced 2025-04-19 20:19:26 +00:00
[SAMSRV]
Changing user account names requires more than just changing the name attribute. Do it properly. svn path=/trunk/; revision=59278
This commit is contained in:
parent
0aa1f8c0cc
commit
dc5e210e8f
1 changed files with 73 additions and 20 deletions
|
@ -6751,6 +6751,71 @@ SamrQueryInformationUser(IN SAMPR_HANDLE UserHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static NTSTATUS
|
||||||
|
SampSetUserName(PSAM_DB_OBJECT UserObject,
|
||||||
|
PRPC_UNICODE_STRING NewUserName)
|
||||||
|
{
|
||||||
|
UNICODE_STRING OldUserName = {0, 0, NULL};
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = SampGetObjectAttributeString(UserObject,
|
||||||
|
L"Name",
|
||||||
|
(PRPC_UNICODE_STRING)&OldUserName);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
TRACE("SampGetObjectAttributeString failed (Status 0x%08lx)\n", Status);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RtlEqualUnicodeString(&OldUserName, (PCUNICODE_STRING)NewUserName, TRUE))
|
||||||
|
{
|
||||||
|
Status = SampCheckAccountNameInDomain(UserObject->ParentObject,
|
||||||
|
NewUserName->Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
TRACE("User name \'%S\' already exists in domain (Status 0x%08lx)\n",
|
||||||
|
NewUserName->Buffer, Status);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = SampSetAccountNameInDomain(UserObject->ParentObject,
|
||||||
|
L"Users",
|
||||||
|
NewUserName->Buffer,
|
||||||
|
UserObject->RelativeId);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
TRACE("SampSetAccountNameInDomain failed (Status 0x%08lx)\n", Status);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = SampRemoveAccountNameFromDomain(UserObject->ParentObject,
|
||||||
|
L"Users",
|
||||||
|
OldUserName.Buffer);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
TRACE("SampRemoveAccountNameFromDomain failed (Status 0x%08lx)\n", Status);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = SampSetObjectAttribute(UserObject,
|
||||||
|
L"Name",
|
||||||
|
REG_SZ,
|
||||||
|
NewUserName->Buffer,
|
||||||
|
NewUserName->Length + sizeof(WCHAR));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
TRACE("SampSetObjectAttribute failed (Status 0x%08lx)\n", Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
if (OldUserName.Buffer != NULL)
|
||||||
|
midl_user_free(OldUserName.Buffer);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
SampSetUserGeneral(PSAM_DB_OBJECT UserObject,
|
SampSetUserGeneral(PSAM_DB_OBJECT UserObject,
|
||||||
PSAMPR_USER_INFO_BUFFER Buffer)
|
PSAMPR_USER_INFO_BUFFER Buffer)
|
||||||
|
@ -6778,11 +6843,8 @@ SampSetUserGeneral(PSAM_DB_OBJECT UserObject,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
Status = SampSetObjectAttribute(UserObject,
|
Status = SampSetUserName(UserObject,
|
||||||
L"Name",
|
&Buffer->General.UserName);
|
||||||
REG_SZ,
|
|
||||||
Buffer->General.UserName.Buffer,
|
|
||||||
Buffer->General.UserName.MaximumLength);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
@ -7011,11 +7073,8 @@ SampSetUserAll(PSAM_DB_OBJECT UserObject,
|
||||||
|
|
||||||
if (WhichFields & USER_ALL_USERNAME)
|
if (WhichFields & USER_ALL_USERNAME)
|
||||||
{
|
{
|
||||||
Status = SampSetObjectAttribute(UserObject,
|
Status = SampSetUserName(UserObject,
|
||||||
L"Name",
|
&Buffer->All.UserName);
|
||||||
REG_SZ,
|
|
||||||
Buffer->All.UserName.Buffer,
|
|
||||||
Buffer->All.UserName.MaximumLength);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -7265,11 +7324,8 @@ SamrSetInformationUser(IN SAMPR_HANDLE UserHandle,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UserNameInformation:
|
case UserNameInformation:
|
||||||
Status = SampSetObjectAttribute(UserObject,
|
Status = SampSetUserName(UserObject,
|
||||||
L"Name",
|
&Buffer->Name.UserName);
|
||||||
REG_SZ,
|
|
||||||
Buffer->Name.UserName.Buffer,
|
|
||||||
Buffer->Name.UserName.MaximumLength);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -7281,11 +7337,8 @@ SamrSetInformationUser(IN SAMPR_HANDLE UserHandle,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UserAccountNameInformation:
|
case UserAccountNameInformation:
|
||||||
Status = SampSetObjectAttribute(UserObject,
|
Status = SampSetUserName(UserObject,
|
||||||
L"Name",
|
&Buffer->AccountName.UserName);
|
||||||
REG_SZ,
|
|
||||||
Buffer->AccountName.UserName.Buffer,
|
|
||||||
Buffer->AccountName.UserName.MaximumLength);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UserFullNameInformation:
|
case UserFullNameInformation:
|
||||||
|
|
Loading…
Reference in a new issue