+#ifdef NEW_LOGON
+ LSA_STRING LogonProcessName;
+ LSA_STRING PackageName;
+ HANDLE LsaHandle = NULL;
+ LSA_OPERATIONAL_MODE SecurityMode = 0;
+ ULONG AuthenticationPackage = 0;
+
+ LSA_STRING OriginName;
+ UNICODE_STRING DomainName;
+ UNICODE_STRING UserName;
+ UNICODE_STRING Password;
+ PMSV1_0_INTERACTIVE_LOGON AuthInfo = NULL;
+ ULONG AuthInfoLength;
+ ULONG_PTR Ptr;
+ TOKEN_SOURCE TokenSource;
+
+ PMSV1_0_INTERACTIVE_PROFILE ProfileBuffer = NULL;
+ ULONG ProfileBufferLength = 0;
+ LUID Luid = {0, 0};
+ HANDLE TokenHandle = NULL;
+ QUOTA_LIMITS QuotaLimits;
+ NTSTATUS SubStatus = STATUS_SUCCESS;
+ NTSTATUS Status;
+
+ *phToken = NULL;
+
+ RtlInitAnsiString((PANSI_STRING)&LogonProcessName,
+ "User32LogonProcess");
+
+ Status = LsaRegisterLogonProcess(&LogonProcessName,
+ &LsaHandle,
+ &SecurityMode);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("LsaRegisterLogonProcess failed (Status 0x%08lx)\n", Status);
+ goto done;
+ }
+
+ RtlInitAnsiString((PANSI_STRING)&PackageName,
+ MSV1_0_PACKAGE_NAME);
+
+ Status = LsaLookupAuthenticationPackage(LsaHandle,
+ &PackageName,
+ &AuthenticationPackage);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("LsaLookupAuthenticationPackage failed (Status 0x%08lx)\n", Status);
+ goto done;
+ }
+
+ TRACE("AuthenticationPackage: 0x%08lx\n", AuthenticationPackage);
+
+
+ RtlInitAnsiString((PANSI_STRING)&OriginName,
+ "Testapp");
+
+ RtlInitUnicodeString(&DomainName,
+ lpszDomain);
+
+ RtlInitUnicodeString(&UserName,
+ lpszUsername);
+
+ RtlInitUnicodeString(&Password,
+ lpszPassword);
+
+ AuthInfoLength = sizeof(MSV1_0_INTERACTIVE_LOGON)+
+ DomainName.MaximumLength +
+ UserName.MaximumLength +
+ Password.MaximumLength;
+
+ AuthInfo = RtlAllocateHeap(RtlGetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ AuthInfoLength);
+ if (AuthInfo == NULL)
+ {
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto done;
+ }
+
+
+ AuthInfo->MessageType = MsV1_0InteractiveLogon;
+
+ Ptr = (ULONG_PTR)AuthInfo + sizeof(MSV1_0_INTERACTIVE_LOGON);
+
+ AuthInfo->LogonDomainName.Length = DomainName.Length;
+ AuthInfo->LogonDomainName.MaximumLength = DomainName.MaximumLength;
+ AuthInfo->LogonDomainName.Buffer = (DomainName.Buffer == NULL) ? NULL : (PWCHAR)Ptr;
+ if (DomainName.MaximumLength > 0)
+ {
+ RtlCopyMemory(AuthInfo->LogonDomainName.Buffer,
+ DomainName.Buffer,
+ DomainName.MaximumLength);
+
+ Ptr += DomainName.MaximumLength;
+ }
+
+ AuthInfo->UserName.Length = UserName.Length;
+ AuthInfo->UserName.MaximumLength = UserName.MaximumLength;
+ AuthInfo->UserName.Buffer = (PWCHAR)Ptr;
+ if (UserName.MaximumLength > 0)
+ RtlCopyMemory(AuthInfo->UserName.Buffer,
+ UserName.Buffer,
+ UserName.MaximumLength);
+
+ Ptr += UserName.MaximumLength;
+
+ AuthInfo->Password.Length = Password.Length;
+ AuthInfo->Password.MaximumLength = Password.MaximumLength;
+ AuthInfo->Password.Buffer = (PWCHAR)Ptr;
+ if (Password.MaximumLength > 0)
+ RtlCopyMemory(AuthInfo->Password.Buffer,
+ Password.Buffer,
+ Password.MaximumLength);
+
+ /* FIXME: Add LocalGroups here */
+
+ strcpy(TokenSource.SourceName, "Bla");
+ AllocateLocallyUniqueId(&TokenSource.SourceIdentifier);
+
+ Status = LsaLogonUser(LsaHandle,
+ &OriginName,
+ Interactive,
+ AuthenticationPackage,
+ (PVOID)AuthInfo,
+ AuthInfoLength,
+ NULL, /* LocalGroups */
+ &TokenSource,
+ (PVOID*)&ProfileBuffer,
+ &ProfileBufferLength,
+ &Luid,
+ &TokenHandle,
+ &QuotaLimits,
+ &SubStatus);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("LsaLogonUser failed (Status 0x%08lx)\n", Status);
+ goto done;
+ }
+
+ if (ProfileBuffer != NULL)
+ {
+ TRACE("ProfileBuffer: %p\n", ProfileBuffer);
+ TRACE("MessageType: %u\n", ProfileBuffer->MessageType);
+
+ TRACE("FullName: %p\n", ProfileBuffer->FullName.Buffer);
+ TRACE("FullName: %S\n", ProfileBuffer->FullName.Buffer);
+
+ TRACE("LogonServer: %p\n", ProfileBuffer->LogonServer.Buffer);
+ TRACE("LogonServer: %S\n", ProfileBuffer->LogonServer.Buffer);
+ }
+
+ TRACE("Luid: 0x%08lx%08lx\n", Luid.HighPart, Luid.LowPart);
+
+ if (TokenHandle != NULL)
+ {
+ TRACE("TokenHandle: %p\n", TokenHandle);
+ }
+
+ *phToken = TokenHandle;
+
+done:
+ if (ProfileBuffer != NULL)
+ LsaFreeReturnBuffer(ProfileBuffer);
+
+ if (!NT_SUCCESS(Status))
+ {
+ if (TokenHandle != NULL)
+ CloseHandle(TokenHandle);
+ }
+
+ if (AuthInfo != NULL)
+ RtlFreeHeap(RtlGetProcessHeap(), 0, AuthInfo);
+
+ if (LsaHandle != NULL)
+ {
+ Status = LsaDeregisterLogonProcess(LsaHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ TRACE("LsaDeregisterLogonProcess failed (Status 0x%08lx)\n", Status);
+ }
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ SetLastError(RtlNtStatusToDosError(Status));
+ return FALSE;
+ }
+
+ return TRUE;
+#else