How can I set ClientCredentials?

后端 未结 1 1770
情书的邮戳
情书的邮戳 2020-12-16 14:05

I\'m trying to consume a WCF service:

The config of the service is:



        
相关标签:
1条回答
  • 2020-12-16 14:52

    As @Paciv noted in a comment, you can do this through code. Set them with the property ClientCredentials.Windows, something like this:

    _client.ClientCredentials.Windows.ClientCredential.Domain = "warzone42";
    _client.ClientCredentials.Windows.ClientCredential.UserName = "user1428798";
    _client.ClientCredentials.Windows.ClientCredential.Password = "p@ssw0rd";
    

    Setting the credentials in code is of course unwise. If you don't set the Windows user programmatically as above, I believe the credentials from the user running the client are sent accross (which is perhaps a more typical situation?).

    Note that if you're setting credentials in code you may in fact be looking for UserName authentication.

    0 讨论(0)
提交回复
热议问题