X509ClientCertificateAuthentication.MapClientCertificateToWindowsAccount 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示是否将证书映射到 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 帐户。