More in this section

Forums / Developing with Sitefinity / replacement for SecurityManager.GetCurrentUser().GetRoleIds()

replacement for SecurityManager.GetCurrentUser().GetRoleIds()

1 posts, 0 answered
  1. Scott
    Scott avatar
    3 posts
    05 Nov 2009
    14 Sep 2012
    Link to this post
    The SecurityManager.GetCurrentUser() method is obsolete and the SitefinityPrincipal object it returns is deprecated so I'm trying to find a replacement for these methods.

    Originally I had this
    Guid[] currentUserRoles = SecurityManager.GetCurrentUser().GetRoleIds();
    and it would return 4 guid roles.

    I then tried this
    User user = UserManager.GetManager().GetUser(Context.User.Identity.Name);
    List<Role> rolesForUser = RoleManager.GetManager().GetRolesForUser(user.Id).ToList();
    I expected to get 4 roles like the 4 Guids I got before but instead I got 0 roles.

    The User object in both attempts return the same user so up to that point it seems to work but the .GetRolesForUser(Guid) doesn't seem to return what I expect.

    So my question is am I doing this right or should I convert my old methods to something else? If it matters, I'm using the Administrative user with my testing.

1 posts, 0 answered