# OpcClientIdentity Members

> Reference: Represents a user identity which is defined by a user name and a password.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcClientIdentity</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.client">Opc.UaFx.Client</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 [OpcUserIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcuseridentity/members), [OpcIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcidentity/members).

## Constructors

### OpcClientIdentity

Initializes a new instance of the [OpcClientIdentity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientidentity/) class using the `userName` and `password` specified.

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

```csharp
public OpcClientIdentity(string userName, string password)
```

</div>

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

```vbnet
Public Sub New(userName As String, password As String)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `userName` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The name of the user. |
| `password` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The password of the user. |

## 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 [UserName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientidentity/members#username) of the identity.

**Overrides**

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

### Password

Gets the password of the user.

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

```csharp
public string Password { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Password As String
```

</div>

**Property value**

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

The password of the user.

### UserName

Gets the name of the user.

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

```csharp
public string UserName { get; }
```

</div>

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

```vbnet
Public ReadOnly Property UserName As String
```

</div>

**Property value**

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

The name of the user.

## Methods

### Impersonate

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

Returns an impersonation context which does not impersonate the user.

<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 [OpcImpersonationContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/) whose [Undo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcimpersonationcontext/members#undo) method does nothing.

**Overrides**

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

### Matches

Determines whether the identity is defined by the `userName` and `password` specified.

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

```csharp
public bool Matches(string userName, string password)
```

</div>

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

```vbnet
Public Function Matches(userName As String, password As String) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `userName` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The name of the user to compare. |
| `password` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The password of the user to compare. |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the `userName` and the `password` are equal to the [UserName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientidentity/members#username) and the [Password](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientidentity/members#password) of the identity; otherwise the value false.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `userName` is an empty string. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `userName` or `password` is a null reference (Nothing in Visual Basic). |
