Answered by:
What the Difference between System.ServiceModel.Security.UserNamePasswordClientCredential and System.ServiceModel.Description.ClientCredentials

Question
-
Hello Everybody,
I am trying Client Credentials combinations and came across following problem.
Client Code looks like this:
Service1Client client = new Service1Client();
where,
public Service1Client()
: base("WSHttpBinding_IService1")
{
//case ****
System.ServiceModel.Security.UserNamePasswordClientCredential CCredentials = new System.ServiceModel.Security.UserNamePasswordClientCredential();
CCredentials.UserName = "test";
CCredentials.Password = "test";
base.ClientCredentials = CCredentials;
//If I DO this....It works....
// base.ClientCredentials.UserName.UserName = "test";
// base.ClientCredentials.UserName.Password = "test";
}
For case **** I get this error.
Error 3 Cannot implicitly convert type 'System.ServiceModel.Security.UserNamePasswordClientCredential' to 'System.ServiceModel.Description.ClientCredentials' D:\TEST_PM\SimpleService_AuthClient_book\AuthClient\Service1.cs 98 34 AuthClient
My Question is 1. why later case works and why earlier case **** doesn't work?
2. What the difference between System.ServiceModel.Security.UserNamePasswordClientCredential and System.ServiceModel.Description.ClientCredentials and where are the Credentials put in the Soap12 message for both the cases?
Thanks,
Kulbhushan
Monday, January 19, 2009 10:46 AM
Answers
-
Hi,
1) UserNamePasswordClientCredential is just a container class for the username and password strings used.
2) ClientCredentials is a container for all the client's credentials (for different types: X.509, Username, ...). However, ClientCredentials is more than that. It is also derives from the SecurityCredentialsManager abstract class, meaning that it is responsible for the creation of token providers, authenticators and serializers (see http://pfelix.wordpress.com/2008/08/04/security-tokens-in-wcf/ for more info). The ClientCredentials class contains properties for setting the credential info for all supported credentials types.So, the correct usage is to use the UserNamePasswordClientCredential instance referenced by the ClientCredentials in the client class.
HTH
Pedro Felix
pfelix.wordpress.com- Proposed as answer by Will.Rogers Monday, January 19, 2009 1:17 PM
- Marked as answer by Dan Glick - MSFT Monday, January 19, 2009 10:37 PM
Monday, January 19, 2009 11:37 AM
All replies
-
Hi,
1) UserNamePasswordClientCredential is just a container class for the username and password strings used.
2) ClientCredentials is a container for all the client's credentials (for different types: X.509, Username, ...). However, ClientCredentials is more than that. It is also derives from the SecurityCredentialsManager abstract class, meaning that it is responsible for the creation of token providers, authenticators and serializers (see http://pfelix.wordpress.com/2008/08/04/security-tokens-in-wcf/ for more info). The ClientCredentials class contains properties for setting the credential info for all supported credentials types.So, the correct usage is to use the UserNamePasswordClientCredential instance referenced by the ClientCredentials in the client class.
HTH
Pedro Felix
pfelix.wordpress.com- Proposed as answer by Will.Rogers Monday, January 19, 2009 1:17 PM
- Marked as answer by Dan Glick - MSFT Monday, January 19, 2009 10:37 PM
Monday, January 19, 2009 11:37 AM -
Thanks Pedro Felix. The link is informative. Yes I am using X509 certificate.
I will try to use the UserNamePasswordClientCredential instance referenced by the ClientCredentials in the client class.
Still I am in thinking process.
Thanks,
Kulbhushan
Monday, January 19, 2009 11:51 AM