The SDK provides a Users client to fetch users and user groups by name and also features some password management operations.
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.
GetUserAsync method gets a user by username. The following example fetches the user entity of the superuser:
IEntity superuser = await MClient.Users.GetUserAsync("superuser");
Getting user groups
GetUserGroupAsync method gets a user group by name. The following example fetches the user group entity for the superusers group.
IEntity superusersGroup = await MClient.Users.GetUserGroupAsync("superusers");
Superusers have the privilege to set passwords of other users. Use the
SetPasswordAsync method To change the password on a specific user:
await MClient.Users.SetPasswordAsync(100, "securepassword");
The first argument is the id of the user (e.g. 100). The second argument is the new password.
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.
This feature only applies to users created and managed in Sitecore Content Hub. It should not be used on users that are created and managed by a Single sign-on provider (SSO).
Can we improve this article ? Provide feedback