2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/lsalib/lsa.c
5 * PURPOSE: Client-side LSA functions
10 /* INCLUDES ******************************************************************/
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>
23 /* GLOBALS *******************************************************************/
25 extern HANDLE Secur32Heap
;
27 /* FUNCTIONS *****************************************************************/
34 LsaDeregisterLogonProcess(HANDLE LsaHandle
)
36 LSA_API_MSG ApiMessage
;
39 DPRINT1("LsaDeregisterLogonProcess()\n");
41 ApiMessage
.ApiNumber
= LSASS_REQUEST_DEREGISTER_LOGON_PROCESS
;
42 ApiMessage
.h
.u1
.s1
.DataLength
= LSA_PORT_DATA_SIZE(ApiMessage
.DeregisterLogonProcess
);
43 ApiMessage
.h
.u1
.s1
.TotalLength
= LSA_PORT_MESSAGE_SIZE
;
44 ApiMessage
.h
.u2
.ZeroInit
= 0;
46 Status
= ZwRequestWaitReplyPort(LsaHandle
,
47 (PPORT_MESSAGE
)&ApiMessage
,
48 (PPORT_MESSAGE
)&ApiMessage
);
49 if (!NT_SUCCESS(Status
))
51 DPRINT1("ZwRequestWaitReplyPort() failed (Status 0x%08lx)\n", Status
);
55 if (!NT_SUCCESS(ApiMessage
.Status
))
57 DPRINT1("ZwRequestWaitReplyPort() failed (ApiMessage.Status 0x%08lx)\n", ApiMessage
.Status
);
58 return ApiMessage
.Status
;
63 DPRINT1("LsaDeregisterLogonProcess() done (Status 0x%08lx)\n", Status
);
74 LsaConnectUntrusted(PHANDLE LsaHandle
)
76 UNICODE_STRING PortName
; // = RTL_CONSTANT_STRING(L"\\LsaAuthenticationPort");
77 SECURITY_QUALITY_OF_SERVICE SecurityQos
;
78 LSA_CONNECTION_INFO ConnectInfo
;
79 ULONG ConnectInfoLength
= sizeof(ConnectInfo
);
82 DPRINT1("LsaConnectUntrusted(%p)\n", LsaHandle
);
84 RtlInitUnicodeString(&PortName
,
85 L
"\\LsaAuthenticationPort");
87 SecurityQos
.Length
= sizeof(SecurityQos
);
88 SecurityQos
.ImpersonationLevel
= SecurityIdentification
;
89 SecurityQos
.ContextTrackingMode
= SECURITY_DYNAMIC_TRACKING
;
90 SecurityQos
.EffectiveOnly
= TRUE
;
92 RtlZeroMemory(&ConnectInfo
,
95 Status
= ZwConnectPort(LsaHandle
,
103 if (!NT_SUCCESS(Status
))
105 DPRINT1("ZwConnectPort failed (Status 0x%08lx)\n", Status
);
109 if (!NT_SUCCESS(ConnectInfo
.Status
))
111 DPRINT1("ConnectInfo.Status: 0x%08lx\n", ConnectInfo
.Status
);
114 return ConnectInfo
.Status
;
123 LsaCallAuthenticationPackage(HANDLE LsaHandle
,
124 ULONG AuthenticationPackage
,
125 PVOID ProtocolSubmitBuffer
,
126 ULONG SubmitBufferLength
,
127 PVOID
*ProtocolReturnBuffer
,
128 PULONG ReturnBufferLength
,
129 PNTSTATUS ProtocolStatus
)
131 LSA_API_MSG ApiMessage
;
134 DPRINT1("LsaCallAuthenticationPackage()\n");
136 ApiMessage
.ApiNumber
= LSASS_REQUEST_CALL_AUTHENTICATION_PACKAGE
;
137 ApiMessage
.h
.u1
.s1
.DataLength
= LSA_PORT_DATA_SIZE(ApiMessage
.CallAuthenticationPackage
);
138 ApiMessage
.h
.u1
.s1
.TotalLength
= LSA_PORT_MESSAGE_SIZE
;
139 ApiMessage
.h
.u2
.ZeroInit
= 0;
141 ApiMessage
.CallAuthenticationPackage
.Request
.AuthenticationPackage
= AuthenticationPackage
;
142 ApiMessage
.CallAuthenticationPackage
.Request
.ProtocolSubmitBuffer
= ProtocolSubmitBuffer
;
143 ApiMessage
.CallAuthenticationPackage
.Request
.SubmitBufferLength
= SubmitBufferLength
;
145 Status
= ZwRequestWaitReplyPort(LsaHandle
,
146 (PPORT_MESSAGE
)&ApiMessage
,
147 (PPORT_MESSAGE
)&ApiMessage
);
148 if (!NT_SUCCESS(Status
))
150 DPRINT1("ZwRequestWaitReplyPort() failed (Status 0x%08lx)\n", Status
);
154 if (!NT_SUCCESS(ApiMessage
.Status
))
156 DPRINT1("ZwRequestWaitReplyPort() failed (ApiMessage.Status 0x%08lx)\n", ApiMessage
.Status
);
157 return ApiMessage
.Status
;
160 *ProtocolReturnBuffer
= ApiMessage
.CallAuthenticationPackage
.Reply
.ProtocolReturnBuffer
;
161 *ReturnBufferLength
= ApiMessage
.CallAuthenticationPackage
.Reply
.ReturnBufferLength
;
162 *ProtocolStatus
= ApiMessage
.CallAuthenticationPackage
.Reply
.ProtocolStatus
;
173 LsaFreeReturnBuffer(PVOID Buffer
)
177 return ZwFreeVirtualMemory(NtCurrentProcess(),
189 LsaLookupAuthenticationPackage(HANDLE LsaHandle
,
190 PLSA_STRING PackageName
,
191 PULONG AuthenticationPackage
)
193 LSA_API_MSG ApiMessage
;
196 /* Check the package name length */
197 if (PackageName
->Length
> LSASS_MAX_PACKAGE_NAME_LENGTH
)
199 return STATUS_NAME_TOO_LONG
;
202 ApiMessage
.ApiNumber
= LSASS_REQUEST_LOOKUP_AUTHENTICATION_PACKAGE
;
203 ApiMessage
.h
.u1
.s1
.DataLength
= LSA_PORT_DATA_SIZE(ApiMessage
.LookupAuthenticationPackage
);
204 ApiMessage
.h
.u1
.s1
.TotalLength
= LSA_PORT_MESSAGE_SIZE
;
205 ApiMessage
.h
.u2
.ZeroInit
= 0;
207 ApiMessage
.LookupAuthenticationPackage
.Request
.PackageNameLength
= PackageName
->Length
;
208 strncpy(ApiMessage
.LookupAuthenticationPackage
.Request
.PackageName
,
210 ApiMessage
.LookupAuthenticationPackage
.Request
.PackageNameLength
);
211 ApiMessage
.LookupAuthenticationPackage
.Request
.PackageName
[ApiMessage
.LookupAuthenticationPackage
.Request
.PackageNameLength
] = '\0';
213 Status
= ZwRequestWaitReplyPort(LsaHandle
,
214 (PPORT_MESSAGE
)&ApiMessage
,
215 (PPORT_MESSAGE
)&ApiMessage
);
216 if (!NT_SUCCESS(Status
))
221 if (!NT_SUCCESS(ApiMessage
.Status
))
223 return ApiMessage
.Status
;
226 *AuthenticationPackage
= ApiMessage
.LookupAuthenticationPackage
.Reply
.Package
;
237 LsaLogonUser(HANDLE LsaHandle
,
238 PLSA_STRING OriginName
,
239 SECURITY_LOGON_TYPE LogonType
,
240 ULONG AuthenticationPackage
,
241 PVOID AuthenticationInformation
,
242 ULONG AuthenticationInformationLength
,
243 PTOKEN_GROUPS LocalGroups
,
244 PTOKEN_SOURCE SourceContext
,
245 PVOID
*ProfileBuffer
,
246 PULONG ProfileBufferLength
,
249 PQUOTA_LIMITS Quotas
,
252 LSA_API_MSG ApiMessage
;
255 ApiMessage
.ApiNumber
= LSASS_REQUEST_LOGON_USER
;
256 ApiMessage
.h
.u1
.s1
.DataLength
= LSA_PORT_DATA_SIZE(ApiMessage
.LogonUser
);
257 ApiMessage
.h
.u1
.s1
.TotalLength
= LSA_PORT_MESSAGE_SIZE
;
258 ApiMessage
.h
.u2
.ZeroInit
= 0;
260 ApiMessage
.LogonUser
.Request
.OriginName
= *OriginName
;
261 ApiMessage
.LogonUser
.Request
.LogonType
= LogonType
;
262 ApiMessage
.LogonUser
.Request
.AuthenticationPackage
= AuthenticationPackage
;
263 ApiMessage
.LogonUser
.Request
.AuthenticationInformation
= AuthenticationInformation
;
264 ApiMessage
.LogonUser
.Request
.AuthenticationInformationLength
= AuthenticationInformationLength
;
265 ApiMessage
.LogonUser
.Request
.LocalGroups
= LocalGroups
;
266 if (LocalGroups
!= NULL
)
267 ApiMessage
.LogonUser
.Request
.LocalGroupsCount
= LocalGroups
->GroupCount
;
269 ApiMessage
.LogonUser
.Request
.LocalGroupsCount
= 0;
270 ApiMessage
.LogonUser
.Request
.SourceContext
= *SourceContext
;
272 Status
= ZwRequestWaitReplyPort(LsaHandle
,
273 (PPORT_MESSAGE
)&ApiMessage
,
274 (PPORT_MESSAGE
)&ApiMessage
);
275 if (!NT_SUCCESS(Status
))
280 *SubStatus
= ApiMessage
.LogonUser
.Reply
.SubStatus
;
282 if (!NT_SUCCESS(ApiMessage
.Status
))
284 return ApiMessage
.Status
;
287 *ProfileBuffer
= ApiMessage
.LogonUser
.Reply
.ProfileBuffer
;
288 *ProfileBufferLength
= ApiMessage
.LogonUser
.Reply
.ProfileBufferLength
;
289 *LogonId
= ApiMessage
.LogonUser
.Reply
.LogonId
;
290 *Token
= ApiMessage
.LogonUser
.Reply
.Token
;
291 *Quotas
= ApiMessage
.LogonUser
.Reply
.Quotas
;
302 LsaRegisterLogonProcess(PLSA_STRING LsaLogonProcessName
,
304 PLSA_OPERATIONAL_MODE OperationalMode
)
306 UNICODE_STRING PortName
; // = RTL_CONSTANT_STRING(L"\\LsaAuthenticationPort");
307 SECURITY_QUALITY_OF_SERVICE SecurityQos
;
308 LSA_CONNECTION_INFO ConnectInfo
;
309 ULONG ConnectInfoLength
= sizeof(ConnectInfo
);
312 DPRINT1("LsaRegisterLogonProcess()\n");
314 /* Check the logon process name length */
315 if (LsaLogonProcessName
->Length
> LSASS_MAX_LOGON_PROCESS_NAME_LENGTH
)
316 return STATUS_NAME_TOO_LONG
;
318 RtlInitUnicodeString(&PortName
,
319 L
"\\LsaAuthenticationPort");
321 SecurityQos
.Length
= sizeof(SecurityQos
);
322 SecurityQos
.ImpersonationLevel
= SecurityIdentification
;
323 SecurityQos
.ContextTrackingMode
= SECURITY_DYNAMIC_TRACKING
;
324 SecurityQos
.EffectiveOnly
= TRUE
;
326 strncpy(ConnectInfo
.LogonProcessNameBuffer
,
327 LsaLogonProcessName
->Buffer
,
328 LsaLogonProcessName
->Length
);
329 ConnectInfo
.Length
= LsaLogonProcessName
->Length
;
330 ConnectInfo
.LogonProcessNameBuffer
[ConnectInfo
.Length
] = '\0';
332 Status
= ZwConnectPort(Handle
,
340 if (!NT_SUCCESS(Status
))
342 DPRINT1("ZwConnectPort failed (Status 0x%08lx)\n", Status
);
346 DPRINT("ConnectInfo.OperationalMode: 0x%08lx\n", ConnectInfo
.OperationalMode
);
347 *OperationalMode
= ConnectInfo
.OperationalMode
;
349 if (!NT_SUCCESS(ConnectInfo
.Status
))
351 DPRINT1("ConnectInfo.Status: 0x%08lx\n", ConnectInfo
.Status
);
354 return ConnectInfo
.Status
;
363 LsaEnumerateLogonSessions(PULONG LogonSessionCount
,
364 PLUID
*LogonSessionList
)
367 return STATUS_NOT_IMPLEMENTED
;
376 LsaGetLogonSessionData(PLUID LogonId
,
377 PSECURITY_LOGON_SESSION_DATA
*ppLogonSessionData
)
380 return STATUS_NOT_IMPLEMENTED
;
389 LsaRegisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass
,
390 HANDLE NotificationEventHandle
)
393 return STATUS_NOT_IMPLEMENTED
;
402 LsaUnregisterPolicyChangeNotification(POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass
,
403 HANDLE NotificationEventHandle
)
406 return STATUS_NOT_IMPLEMENTED
;