ClientBase<TChannel>.ClientCredentials 属性

定义

获取用于调用操作的客户端凭据。

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> 对象用于连接服务的凭据。

适用于

另请参阅