MessageCredentialType 列舉
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
列舉有效訊息的認證類型。
public enum class MessageCredentialType
C#
public enum MessageCredentialType
type MessageCredentialType =
Public Enum 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");
Dim myServiceHost As New ServiceHost(GetType(CalculatorService))
' Create a binding to use.
Dim binding As 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")
這個列舉可用來指定驗證繫結時所要使用的認證類型。 除了使用 BasicHttpBinding 的 BasicHttpMessageCredentialType 之外,所有標準繫結都會用到它。
產品 | 版本 |
---|---|
.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 |