windows 使用 .net 解锁本地计算机
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5764174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unlock local computer using .net
提问by Soumya
Is there any way, without using DLL injection, services, and whatnot, to unlock the local computer using .net? The windows username and password is available to my program.
有什么方法可以不使用 DLL 注入、服务等来解锁使用 .net 的本地计算机?Windows 用户名和密码可用于我的程序。
采纳答案by Dennis
I think there is no .NET function that you can use to unlock your computer and there is no short way to achieve it. But there is a way.
我认为没有可用于解锁计算机的 .NET 功能,并且没有捷径可以实现。但是有一种方法。
You need to implement your custom ICredentialProvider componet, hook it into the windows authentication mechanism, and implement communication between it and your application.
您需要实现您的自定义 ICredentialProvider 组件,将其挂接到 Windows 身份验证机制中,并实现它与您的应用程序之间的通信。
The Windows 7 authentication mechanism consists of two parts. They are WinLogon and LogonUI. LogonUI is responsible for displaying a login window and notification of WinLogon about users' actions. Winlogon reacts for events from LogonUI and performs required actions to log-in users, log-off users, lock sessions, and unlock sessions.
Windows 7 身份验证机制由两部分组成。它们是 WinLogon 和 LogonUI。LogonUI 负责显示登录窗口和 WinLogon 有关用户操作的通知。Winlogon 对来自 LogonUI 的事件做出反应,并执行登录用户、注销用户、锁定会话和解锁会话所需的操作。
Microsoft provides a mechanism to hook a custom behavior into LogonUI. To do this you need to create a COM object that implements ICredentialProvider and register it with a system. You component can tell LogonUI to tell WinLogon to unlock a session.
Microsoft 提供了一种将自定义行为挂接到 LogonUI 的机制。为此,您需要创建一个实现 ICredentialProvider 的 COM 对象并将其注册到系统。您的组件可以告诉 LogonUI 告诉 WinLogon 解锁会话。
Here are couple examples of how to build custom credential providers: How to Build Custom Logon UI's in Windows Vista, Create Custom Login Experiences With Credential Providers For Windows Vista
下面是如何构建自定义凭据提供几个例子: 如何创建自定义登录界面在Windows Vista中, 创建自定义登录遇到与认证供应商对于Windows Vista
This mechanism will work for Windows Vista and Windows 7. You need to use similar mechanism called GINA if you want to achieve the same result for Windows XP. Here you can read more about GINA: Winlogon and GINA
此机制适用于 Windows Vista 和 Windows 7。如果您想在 Windows XP 上获得相同的结果,则需要使用称为 GINA 的类似机制。在这里您可以阅读有关 GINA 的更多信息:Winlogon 和 GINA
There was a hack that you could kind of “unlock” a session in Windows XP.
有一个技巧,你可以在 Windows XP 中“解锁”一个会话。
WinLogon in Windows XP created an additional desktop and switched to it when user chose to lock a session. It was possible to switch back to a “normal” desktop using Windows API. Everything worked fine except WinLogon still though that system is locked and did not react for Ctrl-Alt-Del. I believe that it will not work for Windows Vista and 7. But you could try. It can be simple than implementing a custom credential provider.
Windows XP 中的 WinLogon 创建了一个额外的桌面,并在用户选择锁定会话时切换到它。可以使用 Windows API 切换回“正常”桌面。尽管该系统被锁定并且对 Ctrl-Alt-Del 没有反应,但除了 WinLogon 之外,一切正常。我相信它不适用于 Windows Vista 和 7。但您可以尝试。它可以比实现自定义凭据提供程序简单。
Here is an example of how to do that: Remotely Unlock a Windows Workstation
以下是如何执行此操作的示例:远程解锁 Windows 工作站
I hope this answered your question.
我希望这回答了你的问题。
回答by slugster
No there isn't, at least not within the context specified in your question. But i have to ask - why do you want it unlocked? If you need an application to run, the machine doesn't have to be unlocked for that to happen.
不,没有,至少在您的问题中指定的上下文中没有。但我不得不问 - 你为什么要解锁它?如果您需要运行应用程序,则无需解锁机器即可实现。