HttpDigestClientCredential.AllowedImpersonationLevel 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
使用提供的客户端凭据,获取或设置客户端允许的模拟级别。
public:
property System::Security::Principal::TokenImpersonationLevel AllowedImpersonationLevel { System::Security::Principal::TokenImpersonationLevel get(); void set(System::Security::Principal::TokenImpersonationLevel value); };
public System.Security.Principal.TokenImpersonationLevel AllowedImpersonationLevel { get; set; }
member this.AllowedImpersonationLevel : System.Security.Principal.TokenImpersonationLevel with get, set
Public Property AllowedImpersonationLevel As TokenImpersonationLevel
属性值
客户端授予服务器作为 HTTP 摘要式身份验证一部分的 TokenImpersonationLevel。
示例
下面的示例演示如何设置此属性。
// Create a service host.
EndpointAddress ea = new EndpointAddress("http://localhost/Calculator");
WSHttpBinding b = new WSHttpBinding(SecurityMode.Transport);
b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Digest;
// Create a client. The code is not shown here. See the WCF samples
// for an example of the CalculatorClient code.
CalculatorClient cc = new CalculatorClient(b, ea);
// Get a reference to the Windows client credential object.
HttpDigestClientCredential digestCred = cc.ClientCredentials.HttpDigest;
Console.WriteLine("AllowedImpersonationLevel: {0}",
digestCred.AllowedImpersonationLevel);
Console.WriteLine("Domain: {0}", digestCred.ClientCredential.Domain);
Console.ReadLine();
// Change the AllowedImpersonationLevel.
digestCred.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
Console.WriteLine("Changed AllowedImpersonationLevel: {0}",
digestCred.AllowedImpersonationLevel);
Console.ReadLine();
// Open the calculator and use it.
//cc.Open();
//Console.WriteLine(cc.Add(11, 11));
//// Close the client.
//cc.Close();
' Create a service host.
Dim ea As New EndpointAddress("http://localhost/Calculator")
Dim b As New WSHttpBinding(SecurityMode.Transport)
b.Security.Transport.ClientCredentialType = _
HttpClientCredentialType.Digest
' Create a client. The code is not shown here. See the WCF samples
' for an example of the CalculatorClient code.
Dim cc As New CalculatorClient(b, ea)
' Get a reference to the Windows client credential object.
Dim digestCred As HttpDigestClientCredential = cc.ClientCredentials.HttpDigest
Console.WriteLine("AllowedImpersonationLevel: {0}", _
digestCred.AllowedImpersonationLevel)
Console.WriteLine("Domain: {0}", digestCred.ClientCredential.Domain)
Console.ReadLine()
' Change the AllowedImpersonationLevel.
digestCred.AllowedImpersonationLevel = _
System.Security.Principal.TokenImpersonationLevel.Impersonation
Console.WriteLine("Changed AllowedImpersonationLevel: {0}", _
digestCred.AllowedImpersonationLevel)
Console.ReadLine()
' Open the calculator and use it.
' cc.Open()
' Console.WriteLine(cc.Add(11, 11))
' Close the client.
' cc.Close()
注解
允许的值包括:
由于摘要式身份验证的限制,当客户端使用非默认凭据时,只允许 Impersonation
和 Delegation
级别。