Database WCF服务未模拟客户端
物流: 1台运行WCF服务的服务器。 1台运行WCF服务数据库的服务器 问题: 我在一台服务器上运行了一个WCF服务,它连接到一个单独的服务器,以获取需要检索的必要数据。我的问题是,当从客户端计算机调用服务时,我收到一个数据库sql错误,指出“用户“NT AUTHORITY\ANONYMOUS LOGON”登录失败”。我相信我已经将WCF服务设置为使用模拟 WCF服务器配置:Database WCF服务未模拟客户端,database,wcf,impersonation,Database,Wcf,Impersonation,物流: 1台运行WCF服务的服务器。 1台运行WCF服务数据库的服务器 问题: 我在一台服务器上运行了一个WCF服务,它连接到一个单独的服务器,以获取需要检索的必要数据。我的问题是,当从客户端计算机调用服务时,我收到一个数据库sql错误,指出“用户“NT AUTHORITY\ANONYMOUS LOGON”登录失败”。我相信我已经将WCF服务设置为使用模拟 WCF服务器配置: <bindings> <ws2007HttpBinding> <binding
<bindings>
<ws2007HttpBinding>
<binding maxReceivedMessageSize="214748">
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="Windows" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</ws2007HttpBinding>
</bindings>
<services>
<service behaviorConfiguration="Host.ServiceBehavior" name="Wcf.MyWebService">
<endpoint address="" behaviorConfiguration=""
binding="ws2007HttpBinding" contract="Wcf.MyWebServiceSoap">
<identity>
<servicePrincipalName value="ServerMachineName" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Host.ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization impersonateCallerForAllOperations="true" />
</behavior>
</serviceBehaviors>
</behaviors>
客户端配置和代码:
我正在编程设置以下配置项:
public void TestWebMethod()
{
WS2007HttpBinding binding = new WS2007HttpBinding();
EndpointAddress endpoint = new EndpointAddress("uri");
ServiceClient client = new ServiceClient(binding, endpoint);
client.ClientCredentials.Windows.AllowedImpersonationLevel =
TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.AllowNtlm = true;
string result = client.TestWebMethod();
client.Close();
}
模拟允许服务访问服务的本地资源,但不允许服务访问外部资源(例如,另一个服务)
必须将允许的模拟级别设置为TokenImpersonationLevel.Delegation
我想我已经试着把它改成了授权,但没有成功。但我会再试一试。服务和客户端的配置项看起来正确吗?我在服务端添加了一些代码来记录调用方法时进入的模拟级别。我已经在客户端上将AllowedImpersonationLevel设置为Delegation,但是日志显示它仍然设置为Impersonation。我仍然无法登录数据库。
public void TestWebMethod()
{
WS2007HttpBinding binding = new WS2007HttpBinding();
EndpointAddress endpoint = new EndpointAddress("uri");
ServiceClient client = new ServiceClient(binding, endpoint);
client.ClientCredentials.Windows.AllowedImpersonationLevel =
TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.AllowNtlm = true;
string result = client.TestWebMethod();
client.Close();
}
client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Delegation;