C# Unlock workstation

前端 未结 1 1176
北海茫月
北海茫月 2021-01-01 04:49

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

相关标签:
1条回答
  • 2021-01-01 05:41

    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

    • Unlock Windows workstation programatically
    • Customizing GINA, Part 1
    • Customizing GINA, Part 2
    • Lock Windows Desktop
    • Aucun (a replacement GINA project)
    • Microsoft Graphical Identification and Authentication (GINA) (MSDN)
    • The Essentials of Replacing the Microsoft Graphical Identification and Authentication Dynamic Link Library

    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

    • Winlogon and Credential Providers
    • Create Custom Login Experiences With Credential Providers For Windows Vista
    • How to Build Custom Logon UI’s in Windows Vista
    • Add winlogon login method using C# and YubiKey
    • Credential Provider Samples
    0 讨论(0)
提交回复
热议问题