UserNamePasswordClientCredential.UserName 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置用户名。
public:
property System::String ^ UserName { System::String ^ get(); void set(System::String ^ value); };
public string UserName { get; set; }
member this.UserName : string with get, set
Public Property UserName As String
属性值
用户名。
示例
若要获取或设置此属性,请访问客户端对象的 UserNamePasswordClientCredential 属性的 UserName 对象,如下面的代码所示。
WSHttpBinding myBinding = new WSHttpBinding();
myBinding.Security.Mode = SecurityMode.Message;
myBinding.Security.Message.ClientCredentialType =
MessageCredentialType.UserName;
CalculatorClient client = new CalculatorClient("default");
client.ClientCredentials.UserName.Password = ReturnPassword();
client.ClientCredentials.UserName.UserName = ReturnUsername();
Dim myBinding As New WSHttpBinding()
myBinding.Security.Mode = SecurityMode.Message
myBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName
Dim client As New CalculatorClient("default")
client.ClientCredentials.UserName.Password = ReturnPassword()
client.ClientCredentials.UserName.UserName = ReturnUsername()
注解
对于用户名/密码身份验证,此属性是需要的,并且不能为 null
或空。