I need to add a user to the backoffice admin group. How to do it.
I was thinking to create a group with backoffice permissions and add the user to it.
I can create group and add the users, but not sure how give backoffice permissions for the group.
var person = GetPerson();
var groupName = "NewAdminGroup";
var defaultGroupTemplate = fieldTemplateService.GetAll().OfType<GroupFieldTemplate>().FirstOrDefault();
var userGroup = new StaticGroup(defaultGroupTemplate.SystemId, groupName)
{
Id = groupName
};
using (securityContextService.ActAsSystem())
{
// create group
groupService.Create(userGroup);
// Add person into the group
person = person.MakeWritableClone();
person.GroupLinks.Add(new PersonToGroupLink(userGroup.SystemId));
personService.Update(person)
// Add Backoffice permsion into the group
.....
}
I’m not sure how you would find the information the first time.
But what you want to add is
group.AccessControlOperationList = new HashSet<AccessControlOperationEntry>
{
new AccessControlOperationEntry(new Operation("Test")),
new AccessControlOperationEntry(new Operation("Test2"))
};
The values to add in Operation() can be found be getting a manually created group and looping the values. But I don’t know how to find them in code the first time, but these are the operations you want to add.