Solved

I need help connecting to my DB, securely, from my VB.Net application

Posted on 2016-10-27
5
26 Views
Last Modified: 2016-11-18
Hi Experts,
I just got a request asking me to remove, or encrypt the connection string information from my VB.Net WinForm applications.

A suggestion was to store the connection string in the database and retrieve it somehow.  How would I connect to the sql server database to retrieve my connection string if I don't have my credentials in my Vb.Net application?  How can this be accomplished?

Thanks in advance for your help,
mrotor
0
Comment
Question by:mainrotor
  • 2
  • 2
5 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 250 total points (awarded by participants)
Comment Utility
0
 
LVL 21

Assisted Solution

by:Tapan Pattanaik
Tapan Pattanaik earned 250 total points (awarded by participants)
Comment Utility
Hi mainrotor,

You can encrypt the connection string by following steps.

1. Open Command Prompt with "Run as administrator "
2. At the Command Prompt, enter: ( For .NET framework 4.0)

    cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

In case your web Config is located in "D:\Project\EncryptWebConfig" directory path, then enter the following to encrypt the ConnectionString:

ASPNET_REGIIS -pef "connectionStrings" "D:\Project\EncryptWebConfig"

Use Aspnet_regiis.exe tool with the –pef option and specify the application path as shown above.

Similar  you can Decrypting the Connection String:

ASPNET_REGIIS -pdf "connectionStrings" "D:\Project\EncryptWebConfig"

For moredetails please check the below URL:

http://www.codeproject.com/Tips/795135/Encrypt-ConnectionString-in-Web-Config

Regards,
Tapan Pattanaik
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
nopoints:
@tapan: he is using a windows forms application not a web application therefor no web.config. ErgoÉric Moreau's suggestion of using app.config is correct
1
 
LVL 21

Expert Comment

by:Tapan Pattanaik
Comment Utility
Hi David, You are correct. Thanks for the suggestion.

Hi  mainrotor,

The suggesting I have mentioned above having ID: 41862895 needs to be slightly changed. You have to temporarily rename the App.Config file to Web.Config for performing the above steps which I have mention having ID: 41862895.

Note: The aspnet_regiis.exe Command Line Utility of the Visual Studio does not recognize for App.Config files and hence we need to temporarily rename the App.Config file to Web.Config.

For more details Please check the below links:

http://www.aspsnippets.com/Articles/Encrypt-and-Decrypt-Connection-String-in-AppConfig-file.aspx
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
both good but mine requires less manipulations
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Phishing is at the top of most security top 10 efforts you should be pursuing in 2016 and beyond. If you don't have phishing incorporated into your Security Awareness Program yet, now is the time. Phishers, and the scams they use, are only going to …
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now