简体   繁体   English

如何在Windows应用程序中为当前登录的用户存储用户设置(用户名,密码)

[英]How to store user settings (username, password) in a Windows application for the current logged in user

Now my team is working on a project involving a Windows application (C#). 现在我的团队正在开发一个涉及Windows应用程序(C#)的项目。

The application has a option for saving the username and password in the client machine for the current logged in user. 该应用程序可以选择在当前登录用户的客户端计算机中保存用户名和密码。 The user can start the application without entering username and password. 用户无需输入用户名和密码即可启动应用程序。 Please check the snapshot of my requirement. 请检查我的要求的快照。

Please suggest a good example or reference. 请提出一个很好的例子或参考。

Alt text http://www.freeimagehosting.net/uploads/0ff58473e0.jpg 替代文字http://www.freeimagehosting.net/uploads/0ff58473e0.jpg

To persist user credentials easily and in a secure way you can write them to the application configuration file using the ConfigurationManager class, secure the password using the SecureString class and then encrypt it using tools in the Cryptography namespace. 要以安全的方式轻松保存用户凭据,您可以使用ConfigurationManager类将其写入应用程序配置文件,使用SecureString类保护密码,然后使用Cryptography命名空间中的工具对其进行加密。

Edit: This might help: Encrypting Passwords in a .NET app.config File 编辑:这可能会有所帮助: 加密.NET app.config文件中的密码

Here's a class you can download and possibly use. 这是您可以下载并可能使用的课程。 It uses the windows Credential API and provides a dialog, much like the credential dialog in windows, that allows you to save credentials. 它使用Windows Credential API并提供一个对话框,就像Windows中的凭据对话框一样,允许您保存凭据。

It was a proof of concept I did, but it was never need in a production application. 这是我做过的概念验证,但在生产应用程序中从未需要它。 So use at your own risk :) 所以使用风险自负:)

If you're looking for a simple solution, saving the user name and password in user settings would work. 如果您正在寻找一个简单的解决方案,在用户设置中保存用户名和密码将起作用。 However, this approach is not very secure at all because any other user with sufficient privileges on this machine could simply read the saved settings and steal your login details. 但是,这种方法根本不是很安全,因为在这台机器上拥有足够权限的任何其他用户都可以简单地读取保存的设置并窃取您的登录详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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