# OpcImpersonationContext Members

> Reference: Represents the context of an impersonation started by Impersonate, which undoes the impersonation.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcImpersonationContext</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>

## Constructors

### OpcImpersonationContext

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

Initializes a new instance of the [OpcImpersonationContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/) class.

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

```csharp
protected OpcImpersonationContext()
```

</div>

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

```vbnet
Protected Sub New()
```

</div>

## Methods

### Dispose

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

| Overload | Description |
|---|---|
| [Dispose()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/members#dispose-noparams) | Releases all resources used by the [OpcImpersonationContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/). |
| [Dispose(bool)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/members#dispose-system-boolean)<span class="api-meta">protected · virtual</span> | Releases the unmanaged resources used by the [OpcImpersonationContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/) and optionally releases the managed resources. |

#### Dispose()

Releases all resources used by the [OpcImpersonationContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/).

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

```csharp
public void Dispose()
```

</div>

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

```vbnet
Public Sub Dispose()
```

</div>

**Implements**

[Dispose()](https://learn.microsoft.com/dotnet/api/system.idisposable.dispose)

**Remarks**

The method does not undo the impersonation; call [Undo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/members#undo) to undo it.

#### Dispose(bool)

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

Releases the unmanaged resources used by the [OpcImpersonationContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/) and optionally releases the managed resources.

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

```csharp
protected virtual void Dispose(bool disposing)
```

</div>

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

```vbnet
Protected Overridable Sub Dispose(disposing As Boolean)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `disposing` | [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) | The value true to release both managed and unmanaged resources; otherwise the value false to release only unmanaged resources. |

### Undo

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

Undoes the impersonation.

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

```csharp
public abstract void Undo()
```

</div>

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

```vbnet
Public MustOverride Sub Undo()
```

</div>
