RoleProviderWrapper Bug
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>();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,