当前位置: 首页 > 编程语言 > C#

将Windows凭据传递给远程https WCF服务分享

时间:2023-04-11 02:24:33 C#

C#学习教程:将Windows凭据传递给远程httpsWCF服务在IIS中,仅对这些服务启用Windows身份验证,并通过https运行。服务器端配置是:在客户端:我试图以这种方式使用服务:Client=newMyServiceClient();BasicHttpBinding绑定=newBasicHttpBinding(BasicHttpSecurityMode.Transport);binding.Security.Transport.ClientCredentialType=HttpClientCredentialType.Windows;绑定。MaxReceivedMessageSize=int.MaxValue;binding.MaxBufferPoolSize=long.MaxValue;binding.MaxBufferSize=int.MaxValue;EndpointAddressep=newEndpointAddress("https://myserver.net:4343/MyService.svc");Client=newCOMINTSServiceClient(绑定,ep);Client.ClientCredentials.Windows.AllowedImpersonationLevel=System.Security.Principal.TokenImpersonationLevel.Identification;Client.ClientCredentials.Windows.ClientCredential=System.Net.CredentialCache.DefaultNetworkCredentials;客户端.打开();Array[]obj=Client.RandomMethod();此代码对我不起作用:Client.ClientCredentials.Windows.AllowedImpersonationLevel=System.Security.Principal.TokenImpersonationLevel.Identification;客户.ClientCredentials.Windows.ClientCredential=System.Net.CredentialCache.DefaultNetworkCredentials;在服务中,当询问使用ServiceSecurityContext.Current.WindowsIdentity.Name调用服务的用户时,我总是得到:ISSAPPPOOLASP.NETv4.0而不是使其工作的唯一方法是写入用户名和密码而不是DefaultNetworkCredentialsClient.ClientCredentials.Windows.ClientCredential.UserName="DOMAIN\user";Client.ClientCredentials.Windows.ClientCredential.Password="密码";但我不想对用户/密码进行硬编码。有帮助吗?尝试:Client.ClientCredentials.Windows.AllowedImpersonationLevel=System.Security.Principal.TokenImpersonationLevel.Impersonation;保留CredentialCache作业。以上就是C#学习教程的全部内容:将Windows凭据传递给远程httpsWCF服务。如果对你有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处: