Permissions API: Custom Role for Tags Permission Set is not

Posted by Kaibear on 31-Mar-2020 09:51

I created a role called "Sen_RPA" which shall enable view, creation and modification and deletion of classifications.

The role is created via code and permissions have been granted. Everything is also visible in the backend as I developed it.

However, the simple List "Tags" under Classifications, does not list this custom role in the permissions. Whoever, "All Classifications"'s permissions does list the role. Is there a reason the inheritance does not occur in Tags? Is there even an inheritance from "All Classifications? 

When I manually create a role and add these permissions, "Tags" will automatically get the new role.


My code is the following:

private void CreateTagsPermissions(string role)
        {
            TaxonomyManager taxonomyMgr = TaxonomyManager.GetManager();
            string permSet = SecurityConstants.Sets.Taxonomies.SetName;


            Permission pagePerm = taxonomyMgr.CreatePermission(
                permSet,
                taxonomyMgr.GetSecurityRoot(false).Id,
                GetRole(role).Id);

            pagePerm.GrantActions(
                false,
                SecurityConstants.Sets.Taxonomies.Create,
                SecurityConstants.Sets.Taxonomies.Delete,
                SecurityConstants.Sets.Taxonomies.Modify,
                SecurityConstants.Sets.Taxonomies.View
                );

            taxonomyMgr.GetSecurityRoot(false).Permissions.Add(pagePerm);
            taxonomyMgr.SaveChanges();
        }

     public void CreateRole(string roleName)
        {
            RoleManager roleManager = RoleManager.GetManager(SecurityManager.ApplicationRolesProviderName);
            roleManager.Provider.SuppressSecurityChecks = true;

            if (roleManager.GetRoles().FirstOrDefault(r => r.Name == roleName) == null)
            {
                roleManager.CreateRole(roleName);
                roleManager.SaveChanges();
                roleManager.Provider.SuppressSecurityChecks = false;
            }
            else
            {
                // Handle appropriately when the role already exists
            }
        }






All Replies

This thread is closed