?
Solved

Webconfig error.

Posted on 2007-12-02
3
Medium Priority
?
413 Views
Last Modified: 2013-11-07
I thought it might be a database error. Now I think it is a web.config.
Server Error in '/Cms' Application.
--------------------------------------------------------------------------------

Cannot open database "CMS" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database "CMS" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.



<?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">
  <appSettings>
    <add key="FCKeditor:UserFilesPath" value="/Cms/UserFiles"/>
  </appSettings>
  <connectionStrings>
     <add name="Cms" connectionString="Data Source=Quincy;Initial Catalog=CMS;Integrated Security=True;" providerName="System.Data.SqlClient" />
    </connectionStrings>
  <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" />
 
    <roleManager defaultProvider="SqlProvider"
        enabled="true"
        cacheRolesInCookie="true"
        cookieName=".ASPROLES"
        cookieTimeout="30"
        cookiePath="/"
        cookieRequireSSL="false"
        cookieSlidingExpiration="true"
        cookieProtection="All" >
      <providers>
        <add
          name="SqlProvider"
          type="System.Web.Security.SqlRoleProvider"
          connectionStringName="Cms" />
      </providers>
    </roleManager>
 
    <membership defaultProvider="SqlProvider">
      <providers>
        <add name="SqlProvider"
            type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
            connectionStringName="Cms"
            enablePasswordRetrieval="false"
            enablePasswordReset="true"
            requiresQuestionAndAnswer="true"
            applicationName="/"
            requiresUniqueEmail="false"
            passwordFormat="Hashed"
            maxInvalidPasswordAttempts="5"
            passwordAttemptWindow="10"
            passwordStrengthRegularExpression="" />
      </providers>
    </membership>
 
    <authentication mode="Forms">
      <forms loginUrl="~/Login.aspx" />
    </authentication>
    
    <authorization>
      <allow users="*"/>
    </authorization>
 
    <pages theme="Cms">
      <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. 
        -->
    <!--
            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>
 
  <location path="Management">
    <system.web>
      <authorization>
        <allow roles="Administrator" />
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
</configuration>

Open in new window

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
3 Comments
 
LVL 16

Accepted Solution

by:
TSmooth earned 1000 total points
ID: 20393386
Your connection string is using integrated security but you don't have impersonation in use so the account that asp.net runs as (Network Service in your case) is trying to connect to the database but doesn't have permission to. You can fix this by either:

1.) Give Network service permission to the database.
2.) Create a SQL Server login and have your connection string use that instead of integrated security/windows authentication.
3.) Enable impersonation on your website so that the asp.net service runs as a specific account or namely, the account that the user accessing the site is logged in as. This option will generally only work for you in an intranet environment.
0
 

Expert Comment

by:moradashraf
ID: 20394765
try this

go to IIS --> your Web Site properties --> ASP.NET tab --> Change ASP.NET version to 1.1 and then change back to 2.0.

0
 

Author Closing Comment

by:mathieu_cupryk
ID: 31412249
This works ok. Thanks bud.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
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…
Suggested Courses

770 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