How to solve the login failed for user: "accountname" error

Source: Internet
Author: User

I believe many of my friends will write ASP. NET again.ProgramI have encountered this problem since vs. NET 2005 was used. First, I usually use the Web server provided by vs. Net for debugging, so I don't need to consider these things at all. Second, because SQL authentication is used when I write a program. Therefore, this situation is rare even when it is put on IIS. However, if IIS is used for debugging on the local machine and Windows authentication is used, this error will occur.

The following are basic solutions from Microsoft Knowledge Base:

 

Symptoms

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

Login Failed for user 'machinename \ ASPnet (and above iis5.x, the ASP. Net user is 'your machine name \ aspnet ')

For computers that run Internet Information Services (IIS) 6.0, you may receive the following error message:

Login Failed for user 'nt Authority \ Network Service' (on IIS 6.0, ASP. NET is called Network Service)

NoteYou receive either of these error messages specifically when you use integrated security (when you includeIntegrated Security = sspiAttribute in a connection string ).

 

Resolution

To resolve this issue, use one of the following methods:

Method 1Programmatically change the security context of the ASP. net worker process to a user who has the correct SQL Server permissions.

Method 2Change the default configuration of ASP. NET so that the ASP. net worker process starts and runs under the context of a user who has the correct permissions in SQL Server.

Method 3Grant the correct permissions in SQL server so that the ASPNET account (or NetworkService account, for an application that runs on IIS 6.0) has the appropriate access to the required resources.
NoteThis method will make all the web applications on the server have the corresponding right on the computer that is running SQL Server.

 

The simplest way is to open SQL Server, add a window login, And put ASP.. Net account added. For convenience, I will give this user the db_owner permission. Of course, you can also give db_creator, but since it is a standalone debugging, I think it's best to make it easier.

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.