PDA

View Full Version : چند تا سوال در مورد ASP.NET و MSSQL



C0NN3CT0R
چهارشنبه 16 شهریور 1390, 13:41 عصر
سلام

1. چطور میشه اطلاعات کد شده Connection Strings تو web.config رو خوند یا دیکد کرد :
مثال :

<add key="SQLRptUser" value="hrX2WJIk0Xy+Yu7FnDrPYzf4tw=="/>

2. یه روش برای مدیریت MSSQL دیتابیس می خوام ، مثلا با یه فایل ASP بتونم یوزر پسورد دیتابیس رو وارد کنم و مدیریت کنم دیتابیس رو

3. اگه نشه connection strings رو decrypt کرد آیا میشه از خود همینا با یه کد به دیتابیس وصل شد؟

تشکر

moferferi
پنج شنبه 17 شهریور 1390, 09:48 صبح
واسه کد کردن
Imports System.Configuration
Imports System.Web.Security
Public Sub Encrypt(ByVal protectionProvider As String)
'---open the web.config file
Dim config As Configuration = _
System.Web.Configuration. _
WebConfigurationManager.OpenWebConfiguration( _
Request.ApplicationPath)
'---indicate the section to protect
Dim section As ConfigurationSection = _
config.Sections("connectionStrings")
'---specify the protection provider
section.SectionInformation.ProtectSection(protecti onProvider)
'---Apple the protection and update
config.Save( )
End Sub


و واسه دیکد
Public Sub Decrypt( )
Dim config As Configuration = _
System.Web.Configuration. _
WebConfigurationManager.OpenWebConfiguration( _
Request.ApplicationPath)
Dim section As ConfigurationSection = _
config.Sections("connectionStrings")
section.SectionInformation.UnProtectSection( )
config.Save( )
End Sub