title: How to verify a remote DSN entry?
body: <p>I am creating a verification utility that check various parts of an application to ensure they are configured correctly. One of the things I need to check is that the DSN entry in a Web.config file is a functional DSN, and that the DSN is pointing to the correct SQL server and database.</p>
  
  <p>Currently you can run the utility in one of two modes, local or remote. My problem occurs when I am trying to verify a remote systems DSN on my local computer. I know why it doesnt work, I don't have the same DSN on my local computer. So what I need to figure out is how to either retrieve the DSN connection information from a remote machine to which I have administrative access, or to get the remote machine to verify it for me.</p>
  
  <p>Any suggestions? Thanks!</p>
  
  <p><em>EDIT</em><br>
  So apparenty the DSN info is stored in the registry too!</p>
  
  <pre><code>oRegConn = new ConnectionOptions();
  oRegConn.Username = username;
  oRegConn.Password = password;
  scope = new ManagementScope(@"//" + servername + @"/root/default", oRegConn);
  registry = new ManagementClass(scope, new ManagementPath("StdRegProv"), null);
  
  inParams = registry.GetMethodParameters("GetStringValue");
  inParams["sSubKeyName"] = "SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources\\" + 
      dsnName;
  inParams["sValueName"] = "Server";
  
  outParams = registry.InvokeMethod("GetStringValue", inParams, null);
  server = outParams["sValue"].ToString();
  </code></pre>