I'm calling a WCF service from a Windows service, and I'd like to authenticate the client through the Windows user that the service is running as.

For various reasons (streaming/SSL, mainly) I have to use anonymous authentication for transport credentials. Is there any way to send my WindowsIdentity through the message, the same way you would normally send ClientCredentials.Username.Username or ClientCredentials.Username.Password?

BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;    
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;            
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;      

ServerContractClient serverConnection = new ServerContractClient(binding, new EndpointAddress(url));

string username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
serverConnection.ClientCredentials = ???

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top