ClientBase<TChannel>.ClientCredentials 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取用于调用操作的客户端凭据。
public:
property System::ServiceModel::Description::ClientCredentials ^ ClientCredentials { System::ServiceModel::Description::ClientCredentials ^ get(); };
public System.ServiceModel.Description.ClientCredentials ClientCredentials { get; }
member this.ClientCredentials : System.ServiceModel.Description.ClientCredentials
Public ReadOnly Property ClientCredentials As ClientCredentials
属性值
客户端提供的身份证明。
示例
下面的代码演示如何使用 ClientCredentials 属性在调用服务之前设置用户名和密码。
// Specify client credentials on the client.
// Code to set the UserName and Password is not shown here.
CalculatorClient CalculatorClient = new CalculatorClient("myBinding");
CalculatorClient.ClientCredentials.UserName.UserName = ReturnUserName();
CalculatorClient.ClientCredentials.UserName.Password = ReturnPassword();
' Specify client credentials on the client.
' Code to set the UserName and Password is not shown here.
Dim CalculatorClient As New CalculatorClient("myBinding")
CalculatorClient.ClientCredentials.UserName.UserName = ReturnUserName()
CalculatorClient.ClientCredentials.UserName.Password = ReturnPassword()
注解
使用 ClientCredentials 属性可以配置 ClientBase<TChannel> 对象用于连接服务的凭据。