[SECURE32]
[reactos.git] / reactos / dll / win32 / secur32 / lsalpc.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/secur32/lsalpc.c
5 * PURPOSE: LSA LPC port functions
6 */
7
8 /* INCLUDES ******************************************************************/
9
10 #include "precomp.h"
11
12 #include <ndk/lpctypes.h>
13 #include <ndk/lpcfuncs.h>
14 #include <ndk/mmfuncs.h>
15 #include <ndk/rtlfuncs.h>
16 #include <ndk/obfuncs.h>
17 #include <psdk/ntsecapi.h>
18 #include <lsass/lsass.h>
19
20 #include <wine/debug.h>
21 WINE_DEFAULT_DEBUG_CHANNEL(secur32);
22
23
24 /* GLOBALS *******************************************************************/
25
26 HANDLE LsaPortHandle;
27
28 extern HANDLE Secur32Heap;
29
30
31 /* FUNCTIONS *****************************************************************/
32
33 VOID
34 LsapInitLsaPort(VOID)
35 {
36 LsaPortHandle = NULL;
37 }
38
39
40 VOID
41 LsapCloseLsaPort(VOID)
42 {
43 if (LsaPortHandle != NULL)
44 {
45 NtClose(LsaPortHandle);
46 LsaPortHandle = NULL;
47 }
48 }
49
50
51 NTSTATUS
52 LsapOpenLsaPort(VOID)
53 {
54 UNICODE_STRING PortName;
55 SECURITY_QUALITY_OF_SERVICE SecurityQos;
56 LSA_CONNECTION_INFO ConnectInfo;
57 ULONG ConnectInfoLength;
58 NTSTATUS Status;
59
60 TRACE("LsapOpenLsaPort()\n");
61
62 if (LsaPortHandle != NULL)
63 return STATUS_SUCCESS;
64
65 RtlInitUnicodeString(&PortName,
66 L"\\LsaAuthenticationPort");
67
68 SecurityQos.Length = sizeof(SecurityQos);
69 SecurityQos.ImpersonationLevel = SecurityIdentification;
70 SecurityQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
71 SecurityQos.EffectiveOnly = TRUE;
72
73 RtlZeroMemory(&ConnectInfo,
74 sizeof(ConnectInfo));
75
76 ConnectInfo.CreateContext = FALSE;
77
78 ConnectInfoLength = sizeof(LSA_CONNECTION_INFO);
79 Status = NtConnectPort(&LsaPortHandle,
80 &PortName,
81 &SecurityQos,
82 NULL,
83 NULL,
84 NULL,
85 &ConnectInfo,
86 &ConnectInfoLength);
87 if (!NT_SUCCESS(Status))
88 {
89 TRACE("NtConnectPort failed (Status 0x%08lx)\n", Status);
90 }
91
92 return Status;
93 /*
94 if (!NT_SUCCESS(ConnectInfo.Status))
95 {
96 DPRINT1("ConnectInfo.Status: 0x%08lx\n", ConnectInfo.Status);
97 }
98
99 return ConnectInfo.Status;
100 */
101 }
102
103
104 /* PUBLIC FUNCTIONS **********************************************************/
105
106 /*
107 * @implemented
108 */
109 NTSTATUS
110 NTAPI
111 LsaEnumerateLogonSessions(PULONG LogonSessionCount,
112 PLUID *LogonSessionList)
113 {
114 LSA_API_MSG ApiMessage;
115 NTSTATUS Status;
116
117 TRACE("LsaEnumerateLogonSessions(%p %p)\n", LogonSessionCount, LogonSessionList);
118
119 Status = LsapOpenLsaPort();
120 if (!NT_SUCCESS(Status))
121 return Status;
122
123 ApiMessage.ApiNumber = LSASS_REQUEST_ENUM_LOGON_SESSIONS;
124 ApiMessage.h.u1.s1.DataLength = LSA_PORT_DATA_SIZE(ApiMessage.EnumLogonSessions);
125 ApiMessage.h.u1.s1.TotalLength = LSA_PORT_MESSAGE_SIZE;
126 ApiMessage.h.u2.ZeroInit = 0;
127
128 Status = NtRequestWaitReplyPort(LsaPortHandle,
129 (PPORT_MESSAGE)&ApiMessage,
130 (PPORT_MESSAGE)&ApiMessage);
131 if (!NT_SUCCESS(Status))
132 {
133 ERR("NtRequestWaitReplyPort() failed (Status 0x%08lx)\n", Status);
134 return Status;
135 }
136
137 if (!NT_SUCCESS(ApiMessage.Status))
138 {
139 ERR("NtRequestWaitReplyPort() failed (ApiMessage.Status 0x%08lx)\n", ApiMessage.Status);
140 return ApiMessage.Status;
141 }
142
143 *LogonSessionCount = ApiMessage.EnumLogonSessions.Reply.LogonSessionCount;
144 *LogonSessionList = ApiMessage.EnumLogonSessions.Reply.LogonSessionBuffer;
145
146 return Status;
147 }
148
149
150 /*
151 * @unimplemented
152 */
153 NTSTATUS
154 NTAPI
155 LsaGetLogonSessionData(PLUID LogonId,
156 PSECURITY_LOGON_SESSION_DATA *ppLogonSessionData)
157 {
158 UNIMPLEMENTED;
159 return STATUS_NOT_IMPLEMENTED;
160 }
161
162
163 /*
164 * @unimplemented
165 */
166 NTSTATUS
167 NTAPI
168 LsaRegisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
169 HANDLE NotificationEventHandle)
170 {
171 UNIMPLEMENTED;
172 return STATUS_NOT_IMPLEMENTED;
173 }
174
175
176 /*
177 * @unimplemented
178 */
179 NTSTATUS
180 NTAPI
181 LsaUnregisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
182 HANDLE NotificationEventHandle)
183 {
184 UNIMPLEMENTED;
185 return STATUS_NOT_IMPLEMENTED;
186 }
187
188 /* EOF */