Question: I have a Windows Service that I want to use to programmatically unlock the workstation, using the account username and password.

This article <https://technet.microsoft.com/en-us/library/dn751047(v=ws.11).aspx> explains the logon authentication workflow on Windows in the following image:
 [![authentication workflow](https://i.stack.imgur.com/sniMO.png)](https://i.stack.imgur.com/sniMO.png)

As seen above, on step 5, the user inputs the credentials into the Logon UI. What I want to achieve is to have the Windows Service input the credentials and have winlogon perform the login.

There is no winlogon API to achieve this. As seen in other questions, using winapi's `LogonUser` function successfully performs the authentication and returns a token, but it does not switch to the application desktop and the Logon UI remains on screen.

Most articles and SO answers hint towards credentials providers, but all credentials providers samples require user interaction with the 
Logon UI.

**Update:** I see some users haven't exactly understood the question and are proposing workarounds that are not useful for my case. The workflow that I'm trying to achieve is the following:

1. Windows service starts on Windows boot (done).
2. Same Windows service has a web service and accepts HTTP requests through an API (done).
3. User provides credentials to the service through the API from another device (done).
4. Provided credentials are used to log into the work station.  

4.1 Provided credentials are used to also unlock the work station in case of lock (WinKey + L).
5. (Optional) The service exposes the Windows accounts via the API.
6. (Optional) The user is able to specify to the service what account wants to use for login.

For now, I am interested in making steps 4 and 4.1.

Answer: 
Not that i condone doing this, but just giving you a solution to the problem. And it isn't programmatically interacting with the WinLogon process. It is programmatically working around it.

Use Windows Autologin property. And reboot to change to that user.
Note this does involve storing the Password in the registry, in clear text.

Specifically set these regkeys

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogin
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword

**\* Edit \***

Helps with 4. Doesn't help with 4.1. Unless you wanna reboot to unlock which i doubt.

Another alternative which sounds promising \ worth investigating is mentioned on an older question <https://stackoverflow.com/a/35173886/4640588>
You task is to implement a credential provider interfaces and at the point where your service receive credentials they can be easily forwarded to LogonUI - look at this [answer](https://stackoverflow.com/a/51417103/3868464). 

The goal is to implement default tile which can pack these credentials.

My own credential provider also has an auto logon/unlock behaviour in some use cases.