在主机上运行网站时出现错误。无法为以下应用程序打开数据库连接。消息:无法打开登录请求的数据库“ VRM”。登录失败。用户登录失败用户'IIS APPPOOL \ DefaultAppPool'登录失败。
null
答案 0 :(得分:0)
查看您的连接字符串,或者将它们都更改为Username / password auth,或者授予该帐户访问目标数据库的权限。您可以使用以下脚本配置访问权限,该脚本将授予应用程序池标识对目标数据库的完全控制权:
use vrm
create login [IIS APPPOOL\DefaultAppPool] from windows
create user [IIS APPPOOL\DefaultAppPool] for login [IIS APPPOOL\DefaultAppPool]
grant control to [IIS APPPOOL\DefaultAppPool]
您可以使用SQL Server Management Studio或sqlcmd.exe命令行工具连接到SQL Server之后运行脚本。
对于生产应用程序,您希望限制授予该应用程序标识的权限。这将有助于防止SQL注入漏洞。 EG
use vrm
create login [IIS APPPOOL\DefaultAppPool] from windows
create user [IIS APPPOOL\DefaultAppPool] for login [IIS APPPOOL\DefaultAppPool]
create role AppUser
grant select, execute, insert, update, delete on schema::dbo to AppUser
alter role AppUser add member [IIS APPPOOL\DefaultAppPool]