Authentication of Windows Local User account in C# 3.0

99封情书 提交于 2019-12-11 07:32:13

问题


How to authenticate local windows user account in C# 3.0. Windows OS on which i have to validate the password is Vista and Win2K8. Note: User account is a local account and not an domain account. I found a solution in C# 3.5(PrincipalContext class), but could not find in 3.0 framework. Please suggest, thanks


回答1:


If you are looking to validate local users, you can use LogonUser to do this. It can validate both local and remote users. For local users simply pass the machine name in place of the domain.

The following blog entry goes into detail about how to call this function from C#.

[http://alt.pluralsight.com/wiki/default.aspx/Keith.GuideBook/HowToGetATokenForAUser.html]

https://web.archive.org/web/20110224015020/http://alt.pluralsight.com/wiki/default.aspx/Keith.GuideBook/HowToGetATokenForAUser.html

EDIT

This is the best way to authenticate a user. Once you're done with the session, you should call CloseHandle on the resulting token.



来源:https://stackoverflow.com/questions/609553/authentication-of-windows-local-user-account-in-c-sharp-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!