4

For a usb-smartstick application I want to make, I need to be able to unlock a locked workstation in C#. When I insert my usb with a unique id, I want to unlock the ws. What would be the best way to do this?

I'm aiming for a similar application like Rohos Logon Key.

Kara
  • 6,115
  • 16
  • 50
  • 57
Basaa
  • 1,615
  • 4
  • 20
  • 41
  • That's not possible. The only way to start the login sequence from a locked workstation that an authentication provider like that USB key could use requires the SAS (Secure Authentication Sequence). Ctrl + Alt + Del. Three fingers owned by a human. – Hans Passant Sep 24 '12 at 13:55

1 Answers1

6

As I understand it in order to achieve this you need replacement / hook into the implementation of the component of Windows that handles logon. To my knowledge there is no other way to achieve what you are asking for - the reason why users are required to enter the secure attention sequence (SAS) before logging in is to prevent malware from spoofing the logon dialog. If any old program could do what you are asking for then this is something that malware would be able to exploit.

There are two different methods of doing this depending on the version of Windows that you are targetting.

For Windows XP and earlier

In order to do this you need to write your own GINA (Microsoft Graphical Identification and Authentication) replacement. FYI implementing such a dll in .Net is a probably a bad idea (see A GINA replacement in a .NET language?). Also this is fairly advanced stuff, to quote one of the below linked articles

replacing the GINA is an advanced technique that should not be taken lightly. You should only do this if you have no other choice (if, for example, you are implementing a new logon mechanism that Windows does not support).

For more information on GINA take a look through the following links

Vista and later

On Windows Vista and later GINA has been replaced with Credential Providers, so instead you need to implement the ICredentialProviderCredential interface. Although this is a COM interface, again implementing this in a .Net language would be a bad idea.

More detail can be Found in the following links

Community
  • 1
  • 1
Justin
  • 84,773
  • 49
  • 224
  • 367
  • Please note that this answer only applies to XP and older. On Vista and newer, you need to use [`ICredentialProvider`](http://support.microsoft.com/kb/925520/EN-US) – Daniel Hilgarth Sep 24 '12 at 13:50
  • Thanks for the information, but I'm actually looking for like... An example. I tried to download the 5 samples from the msdn, but I need to validate my Windows, but that tool isn't working anymore. Anyone has a very simple credential provider, just so I can unlock my workstation? Thanks! – Basaa Sep 24 '12 at 16:50
  • @Justin Could you take a look at associated with this my problem thttp://stackoverflow.com/questions/27567811/how-to-unlock-windows-login-screen ? Thank You! –  Dec 22 '14 at 11:05