Let's assume you have service application runs on a computer which is part of a domain and a client application runs on a computer which is not part of any domain and you want to use that service (Simple example can be found on MSDN, WinFx :Net TCP Sample ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.WinFX4VS.1033/WCF_samples/html/e8475fe6-0ecd-407a-8e7e-45860561bb74.htm)
Obviously it would not work, but the problem is even if you add client credentials to the client application, still it does not work! Why
static void Main()
{
// Create a proxy with given client endpoint configuration
using (CalculatorProxy proxy = new CalculatorProxy())
{
//proxy.ClientCredentials.Windows.ImpersonationLevel = TokenImpersonationLevel.Impersonation;
proxy.ClientCredentials.Windows.ClientCredential.Domain = "Domain1";
proxy.ClientCredentials.Windows.ClientCredential.UserName = "User1";
proxy.ClientCredentials.Windows.ClientCredential.Password = "Password1";

NetTcpBinding, Windows security
__ David Zorin
Bijan,
I'm afraid this is a bug in the NetworkCredential class. If you do the following
proxy.ClientCredentials.Windows.ClientCredential = new NetworkCredential ( "User1", "Password1", "Domain1" );
then it should work.
We're hoping to address this bug sometime before release.
Regards
Gudge
Canman2
Hi Bijan,
there is an issue with default NetworkCredentials in .NET. Setting individual properties does not change the way the client authenticates to the service. It will use the process identity all the time. The only way how to change ClientCredentials.Windows.ClientCredential is by creating a new instance of NetworkCredential class and setting it on ClientCredentials.Windows instance. Something like this:
proxy.ClientCredentials.Windows.ClientCredential = new NetworkCredential("User1", "Password1", "Domain1");
should do the work for you.
We are considering to change the way we expose the default ClientCredential on WindowsClientCredential to avoid this issue to surface.
Thanks,
--Jan