语言

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 远程终结点标识的对象。

例外

身份验证失败或未发生。

示例

下面的代码示例演示如何显示此属性的值。

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

适用于