共用方式為


UserNamePasswordClientCredential.UserName 屬性

定義

取得或設定使用者名稱。

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

屬性值

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 或空的。

適用於