Try Now
More in this section

Forums / Developing with Sitefinity / How to get the list of global permissions set for any user (not logged in)?

How to get the list of global permissions set for any user (not logged in)?

2 posts, 0 answered
  1. Bohdan
    Bohdan avatar
    1 posts
    08 Dec 2010
    05 Jan 2011
    Link to this post
    I need to get the list of global permissons assigned to some user. Please advise.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    19 Oct 2016
    05 Jan 2011
    Link to this post
    Hello Bohdan,

    Here is a sample code that illustrates how to get permissions for a user( you get permissions for all roles under which this user belongs)

    ISecuredBase secObject = Telerik.Cms.Security.GlobalPermissions.Instance;
           IDictionary<string, ApplicationPermission> permissions = secObject.GetPermissions(UserManager.Default.RoleProvider.Name);
           ApplicationPermission permission = new ApplicationPermission();
           string[] roles = UserManager.Default.RoleProvider.GetRolesForUser("MyUserName");
           ApplicationPermission curr;
           foreach (string role in roles)
               if (UserManager.IsRoleUnrestricted(UserManager.Default.RoleProvider.Name, role))
                   permission = new ApplicationPermission(PermissionState.Unrestricted).Union(permission);
               else if (permissions.TryGetValue(role.ToLower(), out curr))
                   permission = curr.Union(permission);
           if (permissions.TryGetValue("everyone", out curr))
               permission = curr.Union(permission);
    // here check for the global permission you are looking for - for example CmsAccess
    GlobalPermission cmsGlobalPermission = new GlobalPermission(GlobalRights.CmsAccess);
    // here you can calll cmsGlobalPermission.IsSubsetOf(permission);

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered