I have a windows service that runs under LocalSystem account to manage below scenario
I dont want to share account password with users.
I have username and password of the domain user that should logged in to machine.
Autologon not suitable. Because, when a user locks workstation or logs off from account, it will ask for credentials. Users will not have account password.
I tried credential provider, It can auto unlock or logon to computer with credentials but, its not useful in my case (Hard to implement, manage and register)
I tried this solution, but it doesn't create local session.
I tried LogonUser api, i can authenticate user and get token but no session.
What i can do;
- I can switch to another session with / without password with WTSConnectSession.
I need to create a local session with a domain user that i have credentials. Like below;

I implemented credential provider. I used https://github.com/phaetto/windows-credentials-provider as base.