Users client

The SDK provides a Users client to fetch users and user groups by name and also features some password management operations.

Note

The client variable in the following code examples refers to the IMClient instance. When using the Web SDK, the variable name can be chosen freely, but it is also called client at instantiation in the documentation.

Users and user groups are entities that can be used with the querying client and the entities client.

Get users

The GetUserAsync method gets a user by username. The following example fetches the user entity of the superuser:

RequestResponse

IEntity superuser = await MClient.Users.GetUserAsync("superuser");

Get user groups

The GetUserGroupAsync method gets a user group by name. The following example fetches the user group entity for the superusers group.

RequestResponse

IEntity superusersGroup = await MClient.Users.GetUserGroupAsync("superusers");

Set passwords

Superusers have the necessary privileges to set passwords for other users. Use the SetPasswordAsync method To change the password on a specific user:

RequestResponse

await MClient.Users.SetPasswordAsync(100, "securepassword");

The first argument is the id of the user (for example, 100). The second argument is the new password.

Reset passwords

Superusers also have the privilege to send 'password forgotten' e-mails to users. To do this, call the ResetPasswordAsync method with the id of the user. An e-mail is sent containing a unique and secure link to a page where the user can change their password.

RequestResponse

await MClient.Users.ResetPasswordAsync(100);

Note

This feature only applies to users created and managed in Content Hub. It should not be used on users that are created and managed by a Single sign-on provider (SSO).

Do you have some feedback for us?

If you have suggestions for improving this article,