共用方式為


X509ClientCertificateAuthentication.IncludeWindowsGroups 屬性

定義

取得或設定值,這個值會指出 Windows 群組是否包含在授權內容中。

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

屬性值

Boolean

如果 Windows 群組包含在授權內容中,則為 true,否則為 false。 預設為 true

範例

下列程式碼將示範如何設定這個屬性。

// Create a service host.
Uri httpUri = new Uri("http://localhost/Calculator");
ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);
// Create a binding that uses a certificate.
WSHttpBinding b = new WSHttpBinding(SecurityMode.Message);
b.Security.Message.ClientCredentialType =
    MessageCredentialType.Certificate;

// 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 a certificate.
Dim b As New WSHttpBinding(SecurityMode.Message)
b.Security.Message.ClientCredentialType = MessageCredentialType.Certificate


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

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

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

備註

這個屬性只在 MapClientCertificateToWindowsAccount 屬性設定為 true 時才有效。

只有在您不需要建立使用者所屬群組的清單時,才可以將這個屬性設定為 false;如果應用程式和授權決策不需要 Windows 群組,這項設定將有助於提升效能。

適用於