# OpcUserIdentity Members

> Reference: Represents the identity of a user described by an OPC UA user identity token (e.g. an anonymous user, a user name or a certificate).

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcUserIdentity</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

Inherits members from [OpcIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcidentity/members).

## Constructors

### OpcUserIdentity

<span class="api-meta">protected · 2 overloads</span>

| Overload | Description |
|---|---|
| [OpcUserIdentity(UserIdentityToken)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/members#opcuseridentity-opc-ua-useridentitytoken)<span class="api-meta">protected · since v2.42</span> | Initializes a new instance of the [OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/) class using the `token` specified. |
| [OpcUserIdentity(OpcIdentityToken)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/members#opcuseridentity-opc-uafx-opcidentitytoken)<span class="api-meta">protected · since v2.53</span> | Initializes a new instance of the [OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/) class using the `token` specified. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `token` is a null reference (Nothing in Visual Basic). |

#### OpcUserIdentity(UserIdentityToken)

<span class="api-meta">protected · since v2.42</span>

Initializes a new instance of the [OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/) class using the `token` specified.

<div class="api-signature" data-lang="csharp">

```csharp
protected OpcUserIdentity(UserIdentityToken token)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Sub New(token As UserIdentityToken)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `token` | <abbr title="OPC Foundation stack type, not documented here: Opc.Ua.UserIdentityToken">UserIdentityToken</abbr> | The user identity token which describes the identity. |

#### OpcUserIdentity(OpcIdentityToken)

<span class="api-meta">protected · since v2.53</span>

Initializes a new instance of the [OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/) class using the `token` specified.

<div class="api-signature" data-lang="csharp">

```csharp
protected OpcUserIdentity(OpcIdentityToken token)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Sub New(token As OpcIdentityToken)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `token` | [OpcIdentityToken](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcidentitytoken/) | The user identity token which describes the identity. |

## Properties

### DisplayName

<span class="api-meta">override</span>

Gets the name of the identity to display.

<div class="api-signature" data-lang="csharp">

```csharp
public override string DisplayName { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Overrides ReadOnly Property DisplayName As String
```

</div>

**Property value**

[String](https://learn.microsoft.com/dotnet/api/system.string)

The display name determined by the OPC UA stack from the token: "Anonymous" for an anonymous user, the user name, or the subject of the certificate.

**Overrides**

[DisplayName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcidentity/members#displayname)

## Methods

### Impersonate

<span class="api-meta">override</span>

Impersonates the user represented by the identity.

<div class="api-signature" data-lang="csharp">

```csharp
public override OpcImpersonationContext Impersonate()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Overrides Function Impersonate() As OpcImpersonationContext
```

</div>

**Returns**

[OpcImpersonationContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/)

An [OpcDefaultImpersonationContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdefaultimpersonationcontext/).

**Overrides**

[Impersonate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcidentity/members#impersonate)

**Remarks**

The method does not impersonate the user; the context returned does nothing when it is undone.

### ToString

<span class="api-meta">override</span>

Returns a string that represents the identity.

<div class="api-signature" data-lang="csharp">

```csharp
public override string ToString()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Overrides Function ToString() As String
```

</div>

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)

A string containing the [DisplayName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/members#displayname) of the identity.

**Overrides**

[ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)
