[LSASRV][MSV1_0]
[reactos.git] / reactos / dll / win32 / msv1_0 / msv1_0.c
1 /*
2 * PROJECT: Authentication Package DLL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/msv1_0/msv1_0.c
5 * PURPOSE: Main file
6 * COPYRIGHT: Copyright 2013 Eric Kohl
7 */
8
9 /* INCLUDES ****************************************************************/
10
11 #include "msv1_0.h"
12
13 WINE_DEFAULT_DEBUG_CHANNEL(msv1_0);
14
15
16 /* GLOBALS *****************************************************************/
17
18 LSA_DISPATCH_TABLE DispatchTable;
19
20
21 /* FUNCTIONS ***************************************************************/
22
23 static
24 NTSTATUS
25 GetDomainSid(PRPC_SID *Sid)
26 {
27 LSAPR_HANDLE PolicyHandle = NULL;
28 PLSAPR_POLICY_INFORMATION PolicyInfo = NULL;
29 ULONG Length = 0;
30 NTSTATUS Status;
31
32 Status = LsaIOpenPolicyTrusted(&PolicyHandle);
33 if (!NT_SUCCESS(Status))
34 {
35 TRACE("LsaIOpenPolicyTrusted() failed (Status 0x%08lx)\n", Status);
36 return Status;
37 }
38
39 Status = LsarQueryInformationPolicy(PolicyHandle,
40 PolicyAccountDomainInformation,
41 &PolicyInfo);
42 if (!NT_SUCCESS(Status))
43 {
44 TRACE("LsarQueryInformationPolicy() failed (Status 0x%08lx)\n", Status);
45 goto done;
46 }
47
48 Length = RtlLengthSid(PolicyInfo->PolicyAccountDomainInfo.Sid);
49
50 *Sid = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length);
51 if (*Sid == NULL)
52 {
53 ERR("Failed to allocate SID\n");
54 Status = STATUS_INSUFFICIENT_RESOURCES;
55 goto done;
56 }
57
58 memcpy(*Sid, PolicyInfo->PolicyAccountDomainInfo.Sid, Length);
59
60 done:
61 if (PolicyInfo != NULL)
62 LsaIFree_LSAPR_POLICY_INFORMATION(PolicyAccountDomainInformation,
63 PolicyInfo);
64
65 if (PolicyHandle != NULL)
66 LsarClose(&PolicyHandle);
67
68 return Status;
69 }
70
71
72 static
73 NTSTATUS
74 BuildInteractiveProfileBuffer(IN PLSA_CLIENT_REQUEST ClientRequest,
75 IN PSAMPR_USER_INFO_BUFFER UserInfo,
76 IN PUNICODE_STRING LogonServer,
77 OUT PMSV1_0_INTERACTIVE_PROFILE *ProfileBuffer,
78 OUT PULONG ProfileBufferLength)
79 {
80 PMSV1_0_INTERACTIVE_PROFILE LocalBuffer = NULL;
81 PVOID ClientBaseAddress = NULL;
82 LPWSTR Ptr;
83 ULONG BufferLength;
84 NTSTATUS Status = STATUS_SUCCESS;
85
86 *ProfileBuffer = NULL;
87 *ProfileBufferLength = 0;
88
89 BufferLength = sizeof(MSV1_0_INTERACTIVE_PROFILE) +
90 UserInfo->All.FullName.Length + sizeof(WCHAR) +
91 UserInfo->All.HomeDirectory.Length + sizeof(WCHAR) +
92 UserInfo->All.HomeDirectoryDrive.Length + sizeof(WCHAR) +
93 UserInfo->All.ScriptPath.Length + sizeof(WCHAR) +
94 UserInfo->All.ProfilePath.Length + sizeof(WCHAR) +
95 LogonServer->Length + sizeof(WCHAR);
96
97 LocalBuffer = DispatchTable.AllocateLsaHeap(BufferLength);
98 if (LocalBuffer == NULL)
99 {
100 TRACE("Failed to allocate the local buffer!\n");
101 Status = STATUS_INSUFFICIENT_RESOURCES;
102 goto done;
103 }
104
105 Status = DispatchTable.AllocateClientBuffer(ClientRequest,
106 BufferLength,
107 &ClientBaseAddress);
108 if (!NT_SUCCESS(Status))
109 {
110 TRACE("DispatchTable.AllocateClientBuffer failed (Status 0x%08lx)\n", Status);
111 goto done;
112 }
113
114 TRACE("ClientBaseAddress: %p\n", ClientBaseAddress);
115
116 Ptr = (LPWSTR)((ULONG_PTR)LocalBuffer + sizeof(MSV1_0_INTERACTIVE_PROFILE));
117
118 LocalBuffer->MessageType = MsV1_0InteractiveProfile;
119 LocalBuffer->LogonCount = UserInfo->All.LogonCount;
120 LocalBuffer->BadPasswordCount = UserInfo->All.BadPasswordCount;
121
122 LocalBuffer->LogonTime.LowPart = UserInfo->All.LastLogon.LowPart;
123 LocalBuffer->LogonTime.HighPart = UserInfo->All.LastLogon.HighPart;
124
125 // LocalBuffer->LogoffTime.LowPart =
126 // LocalBuffer->LogoffTime.HighPart =
127
128 // LocalBuffer->KickOffTime.LowPart =
129 // LocalBuffer->KickOffTime.HighPart =
130
131 LocalBuffer->PasswordLastSet.LowPart = UserInfo->All.PasswordLastSet.LowPart;
132 LocalBuffer->PasswordLastSet.HighPart = UserInfo->All.PasswordLastSet.HighPart;
133
134 LocalBuffer->PasswordCanChange.LowPart = UserInfo->All.PasswordCanChange.LowPart;
135 LocalBuffer->PasswordCanChange.HighPart = UserInfo->All.PasswordCanChange.HighPart;
136
137 LocalBuffer->PasswordMustChange.LowPart = UserInfo->All.PasswordMustChange.LowPart;
138 LocalBuffer->PasswordMustChange.HighPart = UserInfo->All.PasswordMustChange.HighPart;
139
140 LocalBuffer->LogonScript.Length = UserInfo->All.ScriptPath.Length;
141 LocalBuffer->LogonScript.MaximumLength = UserInfo->All.ScriptPath.Length + sizeof(WCHAR);
142 LocalBuffer->LogonScript.Buffer = (LPWSTR)((ULONG_PTR)ClientBaseAddress + (ULONG_PTR)Ptr - (ULONG_PTR)LocalBuffer);
143 memcpy(Ptr,
144 UserInfo->All.ScriptPath.Buffer,
145 UserInfo->All.ScriptPath.Length);
146
147 Ptr = (LPWSTR)((ULONG_PTR)Ptr + LocalBuffer->LogonScript.MaximumLength);
148
149 LocalBuffer->HomeDirectory.Length = UserInfo->All.HomeDirectory.Length;
150 LocalBuffer->HomeDirectory.MaximumLength = UserInfo->All.HomeDirectory.Length + sizeof(WCHAR);
151 LocalBuffer->HomeDirectory.Buffer = (LPWSTR)((ULONG_PTR)ClientBaseAddress + (ULONG_PTR)Ptr - (ULONG_PTR)LocalBuffer);
152 memcpy(Ptr,
153 UserInfo->All.HomeDirectory.Buffer,
154 UserInfo->All.HomeDirectory.Length);
155
156 Ptr = (LPWSTR)((ULONG_PTR)Ptr + LocalBuffer->HomeDirectory.MaximumLength);
157
158 LocalBuffer->FullName.Length = UserInfo->All.FullName.Length;
159 LocalBuffer->FullName.MaximumLength = UserInfo->All.FullName.Length + sizeof(WCHAR);
160 LocalBuffer->FullName.Buffer = (LPWSTR)((ULONG_PTR)ClientBaseAddress + (ULONG_PTR)Ptr - (ULONG_PTR)LocalBuffer);
161 memcpy(Ptr,
162 UserInfo->All.FullName.Buffer,
163 UserInfo->All.FullName.Length);
164 TRACE("FullName.Buffer: %p\n", LocalBuffer->FullName.Buffer);
165
166 Ptr = (LPWSTR)((ULONG_PTR)Ptr + LocalBuffer->FullName.MaximumLength);
167
168 LocalBuffer->ProfilePath.Length = UserInfo->All.ProfilePath.Length;
169 LocalBuffer->ProfilePath.MaximumLength = UserInfo->All.ProfilePath.Length + sizeof(WCHAR);
170 LocalBuffer->ProfilePath.Buffer = (LPWSTR)((ULONG_PTR)ClientBaseAddress + (ULONG_PTR)Ptr - (ULONG_PTR)LocalBuffer);
171 memcpy(Ptr,
172 UserInfo->All.ProfilePath.Buffer,
173 UserInfo->All.ProfilePath.Length);
174
175 Ptr = (LPWSTR)((ULONG_PTR)Ptr + LocalBuffer->ProfilePath.MaximumLength);
176
177 LocalBuffer->HomeDirectoryDrive.Length = UserInfo->All.HomeDirectoryDrive.Length;
178 LocalBuffer->HomeDirectoryDrive.MaximumLength = UserInfo->All.HomeDirectoryDrive.Length + sizeof(WCHAR);
179 LocalBuffer->HomeDirectoryDrive.Buffer = (LPWSTR)((ULONG_PTR)ClientBaseAddress + (ULONG_PTR)Ptr - (ULONG_PTR)LocalBuffer);
180 memcpy(Ptr,
181 UserInfo->All.HomeDirectoryDrive.Buffer,
182 UserInfo->All.HomeDirectoryDrive.Length);
183
184 Ptr = (LPWSTR)((ULONG_PTR)Ptr + LocalBuffer->HomeDirectoryDrive.MaximumLength);
185
186 LocalBuffer->LogonServer.Length = LogonServer->Length;
187 LocalBuffer->LogonServer.MaximumLength = LogonServer->Length + sizeof(WCHAR);
188 LocalBuffer->LogonServer.Buffer = (LPWSTR)((ULONG_PTR)ClientBaseAddress + (ULONG_PTR)Ptr - (ULONG_PTR)LocalBuffer);;
189 memcpy(Ptr,
190 LogonServer->Buffer,
191 LogonServer->Length);
192
193 LocalBuffer->UserFlags = 0;
194
195 Status = DispatchTable.CopyToClientBuffer(ClientRequest,
196 BufferLength,
197 ClientBaseAddress,
198 LocalBuffer);
199 if (!NT_SUCCESS(Status))
200 {
201 TRACE("DispatchTable.CopyToClientBuffer failed (Status 0x%08lx)\n", Status);
202 goto done;
203 }
204
205 *ProfileBuffer = (PMSV1_0_INTERACTIVE_PROFILE)ClientBaseAddress;
206 *ProfileBufferLength = BufferLength;
207
208 done:
209 if (LocalBuffer != NULL)
210 DispatchTable.FreeLsaHeap(LocalBuffer);
211
212 if (!NT_SUCCESS(Status))
213 {
214 if (ClientBaseAddress != NULL)
215 DispatchTable.FreeClientBuffer(ClientRequest,
216 ClientBaseAddress);
217 }
218
219 return Status;
220 }
221
222
223 static
224 PSID
225 AppendRidToSid(PSID SrcSid,
226 ULONG Rid)
227 {
228 PSID DstSid = NULL;
229 UCHAR RidCount;
230
231 RidCount = *RtlSubAuthorityCountSid(SrcSid);
232 if (RidCount >= 8)
233 return NULL;
234
235 DstSid = DispatchTable.AllocateLsaHeap(RtlLengthRequiredSid(RidCount + 1));
236 if (DstSid == NULL)
237 return NULL;
238
239 RtlCopyMemory(DstSid,
240 SrcSid,
241 RtlLengthRequiredSid(RidCount));
242
243 *RtlSubAuthorityCountSid(DstSid) = RidCount + 1;
244 *RtlSubAuthoritySid(DstSid, RidCount) = Rid;
245
246 return DstSid;
247 }
248
249 static
250 NTSTATUS
251 BuildTokenUser(OUT PTOKEN_USER User,
252 IN PSID AccountDomainSid,
253 IN ULONG RelativeId)
254 {
255 User->User.Sid = AppendRidToSid(AccountDomainSid,
256 RelativeId);
257 if (User->User.Sid == NULL)
258 {
259 ERR("Could not create the user SID\n");
260 return STATUS_UNSUCCESSFUL;
261 }
262
263 User->User.Attributes = 0;
264
265 return STATUS_SUCCESS;
266 }
267
268
269 static
270 NTSTATUS
271 BuildTokenGroups(IN PSID AccountDomainSid,
272 IN PLUID LogonId,
273 OUT PTOKEN_GROUPS *Groups,
274 OUT PSID *PrimaryGroupSid,
275 OUT PSID *OwnerSid)
276 {
277 SID_IDENTIFIER_AUTHORITY WorldAuthority = {SECURITY_WORLD_SID_AUTHORITY};
278 SID_IDENTIFIER_AUTHORITY LocalAuthority = {SECURITY_LOCAL_SID_AUTHORITY};
279 SID_IDENTIFIER_AUTHORITY SystemAuthority = {SECURITY_NT_AUTHORITY};
280 PTOKEN_GROUPS TokenGroups;
281 #define MAX_GROUPS 8
282 DWORD GroupCount = 0;
283 PSID Sid;
284 NTSTATUS Status = STATUS_SUCCESS;
285
286 TokenGroups = DispatchTable.AllocateLsaHeap(sizeof(TOKEN_GROUPS) +
287 MAX_GROUPS * sizeof(SID_AND_ATTRIBUTES));
288 if (TokenGroups == NULL)
289 {
290 return STATUS_INSUFFICIENT_RESOURCES;
291 }
292
293 Sid = AppendRidToSid(AccountDomainSid, DOMAIN_GROUP_RID_USERS);
294 if (Sid == NULL)
295 {
296
297 }
298
299 /* Member of the domain */
300 TokenGroups->Groups[GroupCount].Sid = Sid;
301 TokenGroups->Groups[GroupCount].Attributes =
302 SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
303 *PrimaryGroupSid = Sid;
304 GroupCount++;
305
306 /* Member of 'Everyone' */
307 RtlAllocateAndInitializeSid(&WorldAuthority,
308 1,
309 SECURITY_WORLD_RID,
310 SECURITY_NULL_RID,
311 SECURITY_NULL_RID,
312 SECURITY_NULL_RID,
313 SECURITY_NULL_RID,
314 SECURITY_NULL_RID,
315 SECURITY_NULL_RID,
316 SECURITY_NULL_RID,
317 &Sid);
318 TokenGroups->Groups[GroupCount].Sid = Sid;
319 TokenGroups->Groups[GroupCount].Attributes =
320 SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
321 GroupCount++;
322
323 #if 1
324 /* Member of 'Administrators' */
325 RtlAllocateAndInitializeSid(&SystemAuthority,
326 2,
327 SECURITY_BUILTIN_DOMAIN_RID,
328 DOMAIN_ALIAS_RID_ADMINS,
329 SECURITY_NULL_RID,
330 SECURITY_NULL_RID,
331 SECURITY_NULL_RID,
332 SECURITY_NULL_RID,
333 SECURITY_NULL_RID,
334 SECURITY_NULL_RID,
335 &Sid);
336 TokenGroups->Groups[GroupCount].Sid = Sid;
337 TokenGroups->Groups[GroupCount].Attributes =
338 SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
339 GroupCount++;
340 #else
341 TRACE("Not adding user to Administrators group\n");
342 #endif
343
344 /* Member of 'Users' */
345 RtlAllocateAndInitializeSid(&SystemAuthority,
346 2,
347 SECURITY_BUILTIN_DOMAIN_RID,
348 DOMAIN_ALIAS_RID_USERS,
349 SECURITY_NULL_RID,
350 SECURITY_NULL_RID,
351 SECURITY_NULL_RID,
352 SECURITY_NULL_RID,
353 SECURITY_NULL_RID,
354 SECURITY_NULL_RID,
355 &Sid);
356 TokenGroups->Groups[GroupCount].Sid = Sid;
357 TokenGroups->Groups[GroupCount].Attributes =
358 SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
359 GroupCount++;
360
361 /* Logon SID */
362 RtlAllocateAndInitializeSid(&SystemAuthority,
363 SECURITY_LOGON_IDS_RID_COUNT,
364 SECURITY_LOGON_IDS_RID,
365 LogonId->HighPart,
366 LogonId->LowPart,
367 SECURITY_NULL_RID,
368 SECURITY_NULL_RID,
369 SECURITY_NULL_RID,
370 SECURITY_NULL_RID,
371 SECURITY_NULL_RID,
372 &Sid);
373 TokenGroups->Groups[GroupCount].Sid = Sid;
374 TokenGroups->Groups[GroupCount].Attributes =
375 SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY | SE_GROUP_LOGON_ID;
376 GroupCount++;
377 *OwnerSid = Sid;
378
379 /* Member of 'Local users */
380 RtlAllocateAndInitializeSid(&LocalAuthority,
381 1,
382 SECURITY_LOCAL_RID,
383 SECURITY_NULL_RID,
384 SECURITY_NULL_RID,
385 SECURITY_NULL_RID,
386 SECURITY_NULL_RID,
387 SECURITY_NULL_RID,
388 SECURITY_NULL_RID,
389 SECURITY_NULL_RID,
390 &Sid);
391 TokenGroups->Groups[GroupCount].Sid = Sid;
392 TokenGroups->Groups[GroupCount].Attributes =
393 SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
394 GroupCount++;
395
396 /* Member of 'Interactive users' */
397 RtlAllocateAndInitializeSid(&SystemAuthority,
398 1,
399 SECURITY_INTERACTIVE_RID,
400 SECURITY_NULL_RID,
401 SECURITY_NULL_RID,
402 SECURITY_NULL_RID,
403 SECURITY_NULL_RID,
404 SECURITY_NULL_RID,
405 SECURITY_NULL_RID,
406 SECURITY_NULL_RID,
407 &Sid);
408 TokenGroups->Groups[GroupCount].Sid = Sid;
409 TokenGroups->Groups[GroupCount].Attributes =
410 SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
411 GroupCount++;
412
413 /* Member of 'Authenticated users' */
414 RtlAllocateAndInitializeSid(&SystemAuthority,
415 1,
416 SECURITY_AUTHENTICATED_USER_RID,
417 SECURITY_NULL_RID,
418 SECURITY_NULL_RID,
419 SECURITY_NULL_RID,
420 SECURITY_NULL_RID,
421 SECURITY_NULL_RID,
422 SECURITY_NULL_RID,
423 SECURITY_NULL_RID,
424 &Sid);
425 TokenGroups->Groups[GroupCount].Sid = Sid;
426 TokenGroups->Groups[GroupCount].Attributes =
427 SE_GROUP_ENABLED | SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_MANDATORY;
428 GroupCount++;
429
430 TokenGroups->GroupCount = GroupCount;
431 ASSERT(TokenGroups->GroupCount <= MAX_GROUPS);
432
433 *Groups = TokenGroups;
434
435 return Status;
436 }
437
438
439 static
440 NTSTATUS
441 BuildTokenPrimaryGroup(PTOKEN_PRIMARY_GROUP PrimaryGroup,
442 PSID PrimaryGroupSid)
443 {
444 ULONG RidCount;
445 ULONG Size;
446
447 RidCount = *RtlSubAuthorityCountSid(PrimaryGroupSid);
448 Size = RtlLengthRequiredSid(RidCount);
449
450 PrimaryGroup->PrimaryGroup = DispatchTable.AllocateLsaHeap(Size);
451 if (PrimaryGroup->PrimaryGroup == NULL)
452 {
453 return STATUS_INSUFFICIENT_RESOURCES;
454 }
455
456 RtlCopyMemory(PrimaryGroup->PrimaryGroup,
457 PrimaryGroupSid,
458 Size);
459
460 return STATUS_SUCCESS;
461 }
462
463 static
464 NTSTATUS
465 BuildTokenPrivileges(PTOKEN_PRIVILEGES *TokenPrivileges)
466 {
467 /* FIXME shouldn't use hard-coded list of privileges */
468 static struct
469 {
470 LPCWSTR PrivName;
471 DWORD Attributes;
472 }
473 DefaultPrivs[] =
474 {
475 { L"SeMachineAccountPrivilege", 0 },
476 { L"SeSecurityPrivilege", 0 },
477 { L"SeTakeOwnershipPrivilege", 0 },
478 { L"SeLoadDriverPrivilege", 0 },
479 { L"SeSystemProfilePrivilege", 0 },
480 { L"SeSystemtimePrivilege", 0 },
481 { L"SeProfileSingleProcessPrivilege", 0 },
482 { L"SeIncreaseBasePriorityPrivilege", 0 },
483 { L"SeCreatePagefilePrivilege", 0 },
484 { L"SeBackupPrivilege", 0 },
485 { L"SeRestorePrivilege", 0 },
486 { L"SeShutdownPrivilege", 0 },
487 { L"SeDebugPrivilege", 0 },
488 { L"SeSystemEnvironmentPrivilege", 0 },
489 { L"SeChangeNotifyPrivilege", SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT },
490 { L"SeRemoteShutdownPrivilege", 0 },
491 { L"SeUndockPrivilege", 0 },
492 { L"SeEnableDelegationPrivilege", 0 },
493 { L"SeImpersonatePrivilege", SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT },
494 { L"SeCreateGlobalPrivilege", SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT }
495 };
496 PTOKEN_PRIVILEGES Privileges = NULL;
497 ULONG i;
498 RPC_UNICODE_STRING PrivilegeName;
499 LSAPR_HANDLE PolicyHandle = NULL;
500 NTSTATUS Status = STATUS_SUCCESS;
501
502 Status = LsaIOpenPolicyTrusted(&PolicyHandle);
503 if (!NT_SUCCESS(Status))
504 {
505 goto done;
506 }
507
508 /* Allocate and initialize token privileges */
509 Privileges = DispatchTable.AllocateLsaHeap(sizeof(TOKEN_PRIVILEGES) +
510 sizeof(DefaultPrivs) / sizeof(DefaultPrivs[0]) *
511 sizeof(LUID_AND_ATTRIBUTES));
512 if (Privileges == NULL)
513 {
514 Status = STATUS_INSUFFICIENT_RESOURCES;
515 goto done;
516 }
517
518 Privileges->PrivilegeCount = 0;
519 for (i = 0; i < sizeof(DefaultPrivs) / sizeof(DefaultPrivs[0]); i++)
520 {
521 PrivilegeName.Length = wcslen(DefaultPrivs[i].PrivName) * sizeof(WCHAR);
522 PrivilegeName.MaximumLength = PrivilegeName.Length + sizeof(WCHAR);
523 PrivilegeName.Buffer = (LPWSTR)DefaultPrivs[i].PrivName;
524
525 Status = LsarLookupPrivilegeValue(PolicyHandle,
526 &PrivilegeName,
527 &Privileges->Privileges[Privileges->PrivilegeCount].Luid);
528 if (!NT_SUCCESS(Status))
529 {
530 WARN("Can't set privilege %S\n", DefaultPrivs[i].PrivName);
531 }
532 else
533 {
534 Privileges->Privileges[Privileges->PrivilegeCount].Attributes = DefaultPrivs[i].Attributes;
535 Privileges->PrivilegeCount++;
536 }
537 }
538
539 *TokenPrivileges = Privileges;
540
541 done:
542 if (PolicyHandle != NULL)
543 LsarClose(&PolicyHandle);
544
545 return Status;
546 }
547
548
549 static
550 NTSTATUS
551 BuildTokenOwner(PTOKEN_OWNER Owner,
552 PSID OwnerSid)
553 {
554 ULONG RidCount;
555 ULONG Size;
556
557 RidCount = *RtlSubAuthorityCountSid(OwnerSid);
558 Size = RtlLengthRequiredSid(RidCount);
559
560 Owner->Owner = DispatchTable.AllocateLsaHeap(Size);
561 if (Owner->Owner == NULL)
562 {
563 return STATUS_INSUFFICIENT_RESOURCES;
564 }
565
566 RtlCopyMemory(Owner->Owner,
567 OwnerSid,
568 Size);
569
570 return STATUS_SUCCESS;
571 }
572
573
574 static
575 NTSTATUS
576 BuildTokenInformationBuffer(PLSA_TOKEN_INFORMATION_V1 *TokenInformation,
577 PRPC_SID AccountDomainSid,
578 ULONG RelativeId,
579 PLUID LogonId)
580 {
581 PLSA_TOKEN_INFORMATION_V1 Buffer = NULL;
582 PSID OwnerSid = NULL;
583 PSID PrimaryGroupSid = NULL;
584 ULONG i;
585 NTSTATUS Status = STATUS_SUCCESS;
586
587 Buffer = DispatchTable.AllocateLsaHeap(sizeof(LSA_TOKEN_INFORMATION_V1));
588 if (Buffer == NULL)
589 {
590 TRACE("Failed to allocate the local buffer!\n");
591 Status = STATUS_INSUFFICIENT_RESOURCES;
592 goto done;
593 }
594
595 /* FIXME: */
596 Buffer->ExpirationTime.QuadPart = -1;
597
598 Status = BuildTokenUser(&Buffer->User,
599 (PSID)AccountDomainSid,
600 RelativeId);
601 if (!NT_SUCCESS(Status))
602 goto done;
603
604 Status = BuildTokenGroups((PSID)AccountDomainSid,
605 LogonId,
606 &Buffer->Groups,
607 &PrimaryGroupSid,
608 &OwnerSid);
609 if (!NT_SUCCESS(Status))
610 goto done;
611
612 Status = BuildTokenPrimaryGroup(&Buffer->PrimaryGroup,
613 PrimaryGroupSid);
614 if (!NT_SUCCESS(Status))
615 goto done;
616
617 Status = BuildTokenPrivileges(&Buffer->Privileges);
618 if (!NT_SUCCESS(Status))
619 goto done;
620
621 Status = BuildTokenOwner(&Buffer->Owner,
622 OwnerSid);
623 if (!NT_SUCCESS(Status))
624 goto done;
625
626 *TokenInformation = Buffer;
627
628 done:
629 if (!NT_SUCCESS(Status))
630 {
631 if (Buffer != NULL)
632 {
633 if (Buffer->User.User.Sid != NULL)
634 DispatchTable.FreeLsaHeap(Buffer->User.User.Sid);
635
636 if (Buffer->Groups != NULL)
637 {
638 for (i = 0; i < Buffer->Groups->GroupCount; i++)
639 {
640 if (Buffer->Groups->Groups[i].Sid != NULL)
641 DispatchTable.FreeLsaHeap(Buffer->Groups->Groups[i].Sid);
642 }
643
644 DispatchTable.FreeLsaHeap(Buffer->Groups);
645 }
646
647 if (Buffer->PrimaryGroup.PrimaryGroup != NULL)
648 DispatchTable.FreeLsaHeap(Buffer->PrimaryGroup.PrimaryGroup);
649
650 if (Buffer->Privileges != NULL)
651 DispatchTable.FreeLsaHeap(Buffer->Privileges);
652
653 if (Buffer->Owner.Owner != NULL)
654 DispatchTable.FreeLsaHeap(Buffer->Owner.Owner);
655
656 if (Buffer->DefaultDacl.DefaultDacl != NULL)
657 DispatchTable.FreeLsaHeap(Buffer->DefaultDacl.DefaultDacl);
658
659 DispatchTable.FreeLsaHeap(Buffer);
660 }
661 }
662
663 return Status;
664 }
665
666
667 static
668 NTSTATUS
669 MsvpChangePassword(IN PLSA_CLIENT_REQUEST ClientRequest,
670 IN PVOID ProtocolSubmitBuffer,
671 IN PVOID ClientBufferBase,
672 IN ULONG SubmitBufferLength,
673 OUT PVOID *ProtocolReturnBuffer,
674 OUT PULONG ReturnBufferLength,
675 OUT PNTSTATUS ProtocolStatus)
676 {
677 PMSV1_0_CHANGEPASSWORD_REQUEST RequestBuffer;
678 ULONG_PTR PtrOffset;
679
680 TRACE("()\n");
681
682 RequestBuffer = (PMSV1_0_CHANGEPASSWORD_REQUEST)ProtocolSubmitBuffer;
683
684 /* Fix-up pointers in the request buffer info */
685 PtrOffset = (ULONG_PTR)ProtocolSubmitBuffer - (ULONG_PTR)ClientBufferBase;
686
687 RequestBuffer->DomainName.Buffer = FIXUP_POINTER(RequestBuffer->DomainName.Buffer, PtrOffset);
688 RequestBuffer->AccountName.Buffer = FIXUP_POINTER(RequestBuffer->AccountName.Buffer, PtrOffset);
689 RequestBuffer->OldPassword.Buffer = FIXUP_POINTER(RequestBuffer->OldPassword.Buffer, PtrOffset);
690 RequestBuffer->NewPassword.Buffer = FIXUP_POINTER(RequestBuffer->NewPassword.Buffer, PtrOffset);
691
692 TRACE("Domain: %S\n", RequestBuffer->DomainName.Buffer);
693 TRACE("Account: %S\n", RequestBuffer->AccountName.Buffer);
694 TRACE("Old Password: %S\n", RequestBuffer->OldPassword.Buffer);
695 TRACE("New Password: %S\n", RequestBuffer->NewPassword.Buffer);
696
697
698 return STATUS_SUCCESS;
699 }
700
701
702 static
703 NTSTATUS
704 MsvpCheckPassword(PUNICODE_STRING UserPassword,
705 PSAMPR_USER_INFO_BUFFER UserInfo)
706 {
707 ENCRYPTED_NT_OWF_PASSWORD UserNtPassword;
708 ENCRYPTED_LM_OWF_PASSWORD UserLmPassword;
709 BOOLEAN UserLmPasswordPresent = FALSE;
710 BOOLEAN UserNtPasswordPresent = FALSE;
711 OEM_STRING LmPwdString;
712 CHAR LmPwdBuffer[15];
713 NTSTATUS Status;
714
715 TRACE("(%p %p)\n", UserPassword, UserInfo);
716
717 /* Calculate the LM password and hash for the users password */
718 LmPwdString.Length = 15;
719 LmPwdString.MaximumLength = 15;
720 LmPwdString.Buffer = LmPwdBuffer;
721 ZeroMemory(LmPwdString.Buffer, LmPwdString.MaximumLength);
722
723 Status = RtlUpcaseUnicodeStringToOemString(&LmPwdString,
724 UserPassword,
725 FALSE);
726 if (NT_SUCCESS(Status))
727 {
728 /* Calculate the LM hash value of the users password */
729 Status = SystemFunction006(LmPwdString.Buffer,
730 (LPSTR)&UserLmPassword);
731 if (NT_SUCCESS(Status))
732 {
733 UserLmPasswordPresent = TRUE;
734 }
735 }
736
737 /* Calculate the NT hash of the users password */
738 Status = SystemFunction007(UserPassword,
739 (LPBYTE)&UserNtPassword);
740 if (NT_SUCCESS(Status))
741 {
742 UserNtPasswordPresent = TRUE;
743 }
744
745 Status = STATUS_WRONG_PASSWORD;
746
747 /* Succeed, if no password has been set */
748 if (UserInfo->All.NtPasswordPresent == FALSE &&
749 UserInfo->All.LmPasswordPresent == FALSE)
750 {
751 TRACE("No password check!\n");
752 Status = STATUS_SUCCESS;
753 goto done;
754 }
755
756 /* Succeed, if NT password matches */
757 if (UserNtPasswordPresent && UserInfo->All.NtPasswordPresent)
758 {
759 TRACE("Check NT password hashes:\n");
760 if (RtlEqualMemory(&UserNtPassword,
761 UserInfo->All.NtOwfPassword.Buffer,
762 sizeof(ENCRYPTED_NT_OWF_PASSWORD)))
763 {
764 TRACE(" success!\n");
765 Status = STATUS_SUCCESS;
766 goto done;
767 }
768
769 TRACE(" failed!\n");
770 }
771
772 /* Succeed, if LM password matches */
773 if (UserLmPasswordPresent && UserInfo->All.LmPasswordPresent)
774 {
775 TRACE("Check LM password hashes:\n");
776 if (RtlEqualMemory(&UserLmPassword,
777 UserInfo->All.LmOwfPassword.Buffer,
778 sizeof(ENCRYPTED_LM_OWF_PASSWORD)))
779 {
780 TRACE(" success!\n");
781 Status = STATUS_SUCCESS;
782 goto done;
783 }
784 TRACE(" failed!\n");
785 }
786
787 done:
788 return Status;
789 }
790
791
792 /*
793 * @unimplemented
794 */
795 NTSTATUS
796 NTAPI
797 LsaApCallPackage(IN PLSA_CLIENT_REQUEST ClientRequest,
798 IN PVOID ProtocolSubmitBuffer,
799 IN PVOID ClientBufferBase,
800 IN ULONG SubmitBufferLength,
801 OUT PVOID *ProtocolReturnBuffer,
802 OUT PULONG ReturnBufferLength,
803 OUT PNTSTATUS ProtocolStatus)
804 {
805 ULONG MessageType;
806 NTSTATUS Status;
807
808 TRACE("()\n");
809
810 if (SubmitBufferLength < sizeof(MSV1_0_PROTOCOL_MESSAGE_TYPE))
811 return STATUS_INVALID_PARAMETER;
812
813 MessageType = (ULONG)*((PMSV1_0_PROTOCOL_MESSAGE_TYPE)ProtocolSubmitBuffer);
814
815 *ProtocolReturnBuffer = NULL;
816 *ReturnBufferLength = 0;
817
818 switch (MessageType)
819 {
820 case MsV1_0Lm20ChallengeRequest:
821 case MsV1_0Lm20GetChallengeResponse:
822 case MsV1_0EnumerateUsers:
823 case MsV1_0GetUserInfo:
824 case MsV1_0ReLogonUsers:
825 Status = STATUS_NOT_IMPLEMENTED;
826 break;
827
828 case MsV1_0ChangePassword:
829 Status = MsvpChangePassword(ClientRequest,
830 ProtocolSubmitBuffer,
831 ClientBufferBase,
832 SubmitBufferLength,
833 ProtocolReturnBuffer,
834 ReturnBufferLength,
835 ProtocolStatus);
836 break;
837
838 case MsV1_0ChangeCachedPassword:
839 case MsV1_0GenericPassthrough:
840 case MsV1_0CacheLogon:
841 case MsV1_0SubAuth:
842 case MsV1_0DeriveCredential:
843 case MsV1_0CacheLookup:
844 Status = STATUS_NOT_IMPLEMENTED;
845 break;
846
847 default:
848 return STATUS_INVALID_PARAMETER;
849 }
850
851 return Status;
852 }
853
854
855 /*
856 * @unimplemented
857 */
858 NTSTATUS
859 NTAPI
860 LsaApCallPackagePassthrough(IN PLSA_CLIENT_REQUEST ClientRequest,
861 IN PVOID ProtocolSubmitBuffer,
862 IN PVOID ClientBufferBase,
863 IN ULONG SubmitBufferLength,
864 OUT PVOID *ProtocolReturnBuffer,
865 OUT PULONG ReturnBufferLength,
866 OUT PNTSTATUS ProtocolStatus)
867 {
868 TRACE("()\n");
869 return STATUS_NOT_IMPLEMENTED;
870 }
871
872
873 /*
874 * @unimplemented
875 */
876 NTSTATUS
877 NTAPI
878 LsaApCallPackageUntrusted(IN PLSA_CLIENT_REQUEST ClientRequest,
879 IN PVOID ProtocolSubmitBuffer,
880 IN PVOID ClientBufferBase,
881 IN ULONG SubmitBufferLength,
882 OUT PVOID *ProtocolReturnBuffer,
883 OUT PULONG ReturnBufferLength,
884 OUT PNTSTATUS ProtocolStatus)
885 {
886 TRACE("()\n");
887 return STATUS_NOT_IMPLEMENTED;
888 }
889
890
891 /*
892 * @unimplemented
893 */
894 NTSTATUS
895 NTAPI
896 LsaApInitializePackage(IN ULONG AuthenticationPackageId,
897 IN PLSA_DISPATCH_TABLE LsaDispatchTable,
898 IN PLSA_STRING Database OPTIONAL,
899 IN PLSA_STRING Confidentiality OPTIONAL,
900 OUT PLSA_STRING *AuthenticationPackageName)
901 {
902 PANSI_STRING NameString;
903 PCHAR NameBuffer;
904
905 TRACE("(%lu %p %p %p %p)\n",
906 AuthenticationPackageId, LsaDispatchTable, Database,
907 Confidentiality, AuthenticationPackageName);
908
909 /* Get the dispatch table entries */
910 DispatchTable.CreateLogonSession = LsaDispatchTable->CreateLogonSession;
911 DispatchTable.DeleteLogonSession = LsaDispatchTable->DeleteLogonSession;
912 DispatchTable.AddCredential = LsaDispatchTable->AddCredential;
913 DispatchTable.GetCredentials = LsaDispatchTable->GetCredentials;
914 DispatchTable.DeleteCredential = LsaDispatchTable->DeleteCredential;
915 DispatchTable.AllocateLsaHeap = LsaDispatchTable->AllocateLsaHeap;
916 DispatchTable.FreeLsaHeap = LsaDispatchTable->FreeLsaHeap;
917 DispatchTable.AllocateClientBuffer = LsaDispatchTable->AllocateClientBuffer;
918 DispatchTable.FreeClientBuffer = LsaDispatchTable->FreeClientBuffer;
919 DispatchTable.CopyToClientBuffer = LsaDispatchTable->CopyToClientBuffer;
920 DispatchTable.CopyFromClientBuffer = LsaDispatchTable->CopyFromClientBuffer;
921
922 /* Return the package name */
923 NameString = DispatchTable.AllocateLsaHeap(sizeof(LSA_STRING));
924 if (NameString == NULL)
925 return STATUS_INSUFFICIENT_RESOURCES;
926
927 NameBuffer = DispatchTable.AllocateLsaHeap(sizeof(MSV1_0_PACKAGE_NAME));
928 if (NameBuffer == NULL)
929 {
930 DispatchTable.FreeLsaHeap(NameString);
931 return STATUS_INSUFFICIENT_RESOURCES;
932 }
933
934 strcpy(NameBuffer, MSV1_0_PACKAGE_NAME);
935
936 RtlInitAnsiString(NameString, NameBuffer);
937
938 *AuthenticationPackageName = (PLSA_STRING)NameString;
939
940 return STATUS_SUCCESS;
941 }
942
943
944 /*
945 * @unimplemented
946 */
947 VOID
948 NTAPI
949 LsaApLogonTerminated(IN PLUID LogonId)
950 {
951 TRACE("()\n");
952 }
953
954
955 /*
956 * @unimplemented
957 */
958 NTSTATUS
959 NTAPI
960 LsaApLogonUser(IN PLSA_CLIENT_REQUEST ClientRequest,
961 IN SECURITY_LOGON_TYPE LogonType,
962 IN PVOID AuthenticationInformation,
963 IN PVOID ClientAuthenticationBase,
964 IN ULONG AuthenticationInformationLength,
965 OUT PVOID *ProfileBuffer,
966 OUT PULONG ProfileBufferLength,
967 OUT PLUID LogonId,
968 OUT PNTSTATUS SubStatus,
969 OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
970 OUT PVOID *TokenInformation,
971 OUT PLSA_UNICODE_STRING *AccountName,
972 OUT PLSA_UNICODE_STRING *AuthenticatingAuthority)
973 {
974 PMSV1_0_INTERACTIVE_LOGON LogonInfo;
975
976 SAMPR_HANDLE ServerHandle = NULL;
977 SAMPR_HANDLE DomainHandle = NULL;
978 SAMPR_HANDLE UserHandle = NULL;
979 PRPC_SID AccountDomainSid = NULL;
980 RPC_UNICODE_STRING Names[1];
981 SAMPR_ULONG_ARRAY RelativeIds = {0, NULL};
982 SAMPR_ULONG_ARRAY Use = {0, NULL};
983 PSAMPR_USER_INFO_BUFFER UserInfo = NULL;
984 UNICODE_STRING LogonServer;
985 BOOLEAN SessionCreated = FALSE;
986 NTSTATUS Status;
987
988 TRACE("()\n");
989
990 TRACE("LogonType: %lu\n", LogonType);
991 TRACE("AuthenticationInformation: %p\n", AuthenticationInformation);
992 TRACE("AuthenticationInformationLength: %lu\n", AuthenticationInformationLength);
993
994 *ProfileBuffer = NULL;
995 *ProfileBufferLength = 0;
996 *SubStatus = STATUS_SUCCESS;
997
998 if (LogonType == Interactive ||
999 LogonType == Batch ||
1000 LogonType == Service)
1001 {
1002 ULONG_PTR PtrOffset;
1003
1004 LogonInfo = (PMSV1_0_INTERACTIVE_LOGON)AuthenticationInformation;
1005
1006 /* Fix-up pointers in the authentication info */
1007 PtrOffset = (ULONG_PTR)AuthenticationInformation - (ULONG_PTR)ClientAuthenticationBase;
1008
1009 LogonInfo->LogonDomainName.Buffer = FIXUP_POINTER(LogonInfo->LogonDomainName.Buffer, PtrOffset);
1010 LogonInfo->UserName.Buffer = FIXUP_POINTER(LogonInfo->UserName.Buffer, PtrOffset);
1011 LogonInfo->Password.Buffer = FIXUP_POINTER(LogonInfo->Password.Buffer, PtrOffset);
1012
1013 TRACE("Domain: %S\n", LogonInfo->LogonDomainName.Buffer);
1014 TRACE("User: %S\n", LogonInfo->UserName.Buffer);
1015 TRACE("Password: %S\n", LogonInfo->Password.Buffer);
1016
1017 RtlInitUnicodeString(&LogonServer, L"Testserver");
1018 }
1019 else
1020 {
1021 FIXME("LogonType %lu is not supported yet!\n", LogonType);
1022 return STATUS_NOT_IMPLEMENTED;
1023 }
1024
1025 Status = GetDomainSid(&AccountDomainSid);
1026 if (!NT_SUCCESS(Status))
1027 {
1028 TRACE("GetDomainSid() failed (Status 0x%08lx)\n", Status);
1029 return Status;
1030 }
1031
1032 /* Connect to the SAM server */
1033 Status = SamIConnect(NULL,
1034 &ServerHandle,
1035 SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
1036 TRUE);
1037 if (!NT_SUCCESS(Status))
1038 {
1039 TRACE("SamIConnect() failed (Status 0x%08lx)\n", Status);
1040 goto done;
1041 }
1042
1043 /* Open the account domain */
1044 Status = SamrOpenDomain(ServerHandle,
1045 DOMAIN_LOOKUP,
1046 AccountDomainSid,
1047 &DomainHandle);
1048 if (!NT_SUCCESS(Status))
1049 {
1050 TRACE("SamrOpenDomain failed (Status %08lx)\n", Status);
1051 goto done;
1052 }
1053
1054 Names[0].Length = LogonInfo->UserName.Length;
1055 Names[0].MaximumLength = LogonInfo->UserName.MaximumLength;
1056 Names[0].Buffer = LogonInfo->UserName.Buffer;
1057
1058 /* Try to get the RID for the user name */
1059 Status = SamrLookupNamesInDomain(DomainHandle,
1060 1,
1061 Names,
1062 &RelativeIds,
1063 &Use);
1064 if (!NT_SUCCESS(Status))
1065 {
1066 TRACE("SamrLookupNamesInDomain failed (Status %08lx)\n", Status);
1067 Status = STATUS_NO_SUCH_USER;
1068 goto done;
1069 }
1070
1071 /* Fail, if it is not a user account */
1072 if (Use.Element[0] != SidTypeUser)
1073 {
1074 TRACE("Account is not a user account!\n");
1075 Status = STATUS_NO_SUCH_USER;
1076 goto done;
1077 }
1078
1079 /* Open the user object */
1080 Status = SamrOpenUser(DomainHandle,
1081 USER_READ_GENERAL | USER_READ_LOGON |
1082 USER_READ_ACCOUNT | USER_READ_PREFERENCES, /* FIXME */
1083 RelativeIds.Element[0],
1084 &UserHandle);
1085 if (!NT_SUCCESS(Status))
1086 {
1087 TRACE("SamrOpenUser failed (Status %08lx)\n", Status);
1088 goto done;
1089 }
1090
1091 Status = SamrQueryInformationUser(UserHandle,
1092 UserAllInformation,
1093 &UserInfo);
1094 if (!NT_SUCCESS(Status))
1095 {
1096 TRACE("SamrQueryInformationUser failed (Status %08lx)\n", Status);
1097 goto done;
1098 }
1099
1100
1101 TRACE("UserName: %S\n", UserInfo->All.UserName.Buffer);
1102
1103 /* FIXME: Check restrictions */
1104
1105 /* Check the password */
1106 if ((UserInfo->All.UserAccountControl & USER_PASSWORD_NOT_REQUIRED) == 0)
1107 {
1108 Status = MsvpCheckPassword(&(LogonInfo->Password),
1109 UserInfo);
1110 if (!NT_SUCCESS(Status))
1111 {
1112 TRACE("MsvpCheckPassword failed (Status %08lx)\n", Status);
1113 goto done;
1114 }
1115 }
1116
1117 /* Return logon information */
1118
1119 /* Create and return a new logon id */
1120 Status = NtAllocateLocallyUniqueId(LogonId);
1121 if (!NT_SUCCESS(Status))
1122 {
1123 TRACE("NtAllocateLocallyUniqueId failed (Status %08lx)\n", Status);
1124 goto done;
1125 }
1126
1127 /* Create the logon session */
1128 Status = DispatchTable.CreateLogonSession(LogonId);
1129 if (!NT_SUCCESS(Status))
1130 {
1131 TRACE("CreateLogonSession failed (Status %08lx)\n", Status);
1132 goto done;
1133 }
1134
1135 SessionCreated = TRUE;
1136
1137 /* Build and fill the interactve profile buffer */
1138 Status = BuildInteractiveProfileBuffer(ClientRequest,
1139 UserInfo,
1140 &LogonServer,
1141 (PMSV1_0_INTERACTIVE_PROFILE*)ProfileBuffer,
1142 ProfileBufferLength);
1143 if (!NT_SUCCESS(Status))
1144 {
1145 TRACE("BuildInteractiveProfileBuffer failed (Status %08lx)\n", Status);
1146 goto done;
1147 }
1148
1149 /* Return the token information type */
1150 *TokenInformationType = LsaTokenInformationV1;
1151
1152 /* Build and fill the token information buffer */
1153 Status = BuildTokenInformationBuffer((PLSA_TOKEN_INFORMATION_V1*)TokenInformation,
1154 AccountDomainSid,
1155 RelativeIds.Element[0],
1156 LogonId);
1157 if (!NT_SUCCESS(Status))
1158 {
1159 TRACE("BuildTokenInformationBuffer failed (Status %08lx)\n", Status);
1160 goto done;
1161 }
1162
1163 done:
1164 /* Return the account name */
1165 *AccountName = DispatchTable.AllocateLsaHeap(sizeof(UNICODE_STRING));
1166 if (*AccountName != NULL)
1167 {
1168 (*AccountName)->Buffer = DispatchTable.AllocateLsaHeap(LogonInfo->UserName.Length +
1169 sizeof(UNICODE_NULL));
1170 if ((*AccountName)->Buffer != NULL)
1171 {
1172 (*AccountName)->MaximumLength = LogonInfo->UserName.Length +
1173 sizeof(UNICODE_NULL);
1174 RtlCopyUnicodeString(*AccountName, &LogonInfo->UserName);
1175 }
1176 }
1177
1178 if (!NT_SUCCESS(Status))
1179 {
1180 if (SessionCreated == TRUE)
1181 DispatchTable.DeleteLogonSession(LogonId);
1182
1183 if (*ProfileBuffer != NULL)
1184 {
1185 DispatchTable.FreeClientBuffer(ClientRequest,
1186 *ProfileBuffer);
1187 *ProfileBuffer = NULL;
1188 }
1189 }
1190
1191 if (UserHandle != NULL)
1192 SamrCloseHandle(&UserHandle);
1193
1194 SamIFree_SAMPR_USER_INFO_BUFFER(UserInfo,
1195 UserAllInformation);
1196 SamIFree_SAMPR_ULONG_ARRAY(&RelativeIds);
1197 SamIFree_SAMPR_ULONG_ARRAY(&Use);
1198
1199 if (DomainHandle != NULL)
1200 SamrCloseHandle(&DomainHandle);
1201
1202 if (ServerHandle != NULL)
1203 SamrCloseHandle(&ServerHandle);
1204
1205 if (AccountDomainSid != NULL)
1206 RtlFreeHeap(RtlGetProcessHeap(), 0, AccountDomainSid);
1207
1208 if (Status == STATUS_NO_SUCH_USER ||
1209 Status == STATUS_WRONG_PASSWORD)
1210 {
1211 *SubStatus = Status;
1212 Status = STATUS_LOGON_FAILURE;
1213 }
1214
1215 TRACE("LsaApLogonUser done (Status %08lx)\n", Status);
1216
1217 return Status;
1218 }
1219
1220
1221 /*
1222 * @unimplemented
1223 */
1224 #if 0
1225 NTSTATUS
1226 NTAPI
1227 LsaApLogonUserEx(IN PLSA_CLIENT_REQUEST ClientRequest,
1228 IN SECURITY_LOGON_TYPE LogonType,
1229 IN PVOID AuthenticationInformation,
1230 IN PVOID ClientAuthenticationBase,
1231 IN ULONG AuthenticationInformationLength,
1232 OUT PVOID *ProfileBuffer,
1233 OUT PULONG ProfileBufferLength,
1234 OUT PLUID LogonId,
1235 OUT PNTSTATUS SubStatus,
1236 OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
1237 OUT PVOID *TokenInformation,
1238 OUT PUNICODE_STRING *AccountName,
1239 OUT PUNICODE_STRING *AuthenticatingAuthority,
1240 OUT PUNICODE_STRING *MachineName)
1241 {
1242 TRACE("()\n");
1243
1244 TRACE("LogonType: %lu\n", LogonType);
1245 TRACE("AuthenticationInformation: %p\n", AuthenticationInformation);
1246 TRACE("AuthenticationInformationLength: %lu\n", AuthenticationInformationLength);
1247
1248 return STATUS_NOT_IMPLEMENTED;
1249 }
1250
1251
1252 /*
1253 * @unimplemented
1254 */
1255 NTSTATUS
1256 NTAPI
1257 LsaApLogonUserEx2(IN PLSA_CLIENT_REQUEST ClientRequest,
1258 IN SECURITY_LOGON_TYPE LogonType,
1259 IN PVOID ProtocolSubmitBuffer,
1260 IN PVOID ClientBufferBase,
1261 IN ULONG SubmitBufferSize,
1262 OUT PVOID *ProfileBuffer,
1263 OUT PULONG ProfileBufferSize,
1264 OUT PLUID LogonId,
1265 OUT PNTSTATUS SubStatus,
1266 OUT PLSA_TOKEN_INFORMATION_TYPE TokenInformationType,
1267 OUT PVOID *TokenInformation,
1268 OUT PUNICODE_STRING *AccountName,
1269 OUT PUNICODE_STRING *AuthenticatingAuthority,
1270 OUT PUNICODE_STRING *MachineName,
1271 OUT PSECPKG_PRIMARY_CRED PrimaryCredentials,
1272 OUT PSECPKG_SUPPLEMENTAL_CRED_ARRAY *SupplementalCredentials)
1273 {
1274 TRACE("()\n");
1275
1276 TRACE("LogonType: %lu\n", LogonType);
1277 TRACE("ProtocolSubmitBuffer: %p\n", ProtocolSubmitBuffer);
1278 TRACE("SubmitBufferSize: %lu\n", SubmitBufferSize);
1279
1280
1281 return STATUS_NOT_IMPLEMENTED;
1282 }
1283 #endif
1284
1285 /* EOF */