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

Forums / Bugs & Issues / GetUsersInRole error

GetUsersInRole error

3 posts, 0 answered
  1. Matt
    Matt avatar
    56 posts
    Registered:
    20 Nov 2009
    14 Jun 2011
    Link to this post
    I can't seem to get the users in a role using the RoleManager.GetUsersInRole method.  I have tried both the default provider as well as the AppRoles provider, and no matter what, if there are users in the role, it gives me this error.  If there are no users it comes back with an empty list as expected.

    System.NullReferenceException: Object reference not set to an instance of an object.
       at DynamicModule.ns.Wrapped_OpenAccessRoleProvider_27f3332dd3234177a50e5232730adb47.GetUsersInRole(String roleName, String filterExpression, String sortExpression, Int32 skip, Int32 take)
       at Telerik.Sitefinity.Security.RoleManager.GetUsersInRole(String roleName)

    Here's my code:
                var roleMan = RoleManager.GetManager();
                var users = roleMan.GetUsersInRole("Staff");

    Matt
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    16 Aug 2017
    15 Jun 2011
    Link to this post
    Hello Matt,

    Thank you for using our services. Can you, please, make sure you've spelled correctly the RoleName when passing it as an argument to the method? I have just tried this functionality and everything seems to work as expected (please take a look at the attached sample video).

    Best wishes,
    Boyan Barnev
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Conrad Ehinger
    Conrad Ehinger avatar
    59 posts
    Registered:
    22 Sep 2009
    01 Dec 2011
    Link to this post
    Boyan,

    I have the same issue. It only occurs when you are logged out of the Sitefinity Admin.

    Also - make sure that one of the users in "Custom Role", is also part of the "Administrators" role. So the user belongs to both "Administrators" and "Custom Role"

    Thanks,

    Chris
3 posts, 0 answered