Running YetAnotherForum inside Sitecore

As I mentioned in the previous post, YetAnotherForum (YAF) cannot run inside Sitecore unless the code base of YAF is changed. So that’s exactly what I did. 

YetAnotherForum running in Sitecore

YetAnotherForum running in Sitecore

 You can find the changed YAF codebase in Sitecores trac:

http://trac.sitecore.net/YAFIntegration

So what does the code do? It allows you to run YAF in a Sitecore layout, on any Sitecore page you wish, using Sitecore extranet (or any other domain) users.

But let’s begin with the beginning. In order to run YAF inside a Sitecore web site at all, major changes are required in the web.config of your website. Basically it requires you to merge the YAF config files with the Sitecore config files. I have provided a sample web.config where I have merged the 2 config files together, as well as a complete description of all changes required.

After you have merged the web.configs, you will need to build the code and apply the code and binaries to the Sitecore solution. The documentation will help you with this.

What code changes have been made then? Since Sitecore and YAF both uses standard .net security providers, changes are relatively small (although widespread). YAF is capable of digesting Sitecore members and roles (users and groups) directly. But since the .net platform only allows one profile provider, the YAF profile provider need to inherit from Sitecore’s profile.

Another change are also implemented: The standard .net security model expects all users to have access to all parts of the website. Sitecore cannot live with that, as some users can access the client, and other can access the extranet. Sitecore deals with this issue in a brilliant, simple way, by prefixing users with the Sitecore domain name. So when Sitecore returns the Anonymous user, the username is extranet\Anonymous. To avoid displaying user names prefixed with the current domain name in YAF, the code wraps the MembershipUser class to ensure that only users from the current domain (usually extranet) can log into YAF, and that the domain name is not displayed in the username.

Users from the current Sitecore domain is displayed in YAF.

Users from the current Sitecore domain is displayed in YAF.

Since YAF is licensed under the GNU public license, so is this code. This means that you can use, change and share the code and any changes you make, as you wish.

 

8 Responses to “Running YetAnotherForum inside Sitecore”

  1. Using Sitecore users in YetAnotherForum « Brian Pedersen’s Sitecore and .NET Blog Says:

    [...] in the same IIS application (they can, if you change the YAF source code, which I will show in a later post), but with a little piece of open source code you are able to use the Sitecore users in [...]

  2. Controlling YetAnotherForum from inside Sitecore « Brian Pedersen’s Sitecore and .NET Blog Says:

    [...] One of my recent projects has been to run YetAnotherForum (YAF) inside a Sitecore website (read this earlier post). The changed YAF source can be found as an open source project at [...]

  3. Tom Says:

    Hi,

    I recently tried to implement your solution for using YAF in sitecore. I used sc version 6.0.2 and ever since i completed the install through your guide i get the following when trying to login to sitecore backend : Method not found: ‘Void Sitecore.Pipelines.LoggedIn.LoggedInArgs.set_Password(System.String)’.

    Any ideas?

  4. Tom Says:

    Nevermind i fixed it :)

  5. Jessica Hart Says:

    Hello Brian,

    I have successfully set up YetAnotherForum inside Sitecore before but this time it is has not gone so well.

    I have copied all the files in to my website and was able to go to the install page and create a forum and a new admin user.

    I now try to browse to http://mywebsite/yaf and I receive the following error

    [NullReferenceException: Object reference not set to an instance of an object.]
    YAF.Classes.Utils.SitecoreMembershipUser..ctor(MembershipUser innerUser) +41
    YAF.Classes.Utils.YafContext.InitUserAndPage() +2733
    YAF.Classes.Utils.YafContext.get_Page() +60
    YAF.Classes.Utils.YafContext.PageValueAsInt(String field) +46
    YAF.Classes.Utils.YafContext.get_PageUserID() +43

    Do you have any idea why?

    Thanks Jess

  6. briancaos Says:

    The “object reference” sounds like a null pointer somewhere. Maybe the code compilation has failed, or you have forgotten to put the compiled DLL’s in the /bin/ folder of Sitecore.
    I admit that having YAF to tun inside Sitecore is not an easy task, which is why I wrote the Documentation guideline (http://trac.sitecore.net/YAFIntegration/export/7/Trunk/YAF%20Integrated%20into%20Sitecore.docx) which you need to follow very carefully.

  7. TW Says:

    Hi Brian,
    I was able to use your code to integrate YAF into sitecore. However, I can’t get the forums to show up for anybody (Anonymous or registered user) except for the admin. Any ideas? I’ve tried setting every possible combination of permissions on the forum through the admin without luck.
    Thanks,
    TW

  8. briancaos Says:

    The permissions in YAF follow the domain in which YAf is running in, even though the domain is not visible from YAF.
    Maybe the users or groups you are using does not exist in the correct domain.

    To test this, you can use the old YAF login screen that still exists in YAF. As far as I remember you can call it using the ?g=login parameter.

    In the old login dialog you can log in any sitecore user. Just remember to include the domain name in the username when logging in (user “brian” in the domain “extranet” is logged in as “extranet\brian”).

    You can use the login dialog to test your users against the YAF security setup.

    Have you also noticed that YAF collects membership roles (groups) in security profiles, and it is these profiles that sets the security? To add security to a forum, you create a security profile (or use any of the existing ones).


Leave a Reply