IIS 7 and Above
enumerate connection strings
Last post May 08, 2019 10:34 PM by lextm
May 07, 2019 11:32 AM|briggirm|LINK
I wrote a vbscript to enumerate all the virtual directories of websites on our web server I have now been asked to add what databases the website are using to that script. In the GUI it's called the " Connection String " but , I can't find where that information
is stored. Does anyone know what object do I need to connect to and what is the name of the item that holds that information or is there any example code I can reference? Thank you for any help I can get it will be greatly appreciated.
May 07, 2019 09:07 PM|lextm|LINK
That data comes from the config folder of .NET Framework installation (machine.config and web.config). Due to the versions and bitness of .NET Framework in use, there can be tons of folders you need to analyze in your script.
May 08, 2019 02:27 PM|briggirm|LINK
Thank you for your response. I think I am not real clear with my question and I am not sure how to ask it. If you are using the GUI to manage websites there is a icon named " Connection String " if you go to that area it lists all the database associated
with that website, in some websites it lists only a single line but others it may list 4 or 5 lines of different servers and databases that that particular site uses. What I am trying to do is find where that information is stored for each website and output
that information with my script. I would think that the information would be stored with the each website since the information for the " Connection string " is unique for each website. I have also noticed if you traverse down the path returned from my script
that returned the path item not all websites have a machine.config or web.config file which make things more confussing because if you look in the GUI there is a " Connection String " showing.
May 08, 2019 10:34 PM|lextm|LINK
Then you probably should give up VBScript as it cannot parse the entire .NET Framework configuration system to query the connection strings.
With C# you can use Microsoft.Web.Administration API to query application level settings,
With the Configuration object returned, you can then query connectionStrings section,
PowerShell might be able to offer the same but I never try that.