語言

X509ClientCertificateAuthentication.MapClientCertificateToWindowsAccount 屬性

定義

會取得或設定一個值,指示憑證是否映射到 Windows 帳號。

public:
 property bool MapClientCertificateToWindowsAccount { bool get(); void set(bool value); };
public bool MapClientCertificateToWindowsAccount { get; set; }
member this.MapClientCertificateToWindowsAccount : bool with get, set
Public Property MapClientCertificateToWindowsAccount As Boolean

屬性值

true如果憑證對應到 Windows 帳號;否則,。 false 預設值為 false。

例外狀況

set 當憑證為唯讀時。

範例

以下程式碼說明如何設定這個屬性。

// Create a service host.
Uri httpUri = new Uri("http://localhost/Calculator");
ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);

// Create a binding that uses Windows security.
WSHttpBinding b = new WSHttpBinding(SecurityMode.Message);
b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;

// Get a reference to the authentication object.
X509ClientCertificateAuthentication myAuthProperties =
    sh.Credentials.ClientCertificate.Authentication;
// Configure IncludeWindowsGroups.
myAuthProperties.IncludeWindowsGroups = true;
' Create a service host.
Dim httpUri As New Uri("http://localhost/Calculator")
Dim sh As New ServiceHost(GetType(Calculator), httpUri)

' Create a binding that uses Windows security.
Dim b As New WSHttpBinding(SecurityMode.Message)
b.Security.Message.ClientCredentialType = MessageCredentialType.Windows

' Get a reference to the authentication object.
Dim myAuthProperties As X509ClientCertificateAuthentication = _
sh.Credentials.ClientCertificate.Authentication
' Configure IncludeWindowsGroups.
myAuthProperties.IncludeWindowsGroups = True

這個屬性也可以在設定檔中設定。

<serviceCredentials>
  <clientCertificate>
     <authentication mapClientCertificateToWindowsAccount='true'/>
  </clientCertificate>
</serviceCredentials>

備註

當在綁定中使用憑證客戶端憑證類型時,憑證並不會映射到 Windows 帳號。 你可以用這個屬性來覆寫這個行為。 當此屬性設定為 true時,客戶端憑證的身份會被映射到 Windows 帳號。

適用於