Need some explaination of CredentialCache.DefaultCredentials

  • Thread starter Thread starter Roy Chastain
  • Start date Start date
R

Roy Chastain

I have two client applications. They both use remoting to access the same server that is hosted in IIS.

One of the clients is started as a zero-touch install by clicking its link on a web page. The other client is installed on the
client system and attempts to use the remote server.

I have the same code to create the remote channel in both clients.

ListDictionary channelProps = new ListDictionary();
channelProps.Add("port", 0);
channelProps.Add("useDefaultCredentials", true);
channelProps["credentials"] = CredentialCache.DefaultCredentials;
SoapServerFormatterSinkProvider serverProvider = new SoapServerFormatterSinkProvider();
HttpChannel hc = new HttpChannel(channelProps, new SoapClientFormatterSinkProvider(), serverProvider);


Notice the use of useDefaultCredentials and the setting of credentials to CredentialCache.DefaultCredentials.

This code works fine in the client that is loaded and run from the web page. It does not work from the client that is installed
on the client system. The problem when run from the installed client is that the remote object returns a 401 not authorized.

If I remove the line
channelProps["credentials"] = CredentialCache.DefaultCredentials;
from the installed client, it too works.

I don't really know enough about this to understand the full ramifications of what I have just done. My guess is as follows

Since the download and run client works, I am assuming that IE did authentication and produced the cached DefaultCredentials for
me and that has not happened when I run the installed client.

My question is
1) - Can any provide more information about what is going on?
2) - Is there any reason that I would not want to just remove the same line of code in the download and run client also?
3) - Eventually I am going to need a LOCAL service (hopefully running under SYSTEM) to connect to the server (local on the same
system) but the server will need to be able to authenticate it in some manner. What would I need to do in that case?

Thanks
 
Back
Top