2 * PROJECT: Local Security Authority Server DLL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/lsasrv/session.c
5 * PURPOSE: Logon session management routines
6 * COPYRIGHT: Copyright 2013 Eric Kohl
9 /* INCLUDES ****************************************************************/
13 WINE_DEFAULT_DEBUG_CHANNEL(lsasrv
);
15 typedef struct _LSAP_LOGON_SESSION
19 } LSAP_LOGON_SESSION
, *PLSAP_LOGON_SESSION
;
22 /* GLOBALS *****************************************************************/
24 LIST_ENTRY SessionListHead
;
27 /* FUNCTIONS ***************************************************************/
30 LsapInitLogonSessions(VOID
)
32 InitializeListHead(&SessionListHead
);
39 LsapGetLogonSession(IN PLUID LogonId
)
41 PLIST_ENTRY SessionEntry
;
42 PLSAP_LOGON_SESSION CurrentSession
;
44 SessionEntry
= SessionListHead
.Flink
;
45 while (SessionEntry
!= &SessionListHead
)
47 CurrentSession
= CONTAINING_RECORD(SessionEntry
,
50 if (RtlEqualLuid(&CurrentSession
->LogonId
, LogonId
))
51 return CurrentSession
;
53 SessionEntry
= SessionEntry
->Flink
;
62 LsapCreateLogonSession(IN PLUID LogonId
)
64 PLSAP_LOGON_SESSION Session
;
68 /* Fail, if a session already exists */
69 if (LsapGetLogonSession(LogonId
) != NULL
)
70 return STATUS_LOGON_SESSION_COLLISION
;
72 /* Allocate a new session entry */
73 Session
= RtlAllocateHeap(RtlGetProcessHeap(),
75 sizeof(LSAP_LOGON_SESSION
));
77 return STATUS_INSUFFICIENT_RESOURCES
;
79 /* Initialize the session entry */
80 RtlCopyLuid(&Session
->LogonId
, LogonId
);
82 /* Insert the new session into the session list */
83 InsertTailList(&SessionListHead
, &Session
->Entry
);
86 return STATUS_SUCCESS
;
92 LsapDeleteLogonSession(IN PLUID LogonId
)
94 PLSAP_LOGON_SESSION Session
;
98 /* Fail, if the session does not exist */
99 Session
= LsapGetLogonSession(LogonId
);
101 return STATUS_NO_SUCH_LOGON_SESSION
;
103 /* Remove the session entry from the list */
104 RemoveEntryList(&Session
->Entry
);
107 /* Free the session entry */
108 RtlFreeHeap(RtlGetProcessHeap(), 0, Session
);
110 return STATUS_SUCCESS
;