2

I have a WCF service I want to use to access a SQL db (via Linq2SQL at the moment), but the trusted security in a live IIS environment doesn't seem to use the right credentials - I've tried to follow the related posts here, but can't seem to quite get it. I'd be really grateful if someone could spot my mistake ...

in the Endpoint config, I've set it up to use BasicHttpBinding, with the following configuration

<basicHttpBinding>
  <binding name="authHttpBinding">
    <security mode="TransportCredentialOnly">
      <transport clientCredentialType="Windows"/>
    </security>
  </binding>
</basicHttpBinding>

I've set the system.web settings to:

<authentication mode="Windows" />
<identity impersonate="true" />

on the IIS server, I've added a new AppPool, set the Identity to ApplicationPoolIdentity and ManagedPipeLine to Integrated. On the actual web application, set to my new AppPool, I've set Windows Authentication to "Enabled", and tried ASP.Net Impersonation on both enabled and disabled

When I try calling the WCF service, it runs, but when it makes an actual call to a stored proc via Linq2SQL (to a database on a remote server using Trusted Security), I get the following error: Login failed for user 'domain\ machinename$' - the machine name with a dollar sign at the end

which looks to me a lot like I've failed to delegate the correct identity (I can access the actual database fine through Management Studio.

4

2 回答 2

0

对的,这是可能的。在这种情况下,您需要确保您的安全设置设置为 Windows(这是默认设置)并确保您的服务已准备好进行模拟。您可以以编程方式或声明方式执行此操作。

您需要通过将适当的 ImpersonationOption 属性设置为 required 或 allowed 来指示 WCF 允许模拟所需的服务/方法。

[OperationBehavior(Impersonation=ImpersonationOption.Allowed)]

因为您正在通过网络访问资源,所以您需要确保将模拟级别设置为委托,而不是模拟,除非您正在访问的资源是本地的。这是在客户端端点行为级别设置的。

 <clientCredentials>
        <windows allowedImpersonationLevel="[Impersonation or Delegate]"/>
 </clientCredentials>
于 2010-08-11T07:57:49.663 回答
0

访问您的数据库不应该与您的 WCF 安全设置有任何关系。我将从您的绑定配置中删除安全设置以及 system.web 中的模拟设置。你不应该需要这些。

检查配置中的连接字符串设置,并确保如果您使用 Windows 集成安全性来访问您的数据库,则您对数据库具有正确的权限。IIS 将尝试使用应用程序池中配置的身份连接到您的数据库,因此您需要确保该帐户具有访问权限。如果您有指定用户,请确保您的凭据设置正确。ConnectionStrings.com 有各种如何正确设置的示例。

HTH。

史蒂夫

于 2010-08-10T07:04:09.203 回答