Solved

Webconfig. user password hard cord.

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

14 Experts available now in Live!

Get 1:1 Help Now