简体   繁体   中英

Authentication of Windows Local User account in C# 3.0

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM