> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ClaimsPrincipal

> Extension methods for ClaimsPrincipal from System.Security.Claims

## Definition

**Assembly:** System.Security.Claims.dll

**Namespace:** System.Security.Claims

## Syntax

```csharp theme={"dark"}
System.Security.Claims.ClaimsPrincipal
```

## Summary

This type is defined in System.Security.Claims.

## Remarks

See [Microsoft documentation](https://learn.microsoft.com/dotnet/api/system.security.claims.claimsprincipal) for more information about the rest of the API.

## Methods

### <Icon icon="puzzle-piece" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> GetAllClaims <Badge color="green">Extension</Badge>

<Note>Extension method from `System.Security.Claims.EasyAF_ClaimsPrincipalExtensions`</Note>

#### Syntax

```csharp theme={"dark"}
public static System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> GetAllClaims(System.Security.Claims.ClaimsPrincipal claimsPrincipal, string claimType)
```

#### Parameters

| Name              | Type                                     | Description                                                                                                                                                                           |
| ----------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `claimsPrincipal` | `System.Security.Claims.ClaimsPrincipal` | The ClaimsPrincipal instance to check for Claims. Should be [Current](https://learn.microsoft.com/dotnet/api/system.security.claims.claimsprincipal.current), except in unit testing. |
| `claimType`       | `string`                                 | -                                                                                                                                                                                     |

#### Returns

Type: `System.Collections.Generic.IEnumerable<System.Security.Claims.Claim>`

### <Icon icon="puzzle-piece" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> GetClaimGuid <Badge color="green">Extension</Badge>

<Note>Extension method from `System.Security.Claims.EasyAF_ClaimsPrincipalExtensions`</Note>

#### Syntax

```csharp theme={"dark"}
public static System.Guid GetClaimGuid(System.Security.Claims.ClaimsPrincipal claimsPrincipal, string claimType)
```

#### Parameters

| Name              | Type                                     | Description |
| ----------------- | ---------------------------------------- | ----------- |
| `claimsPrincipal` | `System.Security.Claims.ClaimsPrincipal` | -           |
| `claimType`       | `string`                                 | -           |

#### Returns

Type: `System.Guid`

#### Exceptions

| Exception         | Description                                                                                                   |
| ----------------- | ------------------------------------------------------------------------------------------------------------- |
| `FormatException` | If the *claimType* is not formatted like a Guid (32 characters with 4 dashes), this exception will be thrown. |

### <Icon icon="puzzle-piece" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> GetClaimValue <Badge color="green">Extension</Badge>

<Note>Extension method from `System.Security.Claims.EasyAF_ClaimsPrincipalExtensions`</Note>

#### Syntax

```csharp theme={"dark"}
public static string GetClaimValue(System.Security.Claims.ClaimsPrincipal claimsPrincipal, string claimType)
```

#### Parameters

| Name              | Type                                     | Description                                                                                                                                                                           |
| ----------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `claimsPrincipal` | `System.Security.Claims.ClaimsPrincipal` | The ClaimsPrincipal instance to check for Claims. Should be [Current](https://learn.microsoft.com/dotnet/api/system.security.claims.claimsprincipal.current), except in unit testing. |
| `claimType`       | `string`                                 | -                                                                                                                                                                                     |

#### Returns

Type: `string`

### <Icon icon="puzzle-piece" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> GetIdClaim <Badge color="green">Extension</Badge>

<Note>Extension method from `System.Security.Claims.EasyAF_ClaimsPrincipalExtensions`</Note>

A shortcut for returning the AppUserProfileId for the current User.

#### Syntax

```csharp theme={"dark"}
public static System.Guid GetIdClaim(System.Security.Claims.ClaimsPrincipal principal)
```

#### Parameters

| Name        | Type                                     | Description                                   |
| ----------- | ---------------------------------------- | --------------------------------------------- |
| `principal` | `System.Security.Claims.ClaimsPrincipal` | The ClaimsPrincipal instance we're extending. |

#### Returns

Type: `System.Guid`
