共用方式為


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);
}

備註

您必須在呼叫此方法之前成功進行驗證。 客戶端藉由呼叫其中 AuthenticateAsClient 一個 或 BeginAuthenticateAsClient 方法來要求驗證時,指定模擬層級。 如果您在未指定 TokenImpersonationLevel 的情況下進行驗證, Identification 則會使用 。

適用於