NegotiateStream.RemoteIdentity Свойство

Определение

Возвращает сведения о идентификации удаленной стороны, использующей данный поток с проверкой подлинности.

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

Объект IIdentity, описывающий идентификацию удаленной конечной точки.

Исключения

Проверка подлинности завершилась неудачно или не выполнялась.

Примеры

В следующем примере кода показано отображение значения этого свойства.

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) сервера и используемый протокол проверки подлинности. При доступе к серверу это свойство возвращает описание WindowsIdentity клиента. Если этот WindowsIdentity параметр недоступен, сведения о клиенте возвращаются серверу в объекте GenericIdentity.

Применяется к