IIS ASP. NET connection SQL Server error resolution

  • 2020-05-10 17:55:49
  • OfStack

Another way to solve the connection problem is to enable SQL Server authentication in IIS, and then use the user ID and password in the connection string. Or when ASP.NET
When the application is run as another Windows user instead of ASPNET, use the ASP.NET impersonation method.
In order for the ASPNET account to access the database of the ASP.NET application, you need to complete the following steps:

1) start SQL Server Management Studio, specify SQL Server instance name, and login in Windows authentication mode.

2) add the Windows user to the SQL Server database using the grantlogin stored procedure. This numerology will be assigned to the ASPNET account
Access to SQL Server. Note that MachineName in the command is replaced with the host name of the machine.
Exec sp_grantlogin 'MachineName\ASPNET'

3) after giving the ASPNET account the right to link to SQL Server, you also need to give it access to the database of the ASP.NET application
Permissions. Note that DateBaseName is replaced by the name of the database for the ASP.NET application:
USE DateBaseName
Exec sp_grantdbaccess 'MachineName\ASPNET'

4) finally, you need to give ASPNET access to the database internal objects of the ASP.NET application, such as executing stored procedures, reading, and
Modify tables, etc. The easiest way is to assign an db_owner role to an ASPNET account for an ASP.NET application's database. If the previous step
To connect to the database of the ASP.NET application, enter the following command:
Exec sp_addrolemember 'db_owner','achineName\ASPNET'

You can now connect to the database from the Web application in Windows authentication mode.

Related articles: