I want to protect connection strings in my app.config file. I'm using this code to do it:
Public Shared Sub ProtectConnString()
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim configSection As System.Configuration.ConfigurationSection
configSection = config.ConnectionStrings
If Not (configSection Is Nothing) Then
If Not (configSection.ElementInformation.IsLocked) Then
configSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")
configSection.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Full)
End If
End If
End Sub
However, I notice it's using Machine-Level DPAPI. I'd like it to use User-Level DPAPI. How can I make this happen?
If you want to use a user level DataProtectionConfigurationProvider as opposed to machine level than add the configuration below to app.config and add the code as shown below.
Add this to app.config
C# Code