解决IIS7.5站点不能登录SQLEXPRESS

在IIS7站点中配置使用本地sqlexpress:

Data Source=.\SQLEXPRESS;Initial Catalog=demo_db;Integrated Security=True;

会遇到如下错误:

Cannot open database "demo_db" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\local.demo.cn'.

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 "demo_db" requested by the login.
The login failed.
Login failed for user 'IIS APPPOOL\local.demo.cn'.

在IIS7.5中应用程序池已经不是 'NT AUTHORITY\NETWORK SERVICE“,做如下修改:

1、修改站点对应用的应用程序池的Process Model --> Identity

由ApplicationPoolIdentity修改为NetworkService

2、用MSSM打开.\SQLEXPRESS,添加用户:

.\sqlexpress --> Security --> Logins --> NT AUTHORITY\NETWORK SERVICE

设置其User Mapping:

Users mapped to this login:选择目标数据库,Default Schema为dbo

Database role membership for : demo_db,选择角色db_owner

3、指定数据库owner用户

.\sqlexpress --> demo_db --> Sceurity --> Users --> 查看NT AUTHORITY\NETWORK SERVICE属性

选择:

Default schema: dbo

Schema owned by this user: db_owner

Database role membership: db_owner

4、重启应用程序池后生效。

posted @ 2011-08-24 11:05  chenjunbiao  阅读(568)  评论(0编辑  收藏  举报