底层提供程序无法打开 [英] The underlying Provider failed to open

查看:71
本文介绍了底层提供程序无法打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在IIS 7上托管了我的WCF服务,数据库在同一台机器上。

WCF服务我有实体framework 4.0版本。

当我尝试通过它执行任何数据库操作时,我收到错误,因为

底层提供程序在Open上失败了。



我在应用程序池中进行了更改

我将应用程序的身份设置为本地系统,然后现在运行正常。





我想解决这个问题,因为该服务将在net.tcp协议上运行。



任何解决方案?

Hi,

I have hosted my WCF services on IIS 7, Database is On same machine.
WCF service i have Entity framework 4.0 version.
When I am trying to perform any database operation through it,I am getting error as
"The underlying provider failed on Open."

I made changes in Application Pool
I set the Identity of Application as Local system and then now its running fine.


I want to fix this as the service will be running on net.tcp protocol.

Any solution ?

推荐答案

如果我理解你在这个帖子上的所有内容,你的问题就是安全问题。



在你的 web.config 中,你可能有这样的连接字符串:

If I've understand everything you put on this thread, you problem is security related.

In your web.config, you probably have connection string like this:
<connectionStrings>
    <add name="MyDb" connectionString="data source=MyServer;initial catalog=MyDb;integrated security=True;" />
</connectionStrings>





其中集成安全性可以替换为 Trusted_Connection 。这告诉ADO.NET您希望运行Web应用程序的帐户连接到数据库。在IIS中创建新的应用程序池时,它使用默认帐户来运行Web应用程序。此帐户无权访问您的数据库,这就是连接失败的原因。


要解决此问题,您有两种选择。第一种是设置一个可以访问相关数据库的服务帐户。以下是一些帮助您解决此问题的链接。



访问IIS应用程序中的数据库 [ ^ ]

指定应用程序池的身份(IIS 7) [ ^ ]

创建数据库用户 [ ^ ]



您的下一个选项是创建一个SQL Server帐户,而不是像这样的网络帐户在上面的例子中。如果在安装SQL Server期间接受了所有默认设置,则会设置Windows身份验证,并且需要更改为混合身份验证。这将允许Windows帐户和SQL Server帐户。看看创建登录 [ ^ ],具体步骤5.如果你走这条路,你最终会使用这样的连接:



Where integrated security could be replaced with Trusted_Connection. This is telling ADO.NET that you want to the account the web application is running under to connect to the database. When you create a new application pool in IIS, it uses a default account to run your web application. This account does not have permissions to access your database and which is why the connection is failing.

To fix this, you have two options. The first is setup a service account that can access the database in question. Below are a few links to help you out with that.

Accessing Database in IIS Applications[^]
Specify an Identity for an Application Pool (IIS 7)[^]
Create Database User[^]

Your next option would be to create a SQL Server account, not a network account like in the examples above. If you accepted all of the defaults during the installation of SQL Server, then it setup for Windows Authentication and would need to be changed to Mixed Authentication. This will allow for both Windows accounts and SQL Server accounts. Take a look at Creat a Login[^] on the MSDN site, specifically step 5. If you go this route, you would end up with a connection like this:

<connectionStrings>
    <add name="MyDb" connectionString="data source=MyServer; initial catalog=MyDb; User Id=myUsername; Password=myPassword;" />
</connectionStrings>





首选方法往往是我给出的第一个选项。这使得密码不受开发人员的影响,并有助于保持应用程序的安全。如果你选择第二个选项,你真的应该考虑加密你的配置文件以保证密码的安全。



我希望这可以帮助你。



The preferred method tends to be the first option I gave. This leaves the password out of the hands of the developers and helps to keep the application secure. If you go with the second option, you really should look into encrypting your configuration files to keep the password safe.

I hope this helps you out.


这篇关于底层提供程序无法打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆