---
title: "Interface IUsersClient"
slug: "sdk--stylelabs.m.sdk.clients.iusersclient"
abstract: ""
---
# Interface IUsersClient

Client for fetching user entities and user related actions.

## Namespace: StylelabsStylelabs.MSdkClients

## Assembly: Stylelabs.M.Sdk.dll

## Syntax

```csharp
public interface IUsersClient
```

## Methods

### GetUserAsync(long, IEntityLoadConfiguration)

Gets the specified user entity.

#### Declaration

```csharp
Task<IEntity> GetUserAsync(long id, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | The id of the user. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The user entity or null when it was not found. |

### GetUserAsync(string, IEntityLoadConfiguration)

Gets the specified user entity.

#### Declaration

```csharp
Task<IEntity> GetUserAsync(string username, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | username | Username of the user. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The user or null when it was not found. |

### GetUserGroupAsync(long, IEntityLoadConfiguration)

Gets the specified user group entity.

#### Declaration

```csharp
Task<IEntity> GetUserGroupAsync(long id, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | Id of the user. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The user or null when it was not found. |

### GetUserGroupAsync(string, IEntityLoadConfiguration)

Gets the user group by the specified name.

#### Declaration

```csharp
Task<IEntity> GetUserGroupAsync(string groupName, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | groupName | Name of the group. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The loading configuration. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The user group entity or null when it was not found. |

### GetUserGroupIdAsync(string)

Gets the ids of the specified user groups by name.

#### Declaration

```csharp
Task<long?> GetUserGroupIdAsync(string groupName)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | groupName | The groupName name. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>long | The group's id or null when it was not found. |

### GetUserGroupIdsAsync(IEnumerable<string>)

Gets the ids of the specified user groups by name.

#### Declaration

```csharp
Task<IDictionary<string, long>> GetUserGroupIdsAsync(IEnumerable<string> groupNames)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | groupNames | A list of group names. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IDictionary<, >stringlong | Non null, case-insensitive dictionary that maps the user group names to ids. Users that don't exist, will not be in the result. |

### GetUserGroupNameAsync(long)

Gets the name of the specified user group.

#### Declaration

```csharp
Task<string> GetUserGroupNameAsync(long id)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | The id of the user group. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>string | The group name or null when it was not found. |

### GetUserGroupNamesAsync(IEnumerable<long>)

Gets the name of the specified user groups.

#### Declaration

```csharp
Task<IDictionary<long, string>> GetUserGroupNamesAsync(IEnumerable<long> ids)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | The ids of user groups. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IDictionary<, >longstring | Non null dictionary that maps the user group ids to user group names. Users that don't exist, will not be in the result. |

### GetUserGroupsAsync(IEnumerable<long>, IEntityLoadConfiguration)

Gets the specified user group entities.

#### Declaration

```csharp
Task<IList<IEntity>> GetUserGroupsAsync(IEnumerable<long> ids, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | The ids of the user groups. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The user group entities. Can contain null when a user group was not found. |

### GetUserGroupsAsync(IEnumerable<string>, IEntityLoadConfiguration)

Gets the specified user group entities.

#### Declaration

```csharp
Task<IList<IEntity>> GetUserGroupsAsync(IEnumerable<string> groupNames, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | groupNames | The names of the user groups. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The user group entities. Can contain null when a user group was not found. |

### GetUserIdAsync(string)

Gets the id of the specified user by username.

#### Declaration

```csharp
Task<long?> GetUserIdAsync(string username)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | username | The user name. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>long | The user's id or null when it was not found. |

### GetUserIdsAsync(IEnumerable<string>)

Gets the ids of the specified users by username.

#### Declaration

```csharp
Task<IDictionary<string, long>> GetUserIdsAsync(IEnumerable<string> usernames)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | usernames | A list of user names. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IDictionary<, >stringlong | Non null, case-insensitive dictionary that maps the user names to ids. Users that don't exist, will not be in the result. |

### GetUsernameAsync(long)

Gets the username of the specified user.

#### Declaration

```csharp
Task<string> GetUsernameAsync(long id)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | The id of the user. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>string | The username or null when it was not found. |

### GetUsernamesAsync(IEnumerable<long>)

Gets the usernames of the specified users.

#### Declaration

```csharp
Task<IDictionary<long, string>> GetUsernamesAsync(IEnumerable<long> ids)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | The ids of the entities to get. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IDictionary<, >longstring | Non null dictionary that maps the user ids to usernames. Users that don't exist, will not be in the result. |

### GetUsersAsync(IEnumerable<long>, IEntityLoadConfiguration)

Gets the specified user entities.

#### Declaration

```csharp
Task<IList<IEntity>> GetUsersAsync(IEnumerable<long> ids, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | The ids of the users. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The user entities. Can contain null when a user was not found. |

### GetUsersAsync(IEnumerable<string>, IEntityLoadConfiguration)

Gets the specified user entities.

#### Declaration

```csharp
Task<IList<IEntity>> GetUsersAsync(IEnumerable<string> usernames, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | usernames | A list of user names. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The user entities. Can contain null when a user was not found. |

### ResetPasswordAsync(long)

Resets the password of the specified user. This sends an e-mail to the specified user with a link to choose a new password.

#### Declaration

```csharp
Task ResetPasswordAsync(long id)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | Id of the user. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

#### Exceptions

| Type | Condition |
| --- | --- |
| [ForbiddenException](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.exceptions.forbiddenexception.html) | When the current user is not a superuser. |

### SetPasswordAsync(long, string)

Changes the password of the specified user.

#### Declaration

```csharp
Task SetPasswordAsync(long id, string password)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | The user id to change the password on. |
| string | password | The password to reset. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

#### Exceptions

| Type | Condition |
| --- | --- |
| [ForbiddenException](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.exceptions.forbiddenexception.html) | When the current user is not a superuser. |
