NegotiateStream.RemoteIdentity Właściwość

Definicja

Pobiera informacje o tożsamości strony zdalnej współużytkowania tego uwierzytelnionego strumienia.

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

Wartość właściwości

Obiekt IIdentity opisujący tożsamość zdalnego punktu końcowego.

Wyjątki

Uwierzytelnianie nie powiodło się lub nie wystąpiło.

Przykłady

Poniższy przykład kodu przedstawia wyświetlanie wartości tej właściwości.

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

Uwagi

Po korzystaniu z dostępu przez klienta ta właściwość zwraca wartość zawierającą GenericIdentity główną nazwę usługi (SPN) serwera i używany protokół uwierzytelniania. Po korzystaniu z serwera ta właściwość zwraca element opisujący WindowsIdentity klienta. Jeśli element WindowsIdentity jest niedostępny, informacje o kliencie są zwracane do serwera w obiekcie GenericIdentity.

Dotyczy