NegotiateStream.RemoteIdentity Property

Definition

Gets information about the identity of the remote party sharing this authenticated stream.

C#
public virtual System.Security.Principal.IIdentity RemoteIdentity { get; }

Property Value

An IIdentity object that describes the identity of the remote endpoint.

Exceptions

Authentication failed or has not occurred.

Examples

The following code example demonstrates displaying the value of this property.

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

Remarks

When accessed by the client, this property returns a GenericIdentity containing the Service Principal Name (SPN) of the server and the authentication protocol used. When accessed by the server, this property returns a WindowsIdentity that describes the client. If the WindowsIdentity is not available, client information is returned to the server in a GenericIdentity.

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1