LogonUser Win32 API Function gives error of incorrect username or password passed for the correct credentials passed!
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;
}