Claim for a backend user

Posted by Community Admin on 04-Aug-2018 11:01

Claim for a backend user

All Replies

Posted by Community Admin on 29-Jun-2015 00:00

Hi everyone!

In this article( www.sitefinity.com/.../single-sign-on-between-sitefinity-and-3rd-party-applications-part-2-using-wif) there is listed a set of sitedfinity claims for SSO.

I wonder if  is there  a claim for backend using? As far as I understand, it is controlled by IsBackendUser property of a User.

Basically the question is: How I can declare that this specfic user has access to backend in the SWT?

 

Many thanks!

Posted by Community Admin on 29-Jun-2015 00:00

After some research, I found out that the IsBackendUser field is binded to the BackendUsers role.

Now the problem is that I could not assing a user to some of the "AppRoles" role provider roles(BackendUsers is a part of it). When I create a role("Default" role provider), I can assign a user to it using claims.  Why I can't do the same with the roles from "AppRoles"?

Thanks

Posted by Community Admin on 01-Jul-2015 00:00

Hi Vladimir,

Indeed, access to the backend is provided to a user if he's a member of the BackendUsers role.
You should be able to assign users to that role regardless of their provider. This article of our documentation describes how to programatically add users to roles:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Model;
  
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DeepDive.Security.Roles.UsersAndRoles
    public partial class RolesApiSnippets
    
        public static void AddUserToRoles(string userName, List<string> rolesToAdd)
        
            UserManager userManager = UserManager.GetManager();
            RoleManager roleManager = RoleManager.GetManager(SecurityManager.ApplicationRolesProviderName);
            roleManager.Provider.SuppressSecurityChecks = true;
  
            if (userManager.UserExists(userName))
            
                User user = userManager.GetUser(userName);
  
                foreach (var roleName in rolesToAdd)
                
                    if (roleManager.RoleExists(roleName))
                    
                        Role role = roleManager.GetRole(roleName);
                        roleManager.AddUserToRole(user, role);
                    
                
            
  
            roleManager.SaveChanges();
            roleManager.Provider.SuppressSecurityChecks = false;
        
    

Are you getting some error when doing this?


Regards,
Grisha 'Greg' Karanikolov
Telerik
 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed