MessageCredentialType 列舉

定義

列舉有效訊息的認證類型。

C#
public enum MessageCredentialType
繼承
MessageCredentialType

欄位

Certificate 3

使用憑證指定用戶端驗證。

IssuedToken 4

使用發行的權杖來指定用戶端驗證。

None 0

指定匿名驗證。

UserName 2

使用 UserName 來指定用戶端驗證。

Windows 1

使用 Windows 指定用戶端驗證。

範例

下列程式碼示範如何存取 ClientCredentialType 屬性並將其設定為這個列舉的成員。

C#
ServiceHost myServiceHost = new ServiceHost(typeof(CalculatorService));
// Create a binding to use.
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType =
    MessageCredentialType.Certificate;

// Set the client certificate.
myServiceHost.Credentials.ClientCertificate.SetCertificate(
    StoreLocation.CurrentUser,
    StoreName.My,
    X509FindType.FindBySubjectName,
    "client.com");

備註

這個列舉可用來指定驗證繫結時所要使用的認證類型。 除了使用 BasicHttpBindingBasicHttpMessageCredentialType 之外,所有標準繫結都會用到它。

適用於

產品 版本
.NET Core 1.0, Core 1.1
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
UWP 10.0