Implement UserInternal1Information for SamrQueryInformationUser and SamrSetInformationUser.

svn path=/trunk/; revision=58252
This commit is contained in:
Eric Kohl 2013-01-29 23:24:37 +00:00
parent 1edcc31339
commit 3cdac21fae

View file

@ -6043,6 +6043,59 @@ done:
} }
static NTSTATUS
SampQueryUserInternal1(PSAM_DB_OBJECT UserObject,
PSAMPR_USER_INFO_BUFFER *Buffer)
{
PSAMPR_USER_INFO_BUFFER InfoBuffer = NULL;
ULONG Length = 0;
NTSTATUS Status;
*Buffer = NULL;
InfoBuffer = midl_user_allocate(sizeof(SAMPR_USER_INFO_BUFFER));
if (InfoBuffer == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
/* Get the NT password */
Length = sizeof(ENCRYPTED_NT_OWF_PASSWORD);
Status = SampGetObjectAttribute(UserObject,
L"NTPwd",
NULL,
(PVOID)&InfoBuffer->Internal1.EncryptedNtOwfPassword,
&Length);
if (!NT_SUCCESS(Status))
goto done;
InfoBuffer->Internal1.NtPasswordPresent = (Length == sizeof(ENCRYPTED_NT_OWF_PASSWORD));
/* Get the LM password */
Length = sizeof(ENCRYPTED_LM_OWF_PASSWORD);
Status = SampGetObjectAttribute(UserObject,
L"LMPwd",
NULL,
(PVOID)&InfoBuffer->Internal1.EncryptedLmOwfPassword,
&Length);
if (!NT_SUCCESS(Status))
goto done;
InfoBuffer->Internal1.LmPasswordPresent = (Length == sizeof(ENCRYPTED_LM_OWF_PASSWORD));
InfoBuffer->Internal1.PasswordExpired = FALSE;
done:
if (!NT_SUCCESS(Status))
{
if (InfoBuffer != NULL)
{
midl_user_free(InfoBuffer);
}
}
return Status;
}
static NTSTATUS static NTSTATUS
SampQueryUserParameters(PSAM_DB_OBJECT UserObject, SampQueryUserParameters(PSAM_DB_OBJECT UserObject,
PSAMPR_USER_INFO_BUFFER *Buffer) PSAMPR_USER_INFO_BUFFER *Buffer)
@ -6136,6 +6189,10 @@ SamrQueryInformationUser(IN SAMPR_HANDLE UserHandle,
USER_READ_ACCOUNT; USER_READ_ACCOUNT;
break; break;
case UserInternal1Information:
DesiredAccess = 0;
break;
default: default:
return STATUS_INVALID_INFO_CLASS; return STATUS_INVALID_INFO_CLASS;
} }
@ -6232,7 +6289,10 @@ SamrQueryInformationUser(IN SAMPR_HANDLE UserHandle,
Buffer); Buffer);
break; break;
// case UserInternal1Information: case UserInternal1Information:
Status = SampQueryUserInternal1(UserObject,
Buffer);
break;
case UserParametersInformation: case UserParametersInformation:
Status = SampQueryUserParameters(UserObject, Status = SampQueryUserParameters(UserObject,
@ -6445,6 +6505,96 @@ done:
} }
static NTSTATUS
SampSetUserInternal1(PSAM_DB_OBJECT UserObject,
PSAMPR_USER_INFO_BUFFER Buffer)
{
SAM_USER_FIXED_DATA FixedData;
ULONG Length = 0;
NTSTATUS Status = STATUS_SUCCESS;
if (Buffer->Internal1.NtPasswordPresent)
{
/* FIXME: Decrypt NT password */
Status = SampSetObjectAttribute(UserObject,
L"NTPwd",
REG_BINARY,
&Buffer->Internal1.EncryptedNtOwfPassword,
sizeof(ENCRYPTED_NT_OWF_PASSWORD));
if (!NT_SUCCESS(Status))
goto done;
}
else
{
Status = SampSetObjectAttribute(UserObject,
L"NTPwd",
REG_BINARY,
NULL,
0);
if (!NT_SUCCESS(Status))
goto done;
}
if (Buffer->Internal1.LmPasswordPresent)
{
/* FIXME: Decrypt LM password */
Status = SampSetObjectAttribute(UserObject,
L"LMPwd",
REG_BINARY,
&Buffer->Internal1.EncryptedLmOwfPassword,
sizeof(ENCRYPTED_LM_OWF_PASSWORD));
if (!NT_SUCCESS(Status))
goto done;
}
else
{
Status = SampSetObjectAttribute(UserObject,
L"LMPwd",
REG_BINARY,
NULL,
0);
if (!NT_SUCCESS(Status))
goto done;
}
/* Get the fixed user attributes */
Length = sizeof(SAM_USER_FIXED_DATA);
Status = SampGetObjectAttribute(UserObject,
L"F",
NULL,
(PVOID)&FixedData,
&Length);
if (!NT_SUCCESS(Status))
goto done;
if (Buffer->Internal1.PasswordExpired)
{
/* The pasword was last set ages ago */
FixedData.PasswordLastSet.LowPart = 0;
FixedData.PasswordLastSet.HighPart = 0;
}
else
{
/* The pasword was last set right now */
Status = NtQuerySystemTime(&FixedData.PasswordLastSet);
if (!NT_SUCCESS(Status))
goto done;
}
/* Set the fixed user attributes */
Status = SampSetObjectAttribute(UserObject,
L"F",
REG_BINARY,
&FixedData,
Length);
done:
return Status;
}
static NTSTATUS static NTSTATUS
SampSetUserAll(PSAM_DB_OBJECT UserObject, SampSetUserAll(PSAM_DB_OBJECT UserObject,
PSAMPR_USER_INFO_BUFFER Buffer) PSAMPR_USER_INFO_BUFFER Buffer)
@ -6662,6 +6812,7 @@ SamrSetInformationUser(IN SAMPR_HANDLE UserHandle,
break; break;
case UserSetPasswordInformation: case UserSetPasswordInformation:
case UserInternal1Information:
DesiredAccess = USER_FORCE_PASSWORD_CHANGE; DesiredAccess = USER_FORCE_PASSWORD_CHANGE;
break; break;
@ -6807,7 +6958,10 @@ SamrSetInformationUser(IN SAMPR_HANDLE UserHandle,
Buffer); Buffer);
break; break;
// case UserInternal1Information: case UserInternal1Information:
Status = SampSetUserInternal1(UserObject,
Buffer);
break;
case UserParametersInformation: case UserParametersInformation:
Status = SampSetObjectAttribute(UserObject, Status = SampSetObjectAttribute(UserObject,