The following error message is displayed when you create a trusted data connection from ASP. NET to SQL SERVER: "Login Failed for user: 'accountname '"

Source: Internet
Author: User
Tags sql server books
**************************************** *************************************

There is no problem with running the local machine, but this error is reported when it is published to the server. Then we can delete "Integrated Security = sspi", but I don't know why, please give me some advice !!

**************************************** *************************************

Symptom

Cause

Solution

Status

More information

Steps to reproduce the problem

Reference


Symptom

When creating a trusted connection from Microsoft ASP. NET to Microsoft SQL Server, you may receive the following error message:

User 'machine ename \ ASPnet Login Failed

For computers running Internet Information Service (IIS) 6.0, you may receive the following error message:

User 'nt Authority \ Network service' Login Failed

Note:: Especially when using integrated security (includingIntegrated Security = sspiProperty), one of the above two error messages will be received.

Back to Top

Cause

Use ASP. net, for aspnet_wp.exe (or for applications running on IIS 6.0, w3wp.exe) and requests sent to SQL Server, the default security context is an ASPNET account (or NetworkService account for applications running on IIS 6.0 ). By default, the ASPNET account (or NetworkService account for applications running on IIS 6.0) does not have any permissions on SQL Server, so it cannot access the database.

Back to Top

Solution

To solve this problem, use one of the following methods:

Method 1Programmatically change the security context of the ASP. net workflow to a user with the correct SQL Server permissions.
Method 2Modify the default configuration of ASP. NET so that the ASP. net workflow can start and run in the context of a user who meets the following conditions: the user has the correct permissions in SQL Server.
Method 3Grant the correct permissions on SQL server so that the ASPNET account (or NetworkService account for applications running on IIS 6.0) has the appropriate permissions to access the required resources.

Note:: This method enables all web applications on the server to have the relevant permissions on the computer on which SQL server is running.

Back to Top

Status

This is caused by design.

Back to Top

More information

Steps to reproduce the problem


1. Create a new Microsoft Visual Basic. NET web application on the computer that runs both ASP. NET and SQL Server.
2. Add the following code to the webform1.aspx page created using this projectPage_loadEvent:

Dim con As New System.Data.SqlClient.SqlConnection("data source=localhost;integrated security=sspi;database=northwind")            con.open()            con.close()

3. Generate the project and open the webform1.aspx page in the browser.
4. You will receive the error message mentioned in the "symptoms" section.

Back to Top

Reference

For more information about how to programmatically change the security context of an ASP. NET workflow, click the following article number to view the article in the Microsoft Knowledge Base:

306158 (http://support.microsoft.com/kb/306158/) How in ASP. NET application implementation simulation 307002 (http://support.microsoft.com/kb/307002/) PRB: ASP/ODBC/SQL Server "login failed for user '(null)'" (User '(null)' Login Failed) error 0x80040e4d 253500 (http://support.microsoft.com/kb/253500/) PRB: "client unable to establish connection" (client cannot establish connection) error message 306586 (http://support.microsoft.com/kb/306586/) PRB: troubleshooting 80004005 (http://support.microsoft.com/kb/247931/) connection to the authentication method used by SQL server on the Active Server Page with the error 247931 Login Failed (Login Failed) in ASP 315158 (http://support.microsoft.com/kb/315158/) fix: ASP. net on Domain Controller with default ASPNET account does not run properly 824308 (http://support.microsoft.com/kb/824308/) BUG: on Windows 2000 Domain Controller installed with SP4, IWAM account is not granted to ASP. NET 1.1 simulated Permissions

For more information about how to change the default configuration of ASP. NET security context, visit the following Microsoft Developer Network (msdn) Website:

Http://msdn2.microsoft.com/en-us/library/ms978378.aspx (http://msdn2.microsoft.com/en-us/library/ms978378.aspx)

For more information about how to add an ASPNET account to SQL Server, see the "add a Windows user or group" topic in SQL Server books online.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.