Author: ekohl Date: Tue Jan 29 23:24:37 2013 New Revision: 58252
URL: http://svn.reactos.org/svn/reactos?rev=58252&view=rev Log: [SAMSRV] Implement UserInternal1Information for SamrQueryInformationUser and SamrSetInformationUser.
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?r... ============================================================================== --- trunk/reactos/dll/win32/samsrv/samrpc.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/samsrv/samrpc.c [iso-8859-1] Tue Jan 29 23:24:37 2013 @@ -6044,6 +6044,59 @@
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 SampQueryUserParameters(PSAM_DB_OBJECT UserObject, PSAMPR_USER_INFO_BUFFER *Buffer) { @@ -6136,6 +6189,10 @@ USER_READ_ACCOUNT; break;
+ case UserInternal1Information: + DesiredAccess = 0; + break; + default: return STATUS_INVALID_INFO_CLASS; } @@ -6232,7 +6289,10 @@ Buffer); break;
-// case UserInternal1Information: + case UserInternal1Information: + Status = SampQueryUserInternal1(UserObject, + Buffer); + break;
case UserParametersInformation: Status = SampQueryUserParameters(UserObject, @@ -6434,6 +6494,96 @@ FixedData.AccountExpires.LowPart = Buffer->Expires.AccountExpires.LowPart; FixedData.AccountExpires.HighPart = Buffer->Expires.AccountExpires.HighPart;
+ Status = SampSetObjectAttribute(UserObject, + L"F", + REG_BINARY, + &FixedData, + Length); + +done: + return Status; +} + + +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, @@ -6662,6 +6812,7 @@ break;
case UserSetPasswordInformation: + case UserInternal1Information: DesiredAccess = USER_FORCE_PASSWORD_CHANGE; break;
@@ -6807,7 +6958,10 @@ Buffer); break;
-// case UserInternal1Information: + case UserInternal1Information: + Status = SampSetUserInternal1(UserObject, + Buffer); + break;
case UserParametersInformation: Status = SampSetObjectAttribute(UserObject,