This method focuses on extracting the connection string file from webroot for the source code version control system (e.g. svn).
Files:
c:\inetpub\config\config.xml
c:\inetpub\wwwroot\global.asa
c:\inetpub\wwwroot\onInit.asp
config.xml:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<database
ip="XXXX"
catalog="XXXX"
id="XXXX"
password="XXXX"
/>
</root>
global.asa:
<script runat="Server" language="VBScript">
Sub Application_OnStart()
server.execute("/onInit.asp")
End Sub
Sub Application_OnEnd()
End Sub
</script>
onInit.asp:
<%
dim xmlDoc, xmlPath, objNodes
set xmlDoc = server.CreateObject("microsoft.xmldom")
xmlDoc.async = false
xmlPath = Server.MapPath("/")
xmlPath = left(xmlPath, inStrRev(xmlPath, "\")) & "config\config.xml"
xmlDoc.load xmlPath
set objNodes = xmlDoc.selectNodes("//database")
application("connectionString") = "Provider=SQLOLEDB.1;Persist Security Info=True;"_
& "Data Source=" & objNodes.item(0).getAttribute("ip") & ";"_
& "Initial Catalog=" & objNodes.item(0).getAttribute("catalog") & ";"_
& "User ID=" & objNodes.item(0).getAttribute("id") & ";"_
& "Password=" & objNodes.item(0).getAttribute("password")
set objNodes = nothing
set xmlDoc = nothing
%>
source
share