mmbianco
  •  mmbianco
  • 56.6% (Neutral)
  • YAF Forumling Topic Starter
2008-07-23T08:32:39Z
Hello,

I have moved this to it's own topic, from here:
http://forum.yetanotherf...op-level-categories.aspx 

I have successfully installed YAF using the source, and embedded into my existing project.

I have started with a new, blank, YAF database, as well as new aspnet membership tables in my existing DB using aspnet_regsql.exe

I am using my own custom membership provider, aspnet's role provider, and aspnet's profile provider, inheriting from YAF.Classes.Utils.YafUserProfile

During the YAF install (/install/default.aspx), it askes for the admin username, which I supply, and it successfully add's the user to the Administrator role. When I logon to YAF it recognizes this user as an Admin.

Unfortunately, no other users are given the Registered role, even though it is set to "IsStart".

I have tried to logon to the forum with two different users, one with no roles assigned in aspnet, and one with the Registered role already assigned in aspnet before logon. Either way the user has no permissions in YAF once logged on.

I see the Administrator and Registered roles as "linked", and Guest as "unlinked" in YAF admin.

I also see that these users have been added to the YAF user database once they've logged on, but no roles have been assigned. I can manually go assign a user to the "Registered" role, and then it works. I want this to happen automatically howerver.

Why isn't the IsStart property beign recognized, and why isn't the user being assigned that Role once they logon?
Is anyone else experiencing this issue?

I am very close and really need to get this forum rocking, so any and all help is very appreciated!

My provider config is the following:

<membership defaultProvider="GMembershipProvider"  userIsOnlineTimeWindow="30">
      <providers>
      <add name="GMembershipProvider"
         type="GMembershipProvider"
         applicationName="GV"
         requiresUniqueEmail="true"
         passwordFormat="SHA1"
         description="Stores and retrieves membership data from SQL Server"
         decryptionKey="<removed>"
         validationKey="<removed>"
        />
      </providers>
    </membership>

    <roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
      <providers>
        <clear/>
        <add connectionStringName="GVConnectionString" applicationName="GV"
          name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
      </providers>
    </roleManager>

    <profile defaultProvider="AspNetSqlProfileProvider" enabled="true" inherits="YAF.Classes.Utils.YafUserProfile">
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider"
             connectionStringName="GVConnectionString"
             applicationName="GV"
             type="System.Web.Profile.SqlProfileProvider" />
      </providers>
      <properties>
        <add name="Theme" allowAnonymous="false" defaultValue="ASPNETBlue"/>
      </properties>
    </profile>

Thanks,
Marco Bianco

Sponsor
mmbianco
  •  mmbianco
  • 56.6% (Neutral)
  • YAF Forumling Topic Starter
2008-07-23T10:42:28Z
Bug found.

I believe I found the issue and the solution.

In MembershipHelper.cs, the GroupInGroupTable method, is returning true if the groupName is found in the groupTable DataTable.

After some debugging, and looking at the stored proc, yaf_group_member, it returns results like this:
1 Administrators 1
2 Guests 0
3 Registered 0

So the groupName is always returned, and therefor is always being returned true, even if the user has the Role in my Role provider, but not in Yaf.

Instead, I changed the GroupInGroupTable method to include another conditional, evaluating the "Member" field, which returns a 1 or a 0 depending on if the user is in the group.

The new method looks like this:

public static bool GroupInGroupTable( string groupName, DataTable groupTable )
		{
			foreach ( DataRow row in groupTable.Rows )
			{
                if (row["Name"].ToString() == groupName)
                {
                    if (row["Member"].ToString() == "1")
                        return true;
                }
			}

			return false;
		}

This seems to have solved my issue and now the user's role is being added to YAF based on the Role in my AspNet Role Provider.

Thanks again, and please let me know if this works or if I've missed something completely.

-Marco

Jaben
  •  Jaben
  • 100% (Exalted)
  • YAF Developer
2008-07-23T22:45:07Z
Thanks for finding the bug and solution.

Always appreciated.

The fix has been committed.

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved