Click here to Skip to main content
15,918,268 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generalstilll!!! SOS of all SOS'es Pin
NANCO15-Apr-07 1:12
NANCO15-Apr-07 1:12 
GeneralRe: stilll!!! SOS of all SOS'es Pin
Christian Graus15-Apr-07 11:30
protectorChristian Graus15-Apr-07 11:30 
AnswerRe: SOS of all SOS'es Pin
Werries15-Apr-07 1:59
Werries15-Apr-07 1:59 
QuestionConvert string to font Pin
NANCO14-Apr-07 18:02
NANCO14-Apr-07 18:02 
AnswerRe: Convert string to font Pin
Christian Graus14-Apr-07 22:24
protectorChristian Graus14-Apr-07 22:24 
AnswerRe: Convert string to font Pin
Werries15-Apr-07 0:09
Werries15-Apr-07 0:09 
GeneralRe: Convert string to font Pin
NANCO15-Apr-07 1:13
NANCO15-Apr-07 1:13 
QuestionHow do you make a secure database connection string Pin
dragon_14-Apr-07 17:36
dragon_14-Apr-07 17:36 
Hi,I'm trying to create a database connection...

connstr as string
connstr="DSN=****;uid=***;pwd=***"

.....

what do you suggest to make it more secure since the connection string is stored in the app.config.

I have tried using the rsaprotectedconfigurationprovider like what the msdn recommended...

Imports System
Imports System.Configuration


Public Class UsingRsaProtectedConfigurationProvider


' Protect the connectionStrings section.
Private Shared Sub ProtectConfiguration()

' Get the application configuration file.
Dim config As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)

' Define the Rsa provider name.
Dim provider As String = _
"RsaProtectedConfigurationProvider"

' Get the section to protect.
Dim connStrings As ConfigurationSection = _
config.ConnectionStrings

If Not (connStrings Is Nothing) Then
If Not connStrings.SectionInformation.IsProtected Then
If Not connStrings.ElementInformation.IsLocked Then
' Protect the section.

connStrings.SectionInformation.ProtectSection(provider)


connStrings.SectionInformation.ForceSave = True

config.Save(ConfigurationSaveMode.Full)

Console.WriteLine( _
"Section {0} is now protected by {1}", _
connStrings.SectionInformation.Name, _
connStrings.SectionInformation.ProtectionProvider.Name)

Else
Console.WriteLine( _
"Can't protect, section {0} is locked", _
connStrings.SectionInformation.Name)
End If
Else
Console.WriteLine( _
"Section {0} is already protected by {1}", _
connStrings.SectionInformation.Name, _
connStrings.SectionInformation.ProtectionProvider.Name)
End If

Else
Console.WriteLine( _
"Can't get the section {0}", _
connStrings.SectionInformation.Name)
End If
End Sub 'ProtectConfiguration



' Unprotect the connectionStrings section.
Private Shared Sub UnProtectConfiguration()

' Get the application configuration file.
Dim config As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)

' Get the section to unprotect.
Dim connStrings As ConfigurationSection = _
config.ConnectionStrings

If Not (connStrings Is Nothing) Then
If connStrings.SectionInformation.IsProtected Then
If Not connStrings.ElementInformation.IsLocked Then
' Unprotect the section.
connStrings.SectionInformation.UnprotectSection()

connStrings.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Full)

Console.WriteLine( _
"Section {0} is now unprotected.", _
connStrings.SectionInformation.Name)

Else
Console.WriteLine( _
"Can't unprotect, section {0} is locked", _
connStrings.SectionInformation.Name)
End If
Else
Console.WriteLine( _
"Section {0} is already unprotected.", _
connStrings.SectionInformation.Name)
End If

Else
Console.WriteLine( _
"Can't get the section {0}", _
connStrings.SectionInformation.Name)
End If
End Sub 'UnProtectConfiguration



Public Shared Sub Main(ByVal args() As String)

Dim selection As String = String.Empty

If args.Length = 0 Then
Console.WriteLine( _
"Select protect or unprotect")
Return
End If

selection = args(0).ToLower()

Select Case selection
Case "protect"
ProtectConfiguration()

Case "unprotect"
UnProtectConfiguration()

Case Else
Console.WriteLine( _
"Unknown selection")
End Select

Console.Read()
End Sub 'Main

End Class 'UsingRsaProtectedConfigurationProvider

but I can't find system.configuration.configuration and configurationmanager.
Also, i tried searching in the object browser the configurationmanager, and it says that its part of system.configuration, but still can't find it...Frown | :(
AnswerRe: How do you make a secure database connection string [modified] Pin
George L. Jackson15-Apr-07 2:12
George L. Jackson15-Apr-07 2:12 
GeneralRe: How do you make a secure database connection string Pin
dragon_15-Apr-07 19:05
dragon_15-Apr-07 19:05 
Questioni want code in vb.net to redirect the form [modified] Pin
karimullah14-Apr-07 16:38
karimullah14-Apr-07 16:38 
AnswerRe: i want code in vb.net to redirect the form Pin
Christian Graus14-Apr-07 22:25
protectorChristian Graus14-Apr-07 22:25 
QuestionWhat am I doing wrong? Pin
dunn1de14-Apr-07 14:56
dunn1de14-Apr-07 14:56 
AnswerRe: What am I doing wrong? Pin
Christian Graus14-Apr-07 22:28
protectorChristian Graus14-Apr-07 22:28 
QuestionZip Code To Lat Lon Conversion Pin
halflife26814-Apr-07 14:06
halflife26814-Apr-07 14:06 
AnswerRe: Zip Code To Lat Lon Conversion Pin
George L. Jackson14-Apr-07 15:13
George L. Jackson14-Apr-07 15:13 
QuestionMicrosoft Agent Control voice Pin
Aung.Myo.Aye14-Apr-07 7:25
Aung.Myo.Aye14-Apr-07 7:25 
AnswerRe: Microsoft Agent Control voice Pin
MatrixCoder14-Apr-07 8:19
MatrixCoder14-Apr-07 8:19 
AnswerRe: Microsoft Agent Control voice Pin
Dmitry Khudorozhkov14-Apr-07 8:25
Dmitry Khudorozhkov14-Apr-07 8:25 
QuestionCross-thread operation not valid Pin
RJGCarey14-Apr-07 6:23
RJGCarey14-Apr-07 6:23 
AnswerRe: Cross-thread operation not valid Pin
George L. Jackson14-Apr-07 9:19
George L. Jackson14-Apr-07 9:19 
QuestionGetting data back from a user control to a parent control Pin
steve_rm14-Apr-07 6:05
steve_rm14-Apr-07 6:05 
AnswerRe: Getting data back from a user control to a parent control Pin
Thomas Stockwell14-Apr-07 6:49
professionalThomas Stockwell14-Apr-07 6:49 
QuestionRe: Getting data back from a user control to a parent control Pin
steve_rm14-Apr-07 9:13
steve_rm14-Apr-07 9:13 
AnswerRe: Getting data back from a user control to a parent control Pin
Thomas Stockwell14-Apr-07 13:26
professionalThomas Stockwell14-Apr-07 13:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.