From 2f75d2cf5a1eb651175e29011526fe319f3e417e Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Mon, 26 Sep 2016 16:28:10 +0000 Subject: [PATCH] [LSASRV] Store the domain name and user SID in the session too. svn path=/trunk/; revision=72814 --- reactos/dll/win32/lsasrv/authpackage.c | 23 +++++++++++++++++++++-- reactos/dll/win32/lsasrv/lsasrv.h | 4 +++- reactos/dll/win32/lsasrv/session.c | 21 ++++++++++++++++++++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/lsasrv/authpackage.c b/reactos/dll/win32/lsasrv/authpackage.c index 071b416c963..8b74f716f86 100644 --- a/reactos/dll/win32/lsasrv/authpackage.c +++ b/reactos/dll/win32/lsasrv/authpackage.c @@ -1380,7 +1380,12 @@ LsapLogonUser(PLSA_API_MSG RequestMsg, SECURITY_LOGON_TYPE LogonType; NTSTATUS Status; - TRACE("(%p %p)\n", RequestMsg, LogonContext); + PUNICODE_STRING UserName = NULL; + PUNICODE_STRING LogonDomainName = NULL; +// UNICODE_STRING LogonServer; + + + TRACE("LsapLogonUser(%p %p)\n", RequestMsg, LogonContext); PackageId = RequestMsg->LogonUser.Request.AuthenticationPackage; LogonType = RequestMsg->LogonUser.Request.LogonType; @@ -1606,9 +1611,23 @@ LsapLogonUser(PLSA_API_MSG RequestMsg, // TokenHandle = NULL; + if (LogonType == Interactive || + LogonType == Batch || + LogonType == Service) + { + UserName = &((PMSV1_0_INTERACTIVE_LOGON)LocalAuthInfo)->UserName; + LogonDomainName = &((PMSV1_0_INTERACTIVE_LOGON)LocalAuthInfo)->LogonDomainName; + } + else + { + FIXME("LogonType %lu is not supported yet!\n", LogonType); + } + Status = LsapSetLogonSessionData(&RequestMsg->LogonUser.Reply.LogonId, LogonType, - AccountName); + UserName, + LogonDomainName, + TokenInfo1->User.User.Sid); if (!NT_SUCCESS(Status)) { ERR("LsapSetLogonSessionData failed (Status 0x%08lx)\n", Status); diff --git a/reactos/dll/win32/lsasrv/lsasrv.h b/reactos/dll/win32/lsasrv/lsasrv.h index 584d1132ffa..06bd2f1277e 100644 --- a/reactos/dll/win32/lsasrv/lsasrv.h +++ b/reactos/dll/win32/lsasrv/lsasrv.h @@ -450,7 +450,9 @@ NTSTATUS LsapSetLogonSessionData( _In_ PLUID LogonId, _In_ ULONG LogonType, - _In_ PUNICODE_STRING UserName); + _In_ PUNICODE_STRING UserName, + _In_ PUNICODE_STRING LogonDomain, + _In_ PSID Sid); NTSTATUS LsapEnumLogonSessions(IN OUT PLSA_API_MSG RequestMsg); diff --git a/reactos/dll/win32/lsasrv/session.c b/reactos/dll/win32/lsasrv/session.c index def8fe7a113..a290e3428fa 100644 --- a/reactos/dll/win32/lsasrv/session.c +++ b/reactos/dll/win32/lsasrv/session.c @@ -67,9 +67,12 @@ NTSTATUS LsapSetLogonSessionData( _In_ PLUID LogonId, _In_ ULONG LogonType, - _In_ PUNICODE_STRING UserName) + _In_ PUNICODE_STRING UserName, + _In_ PUNICODE_STRING LogonDomain, + _In_ PSID Sid) { PLSAP_LOGON_SESSION Session; + ULONG Length; TRACE("LsapSetLogonSessionData(%p)\n", LogonId); @@ -89,6 +92,22 @@ LsapSetLogonSessionData( Session->UserName.MaximumLength = UserName->MaximumLength; RtlCopyMemory(Session->UserName.Buffer, UserName->Buffer, UserName->MaximumLength); + TRACE("LogonDomain %wZ\n", LogonDomain); + Session->LogonDomain.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, LogonDomain->MaximumLength); + if (Session->LogonDomain.Buffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + Session->LogonDomain.Length = LogonDomain->Length; + Session->LogonDomain.MaximumLength = LogonDomain->MaximumLength; + RtlCopyMemory(Session->LogonDomain.Buffer, LogonDomain->Buffer, LogonDomain->MaximumLength); + + Length = RtlLengthSid(Sid); + Session->Sid = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Length); + if (Session->UserName.Buffer == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + RtlCopyMemory(Session->Sid, Sid, Length); + return STATUS_SUCCESS; }