简体   繁体   中英

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#).

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

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.

Edit: This might help: Encrypting Passwords in a .NET app.config File

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.

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.

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