Solved

Webconfig. user password hard cord.

Posted on 2007-03-29
3
854 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
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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