I need my users to input their windows username and password in my application and validate that the credentials are correct, because the role the user should have in my application is mapped to the windows usernames.
(Background: This is an application running on industrial machinery, and the user actually logged into windows is a generic machine user, and the user logging of and on is not feasible). So I cannot just query the currently logged in user and go from there - the user in my software needs to change during the lifetime of the windows login session).
Following Microsofts advice here
The general approach of dealing with credentials is to avoid them and instead rely on other means to authenticate, such as certificates or Windows authentication.
I try to avoid handling the user's password myself.
So I tried using creduipromptforwindowscredentialsw, and while this provides me wit a login window without me handling the credentials, it seems it does not validate the credentials, I can enter anything.
Is there a way to prompt the user for their windows login and just get Username, Domain and "password was correct"? Without ever handling the password in my application?
EDIT to clarify: I do not want or need impersonation. The code can run as the machine user, thats fine. I just want to have a user enter credentials, and get feedback if the credentials were valid and what the username was. With this, my application can grant access to some features that are only accessible to this user.
If I were to handle the passwords myself, my way would be to use DirectoryService to just authenticate against LDAP and be done with it. But I want to avoid having the cleartext passwords in my application if possible.