I am running a blog on Community Server 2008 SP2 (this is a blog software from between 2008-2011), with ASP.NET 2.0. Comments are currently not working, and I'm looking into why it's not working.

When I looked into the exception logs, I see:

Exception Type: RoleNotFound

User Agent:
Path: as HTTP
Referrer:
Message: Error while trying to find a role for the user 'chuacw'. Possible cause is a invalid client cookie or a user rename.
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Web.Security.Roles.GetRolesForUser(String username)
at CommunityServer.ASPNet20MemberRole.CSRoles.GetRolesForUser(String userName)
at CommunityServer.Components.Roles.UserRoleIDsCollection.LoadFromDatabase(String username)

To investigate this, I created testrole.aspx, with the following contents:

<%@ Page %>
<%@ Register TagPrefix="CSM" Namespace="CommunityServer.ASPNet20MemberRole" 

Assembly= "CommunityServer.ASPNet20MemberRole" %>
<%@ Register TagPrefix="Custom2" Namespace="CommunityServer.Components" 

Assembly= "CommunityServer.Components" %>

<% 
      String username = "chuacw";
      CommunityServer.ASPNet20MemberRole.CSRoles role = new 

CommunityServer.ASPNet20MemberRole.CSRoles();

      CommunityServer.Components.Role[] lRoles = role.GetRoles();
      foreach (CommunityServer.Components.Role lRole in lRoles) {
        Response.Write("Role: " + lRole.Name + "<br />");
      }
      Response.Write("<br/>");

      Response.Write("Username is: " + username + "<br />");

      String[] roles = role.GetRolesForUser(username);
      foreach (string lSrole in roles) {
         Response.Write(lSrole + "<br/>");  
      }
%>

And I opened up this page directly in a browser, from my site, ie, http://mysite/testrole.aspx without logging in to my site.

This code worked and I was able to see a list of roles, and the username.

Given that my code called CommunityServer.ASPNet20MemberRole.CSRoles.GetRolesForUser, which is the same method called by the code that raised the exception earlier in the beginning of this question, I'm unable to comprehend why this exception is thrown.

I am the administrator of this database, and I am the user "chuacw". I can log into this blog software using this user.

Does anyone have any ideas how I can further investigate this? I do not have the source to this, however, I can use ILSpy and Reflector, and write new code to test this.

My hope is to find the underlying conditions leading to this error, and fix the cause.

Thank you.

0

There are 0 answers