This article has not yet been verified against Umbraco 8.
The concepts and code examples might not work if you are running Umbraco 8.0 or a later version. If you are using Umbraco 7, this article is perfect for you!
You are more than welcome to report any issues found on the Documentation Issue Tracker.
Applies to Umbraco 6.x and newer
The UserService acts as a "gateway" to Umbraco data for operations which are related to Users.
All samples listed in this document will require references to the following dll:
All samples listed in this document will require the following usings:
using Umbraco.Core.Models.Membership; using Umbraco.Core.Services;
Getting the service
If you wish to use use the user service in a class that inherits from one of the Umbraco base classes - eg.
UmbracoAuthorizedApiController - you can access the user service through a local
IUserService us = Services.UserService;
In Razor views, you can access the UserService through the
IUserService us = ApplicationContext.Services.UserService
If neither a
Services property or a
ApplicationContext is available, you can also reference the
ApplicationContext class directly:
IUserService us = ApplicationContext.Current.Services.UserService
Create a new user
Quick sample showing how to create a new backoffice user; including setting a password, assigning the user to a user group (from Umbraco 7.7 and up), and setting the name of the user.
Get a reference to a user
See the different ways to lookup a backoffice user.
Update user information
See how you can update user information such as names and avatars.