LogonUser Win32 API Function gives error of incorrect username or password passed for the correct credentials passed!

Prem Jha 45 Reputation points
2024-09-27T07:54:29.66+00:00

I created a Windows SSHD MSI Installer using CPP and Win32 API Function to create a SSH login to the remote user on the Windows Server on which we install our MSI Installer.

The Portuguese Language based Windows Server 2016 when logged in with a default user that belongs to Administrators group has the Portuguese as system locale.

Our aim is to install the MSI Installer with new user and make it work with the new user created so we then created a new user with the name 'rackware' and make a password that has English characters only and a '@' character in it and then add it to the Administrators group and then log in to the new user created.

Once successfully logged in, we try to install our Windows SSHD MSI Installer Setup using this new user's username and password but we get the error of "Incorrect Username or Password entered." even after entering the correct credentials.
Error: Error API =LogonUser, error code = 1326, message = the user name or password is incorrect.
But on my test server when I am trying to reproduce the issue it is not being reproduced. and the Installer is passing the logonuser stage without fail.
Below is the line that checks for the logon user where it is failing. But I am getting an error someone and I am not able to understand the reason behind it.
Before this we create Profile for user using LookupAccountNameW and CreateProfile Win32 API Function for the username passed.
If we pass the incorrect username then it gets errored out at the LookupAccountNameW stage itself.
But we are passing the correct password which we used to login the new user then also it is not able to pass the LogonUser. I am not able to understand what else could be the issue.

Please help me out if someone know what could be the issue. Is there a code level issue as I believe it is working on my test server so do not think or do I need to check for and configure any other setting on the server where it is not allowing the new user to install the msi installer using the new user credentials? Please help me out!

        if (!LogonUser(username.c_str(), domain.c_str(), password.c_str(), LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hToken)) {
                DisplayError(L"LogonUser");
                goto Cleanup;
        }
Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,500 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,016 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,603 questions
Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
6,496 questions
Windows Network
Windows Network
Windows: A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.Network: A group of devices that communicate either wirelessly or via a physical connection.
746 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.