共用方式為


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

屬性值

如果憑證對應到 Windows 帳戶,則為 true,否則為 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 帳戶。

適用於