问题
I've been trying to create a simple windows service application that inputs the logon credentials and with a click of a button logs you on. I have read about GINA and Credential Provider. I have also looked at many articles including: http://msdn.microsoft.com/en-us/library/aa379608%28VS.85%29.aspx.
I just want to know if it is possible to logon using the logonuser function provided by windows?
回答1:
No you can not, using LogonUser()
is only one step of many in the logon process. Also GINA is only used in XP and earlier you can not use it on Windows 7.
You will need to instead create a custom Credential Provider (which is not a easy task to do) and it will not be easy to write in any .NET language, it was designed to work with native code (like C++ or C) and there are very few .NET resources available (if any) for example code.
If you do choose to write it in .NET you must use .NET 4.0 or newer due to the new features with Side by Side runtimes. If you write it in a older version it may crash your computer if two competing runtimes attempt to load at the same time. Also if you do get it running and working and then uninstall .NET 4.0 from your computer it also may crash your computer.
来源:https://stackoverflow.com/questions/21704293/can-i-use-logonuser-function-to-logon-to-windows-7