NegotiateStream.RemoteIdentity Eigenschaft

Definition

Ruft Informationen zur Identität der Remoteseite ab, für die dieser authentifizierte Stream freigegeben ist.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

Eigenschaftswert

Ein IIdentity-Objekt, das die Identität des Remoteendpunkts beschreibt.An IIdentity object that describes the identity of the remote endpoint.

Ausnahmen

Bei der Authentifizierung ist ein Fehler aufgetreten, oder es ist keine Authentifizierung erfolgt.Authentication failed or has not occurred.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie der Wert dieser Eigenschaft angezeigt wird.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();
}


    public static void EndAuthenticateCallback (IAsyncResult ar)
    {
        // Get the saved data.
        ClientState cState = (ClientState) ar.AsyncState;
        TcpClient clientRequest = cState.Client;
        NegotiateStream authStream = (NegotiateStream) cState.AuthenticatedStream;
        Console.WriteLine("Ending authentication.");
        // Any exceptions that occurred during authentication are
        // thrown by the EndAuthenticateAsServer method.
        try 
        {
            // This call blocks until the authentication is complete.
            authStream.EndAuthenticateAsServer(ar);
        }
        catch (AuthenticationException e)
        {
            Console.WriteLine(e);
            Console.WriteLine("Authentication failed - closing connection.");
            cState.Waiter.Set();
            return;
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            Console.WriteLine("Closing connection.");
            cState.Waiter.Set();
            return;
        }
        // Display properties of the authenticated client.
        IIdentity id = authStream.RemoteIdentity;
        Console.WriteLine("{0} was authenticated using {1}.", 
            id.Name, 
            id.AuthenticationType
            );
        cState.Waiter.Set();

}

Hinweise

Wenn der Client darauf zugreifen kann, gibt diese Eigenschaft eine GenericIdentity zurück, die den Dienst Prinzipal Namen (SPN) des Servers und das verwendete Authentifizierungsprotokoll enthält.When accessed by the client, this property returns a GenericIdentity containing the Service Principal Name (SPN) of the server and the authentication protocol used. Wenn der Server darauf zugreifen kann, gibt diese Eigenschaft einen WindowsIdentity zurück, der den Client beschreibt.When accessed by the server, this property returns a WindowsIdentity that describes the client. Wenn die WindowsIdentity nicht verfügbar ist, werden Client Informationen in einem GenericIdentityan den Server zurückgegeben.If the WindowsIdentity is not available, client information is returned to the server in a GenericIdentity.

Gilt für: