I've got a WPF windows client that calls a WCF web service. The user is already logged in on the windows domain before starting the application and the WCF service uses windows authentication.
I want the WPF client to use the WindowsPrincipal of the already logged in user when calling the WCF service. I do NOT want to create a new NetworkCredential instance with an EXPLICIT username & password to do this, simply because asking the user to log in twice (in Windows and the app) is ... well pretty user unfriendly.
Most of the samples I've seen use this way to set the credentials, which is not what I want
serviceClientProxy.ClientCredentials.Windows.ClientCredential
= new NetworkCredential("username", "password", "domain");
Instead, I'd like to do something like this
serviceClientProxy.ClientCredentials.Windows.AllowedImpersonationLevel
= TokenImpersonationLevel.Identification;
serviceClientProxy.ClientCredentials.Windows.ClientCredential
= { /* network credential for already logged in user */ }
That is, I want a NetworkCredential for the already existing (and working)
new WindowsPrincipal(WindowsIdentity.GetCurrent())
Does anybody know how to do this? I've tried setting security mode = ""
and transport clientCredentialType = ""
in app.config, but so far to no avail.