• mmbianco
  • 56.6% (Neutral)
  • YAF Forumling Topic Starter
14 years ago

I have moved this to it's own topic, from here:


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">
      <add name="GMembershipProvider"
         description="Stores and retrieves membership data from SQL Server"

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

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


Marco Bianco


  • mmbianco
  • 56.6% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
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.


  • Jaben
  • 100% (Exalted)
  • YAF Developer
14 years ago
Thanks for finding the bug and solution.

Always appreciated.

The fix has been committed.