Solved

Webconfig. user password hard cord.

Posted on 2007-03-29
3
837 Views
Last Modified: 2007-11-27
Old asp classic
'******************************************************************
' Constants
'******************************************************************
Const IIS_USERNAME = "IISIntranet"
Const IIS_PASSWORD = "iisintranet"

ParamConnectionString = "Provider=SQLOLEDB.1;Password=IISintranet;Persist Security Info=True;User ID=IISintranet;Initial Catalog=PARAM_TWD;Data Source=MTLDB1\INST2000"
-------------------------------------------------------------------------------------------------
I need to define the user name and password dynamicly
IIS_USERNAME = "IISIntranet"
IIS_PASSWORD = "iisintranet"
in the web config.
<add name="ParamConnectionString " connectionString="Data Source=MTLDEVDB1\INST2000;Initial Catalog=GLOBAL_APPS;User ID=;Password=" providerName="System.Data.SqlClient"/>

This is my current webconfig
-----------------------------------
<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      <!--
    DATACONFIGURATION SETTINGS
    This section is the configuration parameters used by the data application block assemblies.
    Two environment are defined here, DevConfigServer and ProdConfigServer.
    The application is using the defaultDatabase value as it's value to connect to configuration data.
    When deploying to a Production environment, simply change the defaultDatabase value to ProdConfigServer.
    You can do it here manually or by opening this file (web.config) using the Enterprise Library Configuration Tool.
  -->
      <configSections>
            <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
      </configSections>
      <appSettings>
            <!--
    The HomeUrl app setting is used to redirect to the root web
    site of the application. This must be changed when deploying
    on a production or anyother web server to point on the
    correct web root.
    -->
            <add key="HomeUrl" value="http://DevIntranet/"/>
            <!--
    The Divisions app setting HAS to be separated by semicolons if
    more than one value.
        -->
            <add key="Divisions" value="3;5"/>
            <add key="CrystalImageCleaner-AutoStart" value="true"/>
            <add key="CrystalImageCleaner-Sleep" value="60000"/>
            <add key="CrystalImageCleaner-Age" value="120000"/>
      </appSettings>
      <dataConfiguration defaultDatabase="DevConfigServer"/>
      <connectionStrings>
            <add name="DevConfigServer" connectionString="Data Source=MTLDEVDB1\INST2000;Initial Catalog=GLOBAL_APPS;User ID=IISintranet;Password=iisintranet" providerName="System.Data.SqlClient"/>
            <add name="ProdConfigServer" connectionString="Data Source=Mtldb1\inst2000;Initial Catalog=GLOBAL_APPS;User ID=USR_CUST_LIST;Password=!@#mkt0003$%^" providerName="System.Data.SqlClient"/>
            <add name="GLOBAL_APPSConnectionString" connectionString="Data Source=MTLDEVDB1\INST2000;Initial Catalog=GLOBAL_APPS;User ID=USR_CUST_LIST;Password=!@#mkt0003$%^" providerName="System.Data.SqlClient"/>
      </connectionStrings>
      <!--
    END OF DATA CONFIGURATION
  -->
      <system.web>
            <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions
            where data loss can occur.
            Set explicit="true" to force declaration of all variables.
        -->
            <compilation debug="true" strict="false" explicit="true">
                  <assemblies>
                        <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="Accessibility, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="System.Runtime.Serialization.Formatters.Soap, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="System.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                        <add assembly="CrystalDecisions.CrystalReports.Engine, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                        <add assembly="CrystalDecisions.ReportSource, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                        <add assembly="CrystalDecisions.Shared, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                        <add assembly="CrystalDecisions.Web, Version=11.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
                        <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                        <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
            </compilation>
            <pages>
                  <namespaces>
                        <clear/>
                        <add namespace="System"/>
                        <add namespace="System.Collections"/>
                        <add namespace="System.Collections.Specialized"/>
                        <add namespace="System.Configuration"/>
                        <add namespace="System.Text"/>
                        <add namespace="System.Text.RegularExpressions"/>
                        <add namespace="System.Web"/>
                        <add namespace="System.Web.Caching"/>
                        <add namespace="System.Web.SessionState"/>
                        <add namespace="System.Web.Security"/>
                        <add namespace="System.Web.Profile"/>
                        <add namespace="System.Web.UI"/>
                        <add namespace="System.Web.UI.WebControls"/>
                        <add namespace="System.Web.UI.WebControls.WebParts"/>
                        <add namespace="System.Web.UI.HtmlControls"/>
                  </namespaces>
            </pages>
            <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
            <authentication mode="Windows"/>
            <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
      </system.web>
</configuration>



            
0
Comment
Question by:mathieu_cupryk
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
_TAD_ earned 500 total points
Comment Utility
In your new web.config file

change the following:
      </system.web>
</configuration>

to:

      </system.web>
      <appSettings>
           <add key="userID" value="IISADMIN" />
           <add key="password" value="myPassword" />
      </appSettings>
</configuration>


Then in your code-behind you can read/edit this value.
ConfigurationSettings.AppSettings["userID"] = "Bob";
ConfigurationSettings.AppSettings["password"] = "BobsPwd";


http://www.odetocode.com/Articles/345.aspx
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
I have this now:

but I want to build a connection string

<appSettings>
            <!--
    The HomeUrl app setting is used to redirect to the root web
    site of the application. This must be changed when deploying
    on a production or anyother web server to point on the
    correct web root.
    -->
            <add key="HomeUrl" value="http://DevIntranet/"/>
            <!--
    The Divisions app setting HAS to be separated by semicolons if
    more than one value.
        -->
            <add key="Divisions" value="3;5"/>
            <add key="CrystalImageCleaner-AutoStart" value="true"/>
            <add key="CrystalImageCleaner-Sleep" value="60000"/>
            <add key="CrystalImageCleaner-Age" value="120000"/>
    <add key="userID" value="IISIntranet" />
    <add key="password" value="iisintranet" />
  </appSettings>


connectionStrings>
            <add name="DevConfigServer" connectionString="Data Source=MTLDEVDB1\INST2000;Initial Catalog=;UserID;Password;" providerName="System.Data.SqlClient"/>
          </connectionStrings>

How do I set the Initial Catalog as well ?
0
 

Author Comment

by:mathieu_cupryk
Comment Utility
It is all good
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now