NegotiateStream.ImpersonationLevel 属性

定义

获取一个值,该值指示服务器使用客户端凭据的方法。

public:
 virtual property System::Security::Principal::TokenImpersonationLevel ImpersonationLevel { System::Security::Principal::TokenImpersonationLevel get(); };
public virtual System.Security.Principal.TokenImpersonationLevel ImpersonationLevel { get; }
member this.ImpersonationLevel : System.Security.Principal.TokenImpersonationLevel
Public Overridable ReadOnly Property ImpersonationLevel As TokenImpersonationLevel

属性值

TokenImpersonationLevel 值之一。

例外

身份验证失败或没有进行身份验证。

示例

下面的代码示例演示如何显示此属性的值。

static void DisplayAuthenticationProperties( NegotiateStream^ stream )
{
   Console::WriteLine( L"IsAuthenticated: {0}", stream->IsAuthenticated );
   Console::WriteLine( L"IsMutuallyAuthenticated: {0}", stream->IsMutuallyAuthenticated );
   Console::WriteLine( L"IsEncrypted: {0}", stream->IsEncrypted );
   Console::WriteLine( L"IsSigned: {0}", stream->IsSigned );
   Console::WriteLine( L"ImpersonationLevel: {0}", stream->ImpersonationLevel );
   Console::WriteLine( L"IsServer: {0}", stream->IsServer );
}


 static void DisplayAuthenticationProperties(NegotiateStream stream)
{
     Console.WriteLine("IsAuthenticated: {0}", stream.IsAuthenticated);
    Console.WriteLine("IsMutuallyAuthenticated: {0}", stream.IsMutuallyAuthenticated);
    Console.WriteLine("IsEncrypted: {0}", stream.IsEncrypted);
    Console.WriteLine("IsSigned: {0}", stream.IsSigned);
    Console.WriteLine("ImpersonationLevel: {0}", stream.ImpersonationLevel);
    Console.WriteLine("IsServer: {0}", stream.IsServer);
}

注解

在调用此方法之前,必须成功进行身份验证。 客户端通过调用 或 BeginAuthenticateAsClient 方法之一AuthenticateAsClient请求身份验证时指定模拟级别。 如果在未指定 TokenImpersonationLevel 的情况下进行身份验证, Identification 则使用 。

适用于