Create and update users
Log in to add to favouritesCreating and updating users can be achieved by using one of the New
method overloads in combination with calling Save
on the User class.
- New(string username, string email, string password)
- New(Guid id, string username, string email, string password)
- Update user
Initializes a new user with a username, email address and password. The user is not created from calling New
.
Syntax
public User New(string username, string email, string password)
{
}
Parameters
username
Type: string
The user's username.
Type: string
The user's email address.
password
Type: string
The user's password for login.
Examples
using Zengenti.Contensis.Management;
// Create a client
var client = ManagementClient.Create();
// Initialize the user
User user = client.Security.Users.New("t.durden", "t.durden@fightclub.com", "d0ntT4lk4boutf1ghtClub!");
// Create the user
user.Save();
// Create the user asynchronously
await user.SaveAsync();
Initializes a new user with a specified unique id, username, email address and password. The user is not created from calling New
.
Syntax
public User New(Guid id, string username, string email, string password)
{
}
Parameters
id
Type: guid
A unique identifier for the user.
username
Type: string
The user's username.
Type: string
The user's email address.
password
Type: string
The user's password for login.
Examples
using Zengenti.Contensis.Management;
// Create a client
var client = ManagementClient.Create();
// Create a guid
var userId = Guid.Parse("00000000-0000-0000-0000-000000000001")
// Initialize the user
User user = client.Security.Users.New(userId, "t.durden", "t.durden@fightclub.com", "d0ntT4lk4boutf1ghtClub!");
// Create the user
user.Save();
// Create the user asynchronously
await user.SaveAsync();
Updates an existing user.
Examples
using Zengenti.Contensis.Management;
// Create a client
var client = ManagementClient.Create();
// Get an existing user
User user = client.Security.Users.Get("t.durden");
// Update user details
user.Custom.Add("motto", "The first rule of fight club...");
// Update the user
user.Save();
// Update the user asynchronously
await user.SaveAsync();