简体   繁体   English

ASP.net应用程序无法连接到SQL Server 2005数据库

[英]ASP.net application can't connect to sql server 2005 database

Here is the scenario: 这是场景:

IIS 6 and SQL Server 2005 on same machine: IIS 6和SQL Server 2005在同一台计算机上:

I have just created a new application inside of my main website in IIS. 我刚刚在IIS的主要网站内创建了一个新应用程序。

The root website has its own database. 根网站拥有自己的数据库。 The application I just created under the root site has its own database, as well. 我刚刚在根站点下创建的应用程序也具有自己的数据库。

ASP.net pages in the root site connect to their database using trusted security. 根站点中的ASP.net页使用受信任的安全性连接到其数据库。 This web site is running in the default app pool which uses Windows' Network Service account. 该网站在使用Windows的网络服务帐户的默认应用程序池中运行。

The new application I just created is using that same app pool. 我刚刚创建的新应用程序正在使用相同的应用程序池。

I added the network service account to the new application's database's users and granted db_owner, just like the root site's db is set up. 我将网络服务帐户添加到了新应用程序数据库的用户中,并授予了db_owner,就像设置了根站点的db一样。 When I try to run my new application I get this error: 当我尝试运行新应用程序时,出现以下错误:

Login failed for user ''. 用户“”登录失败。 The user is not associated with a trusted SQL Server connection. 该用户未与受信任的SQL Server连接相关联。

When I switch the new app's connection string to use the sql server sa account, it works. 当我切换新应用程序的连接字符串以使用sql server sa帐户时,它可以工作。 I do not want to use the SA account. 我不想使用SA帐户。

I cannot figure this out! 我无法弄清楚! Please help. 请帮忙。

By default IIS will try to use an ASPNET account which needs to be granted access to SQL Server. 默认情况下,IIS将尝试使用需要被授予对SQL Server的访问权限的ASPNET帐户。 I don't have a setup anymore to describe this but the following link offers a couple of solutions: 我没有安装程序来描述这一点,但是以下链接提供了一些解决方案:

bytes.com/groups/net-asp/290050-setting-up-integrated-security-sql-server bytes.com/groups/net-asp/290050-setting-up-integrated-security-sql-server

听起来数据库希望使用SQL身份验证而不是Windows身份验证。

在这种情况下,您必须将登录名作为用户添加到要使用的数据库中,并提供适当的权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM