ReactOS 0.4.16-dev-122-g325d74c
session.c File Reference
#include "lsasrv.h"
Include dependency graph for session.c:

Go to the source code of this file.

Classes

struct  _LSAP_LOGON_SESSION
 

Typedefs

typedef struct _LSAP_LOGON_SESSION LSAP_LOGON_SESSION
 
typedef struct _LSAP_LOGON_SESSIONPLSAP_LOGON_SESSION
 

Functions

VOID LsapInitLogonSessions (VOID)
 
static PLSAP_LOGON_SESSION LsapGetLogonSession (IN PLUID LogonId)
 
NTSTATUS LsapSetLogonSessionData (_In_ PLUID LogonId, _In_ ULONG LogonType, _In_ PUNICODE_STRING UserName, _In_ PUNICODE_STRING LogonDomain, _In_ PSID Sid)
 
NTSTATUS NTAPI LsapCreateLogonSession (IN PLUID LogonId)
 
NTSTATUS NTAPI LsapDeleteLogonSession (IN PLUID LogonId)
 
NTSTATUS NTAPI LsapAddCredential (_In_ PLUID LogonId, _In_ ULONG AuthenticationPackage, _In_ PLSA_STRING PrimaryKeyValue, _In_ PLSA_STRING Credential)
 
NTSTATUS NTAPI LsapGetCredentials (_In_ PLUID LogonId, _In_ ULONG AuthenticationPackage, _Inout_ PULONG QueryContext, _In_ BOOLEAN RetrieveAllCredentials, _Inout_ PLSA_STRING PrimaryKeyValue, _Out_ PULONG PrimaryKeyLength, _Out_ PLSA_STRING Credentials)
 
NTSTATUS NTAPI LsapDeleteCredential (_In_ PLUID LogonId, _In_ ULONG AuthenticationPackage, _In_ PLSA_STRING PrimaryKeyValue)
 
NTSTATUS LsapEnumLogonSessions (IN OUT PLSA_API_MSG RequestMsg)
 
NTSTATUS LsapGetLogonSessionData (IN OUT PLSA_API_MSG RequestMsg)
 

Variables

LIST_ENTRY SessionListHead
 
ULONG SessionCount
 

Typedef Documentation

◆ LSAP_LOGON_SESSION

◆ PLSAP_LOGON_SESSION

Function Documentation

◆ LsapAddCredential()

NTSTATUS NTAPI LsapAddCredential ( _In_ PLUID  LogonId,
_In_ ULONG  AuthenticationPackage,
_In_ PLSA_STRING  PrimaryKeyValue,
_In_ PLSA_STRING  Credential 
)

Definition at line 259 of file session.c.

264{
265
266 return STATUS_SUCCESS;
267}
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by LsapInitAuthPackages().

◆ LsapCreateLogonSession()

NTSTATUS NTAPI LsapCreateLogonSession ( IN PLUID  LogonId)

Definition at line 159 of file session.c.

160{
161 PLSAP_LOGON_SESSION Session;
163
164 TRACE("LsapCreateLogonSession(%p)\n", LogonId);
165
166 /* Fail, if a session already exists */
169
170 /* Allocate a new session entry */
171 Session = RtlAllocateHeap(RtlGetProcessHeap(),
173 sizeof(LSAP_LOGON_SESSION));
174 if (Session == NULL)
176
177 /* Initialize the session entry */
178 RtlCopyLuid(&Session->LogonId, LogonId);
179
180 TRACE("LsapCreateLogonSession(<0x%lx,0x%lx>)\n",
181 LogonId->HighPart, LogonId->LowPart);
182
183 /* Tell ntoskrnl to create a new logon session */
185 if (!NT_SUCCESS(Status))
186 {
187 RtlFreeHeap(RtlGetProcessHeap(), 0, Session);
188 return Status;
189 }
190
191 /* Insert the new session into the session list */
193 SessionCount++;
194
195 return STATUS_SUCCESS;
196}
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
NTSTATUS LsapRmCreateLogonSession(PLUID LogonId)
Definition: srm.c:245
ULONG SessionCount
Definition: session.c:31
LIST_ENTRY SessionListHead
Definition: session.c:30
static PLSAP_LOGON_SESSION LsapGetLogonSession(IN PLUID LogonId)
Definition: session.c:45
#define InsertHeadList(ListHead, Entry)
Status
Definition: gdiplustypes.h:25
NTSYSAPI void WINAPI RtlCopyLuid(PLUID, const LUID *)
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE _In_ ULONG _In_ ULONG _In_opt_ PTOKEN_GROUPS _In_ PTOKEN_SOURCE _Out_ PVOID _Out_ PULONG _Inout_ PLUID LogonId
#define STATUS_LOGON_SESSION_COLLISION
Definition: ntstatus.h:497
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY Entry
Definition: session.c:13
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by LsapInitAuthPackages().

◆ LsapDeleteCredential()

NTSTATUS NTAPI LsapDeleteCredential ( _In_ PLUID  LogonId,
_In_ ULONG  AuthenticationPackage,
_In_ PLSA_STRING  PrimaryKeyValue 
)

Definition at line 288 of file session.c.

292{
293
294 return STATUS_SUCCESS;
295}

Referenced by LsapInitAuthPackages().

◆ LsapDeleteLogonSession()

NTSTATUS NTAPI LsapDeleteLogonSession ( IN PLUID  LogonId)

Definition at line 201 of file session.c.

202{
203 PLSAP_LOGON_SESSION Session;
205
206 TRACE("LsapDeleteLogonSession(%p)\n", LogonId);
207
208 /* Fail, if the session does not exist */
209 Session = LsapGetLogonSession(LogonId);
210 if (Session == NULL)
212
213 TRACE("LsapDeleteLogonSession(0x%08lx%08lx)\n",
214 LogonId->HighPart, LogonId->LowPart);
215
216 /* Tell ntoskrnl to delete the logon session */
218 if (!NT_SUCCESS(Status))
219 return Status;
220
221 /* Notify the authentication packages */
223
224 /* Remove the session entry from the list */
225 RemoveEntryList(&Session->Entry);
226 SessionCount--;
227
228 /* Free the session data */
229 if (Session->Sid != NULL)
230 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->Sid);
231
232 if (Session->UserName.Buffer != NULL)
233 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName.Buffer);
234
235 if (Session->LogonDomain.Buffer != NULL)
236 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->LogonDomain.Buffer);
237
238 if (Session->AuthenticationPackage.Buffer != NULL)
239 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->AuthenticationPackage.Buffer);
240
241 if (Session->LogonServer.Buffer != NULL)
242 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->LogonServer.Buffer);
243
244 if (Session->DnsDomainName.Buffer != NULL)
245 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->DnsDomainName.Buffer);
246
247 if (Session->Upn.Buffer != NULL)
248 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->Upn.Buffer);
249
250 /* Free the session entry */
251 RtlFreeHeap(RtlGetProcessHeap(), 0, Session);
252
253 return STATUS_SUCCESS;
254}
VOID LsapTerminateLogon(_In_ PLUID LogonId)
Definition: authpackage.c:545
NTSTATUS LsapRmDeleteLogonSession(PLUID LogonId)
Definition: srm.c:285
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define STATUS_NO_SUCH_LOGON_SESSION
Definition: ntstatus.h:331
UNICODE_STRING LogonServer
Definition: session.c:22
UNICODE_STRING DnsDomainName
Definition: session.c:23
UNICODE_STRING UserName
Definition: session.c:19
UNICODE_STRING LogonDomain
Definition: session.c:20
UNICODE_STRING AuthenticationPackage
Definition: session.c:21
UNICODE_STRING Upn
Definition: session.c:24

Referenced by LsapInitAuthPackages(), and LsapLogonUser().

◆ LsapEnumLogonSessions()

NTSTATUS LsapEnumLogonSessions ( IN OUT PLSA_API_MSG  RequestMsg)

Definition at line 299 of file session.c.

300{
303 PLIST_ENTRY SessionEntry;
304 PLSAP_LOGON_SESSION CurrentSession;
305 PLUID SessionList;
306 ULONG i, Length;
307 SIZE_T MemSize;
308 PVOID ClientBaseAddress = NULL;
310
311 TRACE("LsapEnumLogonSessions(%p)\n", RequestMsg);
312
313 Length = SessionCount * sizeof(LUID);
314 SessionList = RtlAllocateHeap(RtlGetProcessHeap(),
316 Length);
317 if (SessionList == NULL)
319
320 i = 0;
321 SessionEntry = SessionListHead.Flink;
322 while (SessionEntry != &SessionListHead)
323 {
324 CurrentSession = CONTAINING_RECORD(SessionEntry,
326 Entry);
327
328 RtlCopyLuid(&SessionList[i],
329 &CurrentSession->LogonId);
330
331 SessionEntry = SessionEntry->Flink;
332 i++;
333 }
334
336 NULL,
337 0,
338 NULL,
339 NULL);
340
344 &RequestMsg->h.ClientId);
345 if (!NT_SUCCESS(Status))
346 {
347 TRACE("NtOpenProcess() failed (Status %lx)\n", Status);
348 goto done;
349 }
350
351 TRACE("Length: %lu\n", Length);
352
353 MemSize = Length;
355 &ClientBaseAddress,
356 0,
357 &MemSize,
360 if (!NT_SUCCESS(Status))
361 {
362 TRACE("NtAllocateVirtualMemory() failed (Status %lx)\n", Status);
363 goto done;
364 }
365
366 TRACE("MemSize: %lu\n", MemSize);
367 TRACE("ClientBaseAddress: %p\n", ClientBaseAddress);
368
370 ClientBaseAddress,
371 SessionList,
372 Length,
373 NULL);
374 if (!NT_SUCCESS(Status))
375 {
376 TRACE("NtWriteVirtualMemory() failed (Status %lx)\n", Status);
377 goto done;
378 }
379
380 RequestMsg->EnumLogonSessions.Reply.LogonSessionCount = SessionCount;
381 RequestMsg->EnumLogonSessions.Reply.LogonSessionBuffer = ClientBaseAddress;
382
383done:
384 if (ProcessHandle != NULL)
386
387 if (SessionList != NULL)
388 RtlFreeHeap(RtlGetProcessHeap(), 0, SessionList);
389
390 return Status;
391}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
struct _LUID LUID
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PROCESS_VM_READ
Definition: pstypes.h:162
#define PROCESS_VM_WRITE
Definition: pstypes.h:163
#define PROCESS_VM_OPERATION
Definition: pstypes.h:161
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define PAGE_READWRITE
Definition: nt_native.h:1304
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define MEM_COMMIT
Definition: nt_native.h:1313
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI NtWriteVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, IN PVOID Buffer, IN SIZE_T NumberOfBytesToWrite, OUT PSIZE_T NumberOfBytesWritten OPTIONAL)
Definition: virtual.c:2930
NTSTATUS NTAPI NtAllocateVirtualMemory(IN HANDLE ProcessHandle, IN OUT PVOID *UBaseAddress, IN ULONG_PTR ZeroBits, IN OUT PSIZE_T URegionSize, IN ULONG AllocationType, IN ULONG Protect)
Definition: virtual.c:4492
NTSTATUS NTAPI NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId)
Definition: process.c:1440
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59

Referenced by AuthPortThreadRoutine().

◆ LsapGetCredentials()

NTSTATUS NTAPI LsapGetCredentials ( _In_ PLUID  LogonId,
_In_ ULONG  AuthenticationPackage,
_Inout_ PULONG  QueryContext,
_In_ BOOLEAN  RetrieveAllCredentials,
_Inout_ PLSA_STRING  PrimaryKeyValue,
_Out_ PULONG  PrimaryKeyLength,
_Out_ PLSA_STRING  Credentials 
)

Definition at line 272 of file session.c.

280{
281
282 return STATUS_SUCCESS;
283}

Referenced by LsapInitAuthPackages().

◆ LsapGetLogonSession()

static PLSAP_LOGON_SESSION LsapGetLogonSession ( IN PLUID  LogonId)
static

Definition at line 45 of file session.c.

46{
47 PLIST_ENTRY SessionEntry;
48 PLSAP_LOGON_SESSION CurrentSession;
49
50 SessionEntry = SessionListHead.Flink;
51 while (SessionEntry != &SessionListHead)
52 {
53 CurrentSession = CONTAINING_RECORD(SessionEntry,
55 Entry);
56 if (RtlEqualLuid(&CurrentSession->LogonId, LogonId))
57 return CurrentSession;
58
59 SessionEntry = SessionEntry->Flink;
60 }
61
62 return NULL;
63}
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301

Referenced by LsapCreateLogonSession(), LsapDeleteLogonSession(), LsapGetLogonSessionData(), and LsapSetLogonSessionData().

◆ LsapGetLogonSessionData()

NTSTATUS LsapGetLogonSessionData ( IN OUT PLSA_API_MSG  RequestMsg)

Definition at line 395 of file session.c.

396{
399 PLSAP_LOGON_SESSION Session;
400 PSECURITY_LOGON_SESSION_DATA LocalSessionData;
401 PVOID ClientBaseAddress = NULL;
402 ULONG TotalLength, SidLength = 0;
403 SIZE_T MemSize;
404 PUCHAR Ptr;
406
407 TRACE("LsapGetLogonSessionData(%p)\n", RequestMsg);
408
409 TRACE("LogonId: %lx\n", RequestMsg->GetLogonSessionData.Request.LogonId.LowPart);
410 Session = LsapGetLogonSession(&RequestMsg->GetLogonSessionData.Request.LogonId);
411 if (Session == NULL)
413
414 /* Calculate the required buffer size */
416 Session->UserName.MaximumLength +
417 Session->LogonDomain.MaximumLength +
419 Session->LogonServer.MaximumLength +
421 Session->Upn.MaximumLength;
422 if (Session->Sid != NULL)
423 {
424 SidLength = RtlLengthSid(Session->Sid);
425 TotalLength += SidLength;
426 }
427 TRACE("TotalLength: %lu\n", TotalLength);
428
429 /* Allocate the buffer */
430 LocalSessionData = RtlAllocateHeap(RtlGetProcessHeap(),
433 if (LocalSessionData == NULL)
435
436 Ptr = (PUCHAR)((ULONG_PTR)LocalSessionData + sizeof(SECURITY_LOGON_SESSION_DATA));
437 TRACE("LocalSessionData: %p Ptr: %p\n", LocalSessionData, Ptr);
438
439 LocalSessionData->Size = sizeof(SECURITY_LOGON_SESSION_DATA);
440
441 /* Copy the LogonId */
442 RtlCopyLuid(&LocalSessionData->LogonId,
443 &RequestMsg->GetLogonSessionData.Request.LogonId);
444
445 /* Copy the UserName string */
446 LocalSessionData->UserName.Length = Session->UserName.Length;
447 LocalSessionData->UserName.MaximumLength = Session->UserName.MaximumLength;
448 if (Session->UserName.MaximumLength != 0)
449 {
451 LocalSessionData->UserName.Buffer = (PWSTR)((ULONG_PTR)Ptr - (ULONG_PTR)LocalSessionData);
452
453 Ptr = (PUCHAR)((ULONG_PTR)Ptr + Session->UserName.MaximumLength);
454 }
455
456 /* Copy the LogonDomain string */
457 LocalSessionData->LogonDomain.Length = Session->LogonDomain.Length;
458 LocalSessionData->LogonDomain.MaximumLength = Session->LogonDomain.MaximumLength;
459 if (Session->LogonDomain.MaximumLength != 0)
460 {
462 LocalSessionData->LogonDomain.Buffer = (PWSTR)((ULONG_PTR)Ptr - (ULONG_PTR)LocalSessionData);
463
465 }
466
467 /* Copy the AuthenticationPackage string */
468 LocalSessionData->AuthenticationPackage.Length = Session->AuthenticationPackage.Length;
469 LocalSessionData->AuthenticationPackage.MaximumLength = Session->AuthenticationPackage.MaximumLength;
470 if (Session->AuthenticationPackage.MaximumLength != 0)
471 {
473 LocalSessionData->AuthenticationPackage.Buffer = (PWSTR)((ULONG_PTR)Ptr - (ULONG_PTR)LocalSessionData);
474
476 }
477
478 LocalSessionData->LogonType = Session->LogonType;
479 LocalSessionData->Session = 0;
480
481 /* Sid */
482 if (Session->Sid != NULL)
483 {
484 RtlCopyMemory(Ptr, Session->Sid, SidLength);
485 LocalSessionData->Sid = (PSID)((ULONG_PTR)Ptr - (ULONG_PTR)LocalSessionData);
486
487 Ptr = (PUCHAR)((ULONG_PTR)Ptr + SidLength);
488 }
489
490 /* LogonTime */
491 LocalSessionData->LogonTime.QuadPart = Session->LogonTime.QuadPart;
492
493 /* Copy the LogonServer string */
494 LocalSessionData->LogonServer.Length = Session->LogonServer.Length;
495 LocalSessionData->LogonServer.MaximumLength = Session->LogonServer.MaximumLength;
496 if (Session->LogonServer.MaximumLength != 0)
497 {
499 LocalSessionData->LogonServer.Buffer = (PWSTR)((ULONG_PTR)Ptr - (ULONG_PTR)LocalSessionData);
500
502 }
503
504 /* Copy the DnsDomainName string */
505 LocalSessionData->DnsDomainName.Length = Session->DnsDomainName.Length;
506 LocalSessionData->DnsDomainName.MaximumLength = Session->DnsDomainName.MaximumLength;
507 if (Session->DnsDomainName.MaximumLength != 0)
508 {
510 LocalSessionData->DnsDomainName.Buffer = (PWSTR)((ULONG_PTR)Ptr - (ULONG_PTR)LocalSessionData);
511
513 }
514
515 /* Copy the Upn string */
516 LocalSessionData->Upn.Length = Session->Upn.Length;
517 LocalSessionData->Upn.MaximumLength = Session->Upn.MaximumLength;
518 if (Session->Upn.MaximumLength != 0)
519 {
520 RtlCopyMemory(Ptr, Session->Upn.Buffer, Session->Upn.MaximumLength);
521 LocalSessionData->Upn.Buffer = (PWSTR)((ULONG_PTR)Ptr - (ULONG_PTR)LocalSessionData);
522
523 Ptr = (PUCHAR)((ULONG_PTR)Ptr + Session->Upn.MaximumLength);
524 }
525
527 NULL,
528 0,
529 NULL,
530 NULL);
531
535 &RequestMsg->h.ClientId);
536 if (!NT_SUCCESS(Status))
537 {
538 TRACE("NtOpenProcess() failed (Status %lx)\n", Status);
539 goto done;
540 }
541
542 MemSize = TotalLength;
544 &ClientBaseAddress,
545 0,
546 &MemSize,
549 if (!NT_SUCCESS(Status))
550 {
551 TRACE("NtAllocateVirtualMemory() failed (Status %lx)\n", Status);
552 goto done;
553 }
554
555 TRACE("MemSize: %lu\n", MemSize);
556 TRACE("ClientBaseAddress: %p\n", ClientBaseAddress);
557
559 ClientBaseAddress,
560 LocalSessionData,
562 NULL);
563 if (!NT_SUCCESS(Status))
564 {
565 TRACE("NtWriteVirtualMemory() failed (Status %lx)\n", Status);
566 goto done;
567 }
568
569 RequestMsg->GetLogonSessionData.Reply.SessionDataBuffer = ClientBaseAddress;
570
571done:
572 if (ProcessHandle != NULL)
574
575 if (LocalSessionData != NULL)
576 RtlFreeHeap(RtlGetProcessHeap(), 0, LocalSessionData);
577
578 return Status;
579}
#define ULONG_PTR
Definition: config.h:101
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
if(dx< 0)
Definition: linetemp.h:194
struct _SID * PSID
Definition: eventlog.c:35
NTSYSAPI ULONG NTAPI RtlLengthSid(IN PSID Sid)
Definition: sid.c:150
struct _SECURITY_LOGON_SESSION_DATA SECURITY_LOGON_SESSION_DATA
LARGE_INTEGER LogonTime
Definition: session.c:17
USHORT MaximumLength
Definition: ntsecapi.h:164
LSA_UNICODE_STRING UserName
Definition: ntsecapi.h:306
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:56
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ ULONG TotalLength
Definition: usbdlib.h:158

Referenced by AuthPortThreadRoutine().

◆ LsapInitLogonSessions()

VOID LsapInitLogonSessions ( VOID  )

Definition at line 36 of file session.c.

37{
39 SessionCount = 0;
40}
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944

Referenced by LsapInitLsa().

◆ LsapSetLogonSessionData()

NTSTATUS LsapSetLogonSessionData ( _In_ PLUID  LogonId,
_In_ ULONG  LogonType,
_In_ PUNICODE_STRING  UserName,
_In_ PUNICODE_STRING  LogonDomain,
_In_ PSID  Sid 
)

Definition at line 67 of file session.c.

73{
75 PLSAP_LOGON_SESSION Session;
77
78 TRACE("LsapSetLogonSessionData(%p)\n", LogonId);
79
81 if (Session == NULL)
83
84 TRACE("LogonType %lu\n", LogonType);
85 Session->LogonType = LogonType;
86
87 Status = RtlValidateUnicodeString(0, UserName);
88 if (!NT_SUCCESS(Status))
90
91 /* UserName is mandatory and cannot be an empty string */
92 TRACE("UserName %wZ\n", UserName);
93 Session->UserName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
95 UserName->MaximumLength);
96 if (Session->UserName.Buffer == NULL)
98
99 Session->UserName.Length = UserName->Length;
100 Session->UserName.MaximumLength = UserName->MaximumLength;
101 RtlCopyMemory(Session->UserName.Buffer, UserName->Buffer, UserName->MaximumLength);
102
103 Status = RtlValidateUnicodeString(0, LogonDomain);
104 if (!NT_SUCCESS(Status))
105 {
106 /* Cleanup and fail */
107 if (Session->UserName.Buffer != NULL)
108 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName.Buffer);
109
111 }
112
113 /* LogonDomain is optional and can be an empty string */
114 TRACE("LogonDomain %wZ\n", LogonDomain);
115 if (LogonDomain->Length)
116 {
117 Session->LogonDomain.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
119 LogonDomain->MaximumLength);
120 if (Session->LogonDomain.Buffer == NULL)
121 {
122 /* Cleanup and fail */
123 if (Session->UserName.Buffer != NULL)
124 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName.Buffer);
125
127 }
128
129 Session->LogonDomain.Length = LogonDomain->Length;
130 Session->LogonDomain.MaximumLength = LogonDomain->MaximumLength;
131 RtlCopyMemory(Session->LogonDomain.Buffer, LogonDomain->Buffer, LogonDomain->MaximumLength);
132 }
133 else
134 {
135 RtlInitEmptyUnicodeString(&Session->LogonDomain, NULL, 0);
136 }
137
139 Session->Sid = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Length);
140 if (Session->Sid == NULL)
141 {
142 /* Cleanup and fail */
143 if (Session->LogonDomain.Buffer != NULL)
144 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->LogonDomain.Buffer);
145 if (Session->UserName.Buffer != NULL)
146 RtlFreeHeap(RtlGetProcessHeap(), 0, Session->UserName.Buffer);
147
149 }
150
151 RtlCopyMemory(Session->Sid, Sid, Length);
152
153 return STATUS_SUCCESS;
154}
NTSYSAPI NTSTATUS NTAPI RtlValidateUnicodeString(_In_ ULONG Flags, _In_ PCUNICODE_STRING String)
Definition: unicode.c:2605
_In_ ULONG _In_ ACCESS_MASK _In_ PSID Sid
Definition: rtlfuncs.h:1145
_IRQL_requires_same_ _In_ PLSA_STRING _In_ SECURITY_LOGON_TYPE LogonType
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by LsapLogonUser().

Variable Documentation

◆ SessionCount

◆ SessionListHead