Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Webconfig. user password hard cord.

Posted on 2007-03-29
3
Medium Priority
?
884 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 1500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

721 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