NegotiateStream.RemoteIdentity プロパティ

定義

この認証されたストリームを共有するリモート側の ID に関する情報を取得します。Gets information about the identity of the remote party sharing this authenticated stream.

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

プロパティ値

IIdentity

リモート エンドポイントの ID を示す IIdentity オブジェクト。An IIdentity object that describes the identity of the remote endpoint.

例外

認証に失敗したか、認証が行われていません。Authentication failed or has not occurred.

次のコード例は、このプロパティの値を表示する方法を示しています。The following code example demonstrates displaying the value of this property.

static void EndAuthenticateCallback( IAsyncResult^ ar )
{
   
   // Get the saved data.
   ClientState^ cState = dynamic_cast<ClientState^>(ar->AsyncState);
   TcpClient^ clientRequest = cState->Client;
   NegotiateStream^ authStream = dynamic_cast<NegotiateStream^>(cState->AuthStream);
   Console::WriteLine( L"Ending authentication." );
   
   // Any exceptions that occurred during authentication are
   // thrown by the EndServerAuthenticate method.
   try
   {
      
      // This call blocks until the authentication is complete.
      authStream->EndAuthenticateAsServer( ar );
   }
   catch ( AuthenticationException^ e ) 
   {
      Console::WriteLine( e );
      Console::WriteLine( L"Authentication failed - closing connection." );
      cState->Waiter->Set();
      return;
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( e );
      Console::WriteLine( L"Closing connection." );
      cState->Waiter->Set();
      return;
   }

   
   // Display properties of the authenticated client.
   IIdentity^ id = authStream->RemoteIdentity;
   Console::WriteLine( L"{0} was authenticated using {1}.", id->Name, id->AuthenticationType );
   cState->Waiter->Set();
}


private static void EndAuthenticateCallback(ClientState cState)
{
    // Get the saved data.
    NegotiateStream authStream = (NegotiateStream)cState.AuthenticatedStream;
    Console.WriteLine("Ending authentication.");

    // Display properties of the authenticated client.
    IIdentity id = authStream.RemoteIdentity;
    Console.WriteLine("{0} was authenticated using {1}.",
        id.Name,
        id.AuthenticationType
    );
}

注釈

クライアントからアクセスすると、このプロパティは、 GenericIdentity サーバーのサービスプリンシパル名 (SPN) と使用されている認証プロトコルを含むを返します。When accessed by the client, this property returns a GenericIdentity containing the Service Principal Name (SPN) of the server and the authentication protocol used. サーバーによってアクセスされた場合、このプロパティは、 WindowsIdentity クライアントを説明するを返します。When accessed by the server, this property returns a WindowsIdentity that describes the client. WindowsIdentityが使用できない場合、クライアント情報はでサーバーに返され GenericIdentity ます。If the WindowsIdentity is not available, client information is returned to the server in a GenericIdentity.

適用対象