+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Claim for a backend user

Claim for a backend user

3 posts, 0 answered
  1. Vladimir
    Vladimir avatar
    13 posts
    Registered:
    30 Apr 2015
    29 Jun 2015
    Link to this post

    Hi everyone!

    In this article( http://www.sitefinity.com/blogs/svetla-yankovas-blog/2013/07/02/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!

  2. Vladimir
    Vladimir avatar
    13 posts
    Registered:
    30 Apr 2015
    29 Jun 2015
    Link to this post

    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

  3. Grisha 'Greg' Karanikolov
    Grisha 'Greg' Karanikolov avatar
    156 posts
    Registered:
    30 Nov 2016
    01 Jul 2015
    Link to this post
    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
     
3 posts, 0 answered