Solved

Webconfig. user password hard cord.

Posted on 2007-03-29
3
875 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Accepted Solution

by:
_TAD_ earned 500 total points
ID: 18816543
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
ID: 18816629
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
ID: 18816717
It is all good
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

617 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