YAFLogo

ryaneastabrook
13 years ago
I am attempting (still) to integrate YAF into another project I have that uses a custom membership provider on its own. I have now replaced the default YAF provider with my membership provider from my other project. When I attempt to login I'm getting a "failed to find guest user" server error.

I'm logging in with a valid user account from my other app (I can debug and see that it has been successful on the UserPageBase.cs InitUserAndpage() method....however, once it hits LegacyDb.pageload it returns null. I'm assuming something needs to be mapped in the database or something for this new user, but I don't know what, ideas? Or, do you have any ideas why this is happening? The other forum posts that refer to the "failed to find guest user" do not solve my particular issue.

I am using the most current source code from SVN (I have also tried the latest stable release).

Thanks for any detailed answers or feedback!

Sponsor
yesimahuman
13 years ago
I am having the same issue. The tables seem to be fine. The previous answers saying that the guest user group got messed up don't seem to be accurate in this case (I have a Guest user with groupid 2 pointing to the "Guests" group.

I am auto registering users from facebook using this code:

          MembershipCreateStatus status;
          var user = yafMembershipProvider.CreateUser(username, Membership.GeneratePassword(32, 16),
            email, "This question has no answer.  Please contact us at help@mycompany.com",
            Membership.GeneratePassword(64, 30), true, null, out status);

          int? userID = RoleMembershipHelper.CreateForumUser(user, username, YafContext.Current.PageBoardID);

I am calling FormsAuthentication.SetAuthCookie(username, true) after creating the user and then I get this error until I clear my cookies.

Any ideas?

Thanks.

lazoras
  • lazoras
  • 51.8% (Neutral)
  • YAF Forumling
12 years ago
Has anyone found a solution to this problem yet?
bbobb
  • bbobb
  • 100% (Exalted)
  • YAF Developer
12 years ago
Guest is not a part of Membership, Roles or Profile providers.
psh84
  • psh84
  • 50.6% (Neutral)
  • YAF Forumling
12 years ago
I encountered the issue #ryaneastabrook described exactly. We had our own existing membership provider for our external application and when attempting to "wire up" YAF to use our membership provider we encountered problems immediately. Browsing the forum while unauthenticated worked perfectly fine, but as soon as I logged in using an account from our existing application, I got the "Unable to find the Guest User!" error message. I stepped through the authentication process and verified that the account was being validated correctly and it was. I literally spent hours googling that error message and wasn't able to find a solution but there were posts within this forum that pointed me in the right direction - ASP.Net Roles and the YAF role provider.

A little about YAF roles (from my experience) - when YAF membership accounts are created through the "Register" section of the YAF app, they're assigned the "Registered" role found in the "yaf_prov_Role" table in the YAF database. All YAF accounts intended to have write permissions in the forum require this role assignment.

Now since I was using the role provider for our existing application and not the default YAF role provider, I knew the "Registered" role didn't exist in our "aspnet_roles" table in our database. I decided I'd try inserting the "Registered" role into our existing "aspnet_roles" table using the id of the role in the "yaf_prov_Role" table. Next, in the code of the account creation/registration section of our external application, I assigned the newly created "Registered" role to the membership account. The next time I logged into the YAF app with an account created in our existing application, everything worked fine - no guest error. I also made sure to assign the new "Registered" role to our existing accounts.

It turned out that the root cause of the error didn't really have anything to do with the Guest account itself, thus, the error message is a bit misleading. To summarize, all I did was add the "Registered" role to the "aspnet_roles" table in our existing database (using the same role id from the "yaf_prov_role" table) and then assign the rule to our existing and new accounts.

I hope my own experience can be of some help to others who might be encountering the same problem.