我有我已经在web应用web.config中创造了以下配置WCF服务获取DefaultNetworkCredentials通过对WCF服务
<service name="RedwebServerManager.WebApplication.DesktopService"
behaviorConfiguration="ServBehave">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="basicBind"
contract="RedwebServerManager.WebApplication.IDesktopService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicBind">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
这种服务需要采取WindowsCredentials在一个获取信息基于认证用户的数据库。该服务目前有一个方法实现一个接口具有以下签名
[ServiceContract]
public interface IDesktopService
{
/// <summary>
/// Gets the clients.
/// </summary>
/// <returns>IEnumerable<ClientServiceModel>.</returns>
[OperationContract]
IEnumerable<ClientServiceModel> GetClients();
}
我有一个Windows窗体应用程序,它在消费WCF服务,我想使用的应用程序,因为这样会通过当前用户的凭据都在我们的领域。在app.config如下
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDesktopService">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://redwebservermanager.redweb.network/DesktopService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IDesktopService"
contract="ManagerService.IDesktopService" name="BasicHttpBinding_IDesktopService" />
</client>
</system.serviceModel>
如果我手动设置凭据的用户名和密码,一切正常,但是我一直在努力
managerService.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials
,这样我可以在传递当前用户的凭据,但我在GetClients()调用中不会设置用户名和密码的错误。
任何人都可以帮助我吗?我也尝试加入
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
该方法,但这没有什么区别。
我知道这听起来很愚蠢,但你有没有尝试过**并没有设置** ClientCredential'。我们使用'NetTcpBinding'来保证交通安全以及上述工作。 –