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

Forums / Bugs & Issues / RoleProviderWrapper Bug

RoleProviderWrapper Bug

2 posts, 0 answered
  1. John Tolar
    John Tolar avatar
    87 posts
    Registered:
    07 May 2003
    09 Aug 2011
    Link to this post
    While trying to find out why the roles for a custom provider is not showing up in the user admin screen (see screenshot2) like it does in the default user provider (see screenshot1).

    While debugging the code, I ran across the following code in your RoleProviderWrapper class:
    01.public override System.Linq.IQueryable<Role> GetRolesForUser(System.Guid userId)
    02.    {
    03.      string str;
    04.      User user = SecurityManager.GetUser(userId, out str);
    05.      System.Collections.Generic.List<Role> source = new System.Collections.Generic.List<Role>();
    06.      if (user != null)
    07.      {
    08.        string[] rolesForUser = this.roleProvider.GetRolesForUser(user.get_UserName());
    09.        for (int i = 0; i < rolesForUser.Length; i = (int) (i + 1))
    10.        {
    11.          string str2 = rolesForUser[i];
    12.          Role role = new Role {
    13.            Name = str2,
    14.            Id = this.GetGuidFromStrings(this.Name, str2)
    15.          };
    16.        }
    17.      }
    18.      return source.AsQueryable<Role>();

    Not sure if you see the problem here. It is missing one crucial line of code (line 16 below).

    01.public override System.Linq.IQueryable<Role> GetRolesForUser(System.Guid userId)
    02.    {
    03.      string str;
    04.      User user = SecurityManager.GetUser(userId, out str);
    05.      System.Collections.Generic.List<Role> source = new System.Collections.Generic.List<Role>();
    06.      if (user != null)
    07.      {
    08.        string[] rolesForUser = this.roleProvider.GetRolesForUser(user.get_UserName());
    09.        for (int i = 0; i < rolesForUser.Length; i = (int) (i + 1))
    10.        {
    11.          string str2 = rolesForUser[i];
    12.          Role role = new Role {
    13.            Name = str2,
    14.            Id = this.GetGuidFromStrings(this.Name, str2)
    15.          };
    16.          source.Add(role);
    17.        }
    18.      }
    19.      return source.AsQueryable<Role>();
  2. Lubomir Velkov
    Lubomir Velkov avatar
    688 posts
    Registered:
    03 Nov 2014
    10 Aug 2011
    Link to this post
    Hi John Tolar,

    This code has been rewritten in the latest version of Sitefinity - 4.2 - that should be released by the end of the week. I just checked that this problem exists in 4.1 SP2 and SP3, which you probably are using at the moment.

    Regards,
    Lubomir Velkov
    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
2 posts, 0 answered