Search code examples
c#kenticokentico-api

How to give a role create and delete permissions to a node in Kentico API?


I'm using the following example to update role permission on a tree node via Kentico API:

https://docs.kentico.com/api11/content-management/page-security#Pagesecurity-Settingpagepermissionsforarole

Not able to figure out how to assign multiple permissions, for instance Allow Create and Allow Delete. Any example greatly appreciated.


Solution

  • Sum all values that you get from permission flag method into allowed and save it:

        if (role != null)
        {
            int allowed = DocumentSecurityHelper.GetNodePermissionFlags(NodePermissionsEnum.Create);
            allowed += DocumentSecurityHelper.GetNodePermissionFlags(NodePermissionsEnum.Delete);
            // Prepares a value indicating that no page permissions are denied
            int denied = 0;
    
            AclItemInfoProvider.SetRolePermissions(page, allowed, denied, role);
        }