User serialization

Version: 10.2

You can serialize users, which means that specified users will be taken into account during sync operations.

The user serialization feature lets you manage users in your solution to synchronize users with other developers on the same project, and to promote changes to source-controlled users across Sitecore environments. Users can also be included in item packages files (*.itempackage).

Note

This feature is currently unavailable for creating *.dat files.

Setting up users in *module.json

You can decide which users are included in the serialization process.

You can specify users in any *module.json configuration files, inside the root section. The users property is an array of user predicate items with two properties:

  • domain - Sitecore user domain.

  • pattern - Regex pattern to determine specific users to include under the domain.

For example:

RequestResponse
{
    ...
    "items": {
        ...
    },
    "users": [
      {
        "domain": "sitecore",
        "pattern": "Developer"
      },
      {
        "domain": "custom",
        "pattern": "User*"
      },
      {
        "domain": "extranet",
        "pattern": "^MySite.*$"
      }
    ]
}
Note

The orphaned users that are not serialized but match the configuration predicate are automatically deleted from Sitecore.

Checking user serialization using the ser info command

You can check users' data using the Sitecore CLI dotnet sitecore serialization info command. For example:

RequestResponse
ModuleWithUser
  Subtrees:
    ...
  Users: 1

To output more information, you can use the --trace or -t option with the command:

RequestResponse
dotnet sitecore serialization info
RequestResponse
Maximum subtree-relative item path allowed: 120

ModuleWithUser
    File: C:\Projects\Example\serialization\src/ModuleWithUser/ModuleWithUser.module.json
    Subtrees:
        ...
    Users:
        domain :extranet
        pattern:^MySite.*$

Server-side user synchronization configuration

You can find a configuration file in the following location <cm_instance_path>\App_Config\Sitecore\Services.GraphQL\Sitecore.Services.GraphQL.Serialization.Users.config

RequestResponse
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore>
       ...
        <settings>
            <setting name="Sitecore.DevEx.GraphQL.Serialization.Users.AllowUserSynchronization" value="true" />
            <setting name="Sitecore.DevEx.GraphQL.Serialization.Users.DefaultPassword" value="sitecore" />
            <setting name="Sitecore.DevEx.GraphQL.Serialization.Users.MinPasswordLength" value="8" />
        </settings>
    </sitecore>
</configuration>
  • AllowUserSynchronization - allows to serialize/deserialize users.

  • DefaultPassword - when new users are deserialized, their passwords will be set to this value. If the value is set to random, the password will be set to a long randomly generated value. Otherwise, the literal value is used. If using the random password mode, an administrator must reset the user's password before it can be used.

  • MinPasswordLength - if the default password is not random, this settings defines the minimum accepted password length when deserializing a user. The length must be larger than 0. The default length is 8.

CLI-side user synchronization configuration in sitecore.json

You can specify how to manage orphaned users. 

For example, to remove orphaned users:

RequestResponse
 {
   ...
    "removeOrphansForUsers": true,
   ...
  },

Do you have some feedback for us?

If you have suggestions for improving this article,