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.
You can find the changed YAF codebase in Sitecores marketplace:
http://marketplace.sitecore.net/en/Modules/YAF_integration.aspx
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.
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.
Pingback: Using Sitecore users in YetAnotherForum « Brian Pedersen’s Sitecore and .NET Blog
Pingback: Controlling YetAnotherForum from inside Sitecore « Brian Pedersen’s Sitecore and .NET Blog
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?
LikeLike
Nevermind i fixed it :)
LikeLike
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
LikeLike
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.
LikeLike
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
LikeLike
The permissions in YAF follow the domain in which Sitecore 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).
LikeLike
Hi Brian
the guide to the integration is for sitecore6. Is it possible to integrate YAF into sitecore5? If so, is there a giude for doing this?
Stefan
LikeLike
Sitecore 5 uses a different security model (a homebrewn model), as opposed to Sitecore 6 which uses the standard .net security model. Therefore it is not possible to integrate YAF into Sitecore 5.
You should read this article instead: https://briancaos.wordpress.com/2009/05/27/using-sitecore-users-in-yetanotherforum/
LikeLike
Brian,
I’ve just implemented a “DisplayName” system in YAF v1.9.4 RC2 (will be released in v1.9.4 final). It allows a custom provider that handles the user display name for YAF. Basically, the integration is easier since you won’t need to wrap the membership provider anymore.
Regards,
Jaben
YAF Lead Developer
LikeLike
I’m looking around for a solution why I cannot compile my solution after integrating the YAF into Sitecore.
Currently the YAF.Editor is not found at several codebehind files, despite the fact that the YAF.Editor is set up with a tagprefix in the web.config, as instructed. Argh.
LikeLike
I’ve just implemented the SitecoreYAF project into a Sitecore 6.2 solution. However, when I compile I get an error stating:
‘The type or namespace name ‘Editor’ does not exist in the namespace ‘YAF’ (are you missing an assembly reference?)
The error doesn’t occur in your project, but after it’s implemented in my current solution.
I’ve looked at the YAF forum and seen an mention of the same issue there (http://forum.yetanotherforum.net/yaf_postsm40743_1-9-3-RC2-Editor-does-not-exist-in-the-namespace-YAF.aspx#post40743). However, I’ve yet to discover why the error occurs on just the Editor.
LikeLike
Hi Brian,
I have implemented YAF into SiteCore but within SiteCore I have it configured withe the CRM provider. I’m assuming it’s not recognizing the CRM domain I’m logged in as because it always defaults back to the anonymous user.
You mentioned YAF looks at the SiteCore cookie. What specifically does it look at and how is it properly generated?
Thanks
Steve
LikeLike
Hi Brian,
I successfully setup your modified yaf into our sitecore solution, but when I try to open the forum via mysite/yaf, it gives me this kind of error:
Unknown server tag ‘YAF:Forum’.
I checked the the namespace part in web.config, they are all the same as in your sample config file.
Do you have any idea what that is?
Thanks,
Ivan
LikeLike
YAF:Forum is found in the default.aspx of the YAF code. It needs to be able to find it’s code in the App_Code folder in the root of the site. Inside the App_Code folder, YAF have placed the Forum.cs file that contain the code for the forum.
LikeLike
Thanks Brian,
Yes, I found that I missed that foloder. But I got the same error as Jess Hart got in the previous post.
NullReferenceException: Object reference not set to an instance of an object.]
YAF.Classes.Utils.SitecoreMembershipUser..ctor(MembershipUser innerUser) in C:\inetpub\YAFIntegration\Trunk\YAF.Classes\YAF.Classes.Utils\Sitecore\SitecoreMembershipUser.cs:19
YAF.Classes.Utils.YafContext.InitUserAndPage() in C:\inetpub\YAFIntegration\Trunk\YAF.Classes\YAF.Classes.Utils\Context.cs:994
YAF.Classes.Utils.YafContext.get_Page() in C:\inetpub\YAFIntegration\Trunk\YAF.Classes\YAF.Classes.Utils\Context.cs:176
YAF.Classes.Utils.YafContext.PageValueAsInt(String field) in C:\inetpub\YAFIntegration\Trunk\YAF.Classes\YAF.Classes.Utils\Context.cs:376
YAF.Classes.Utils.YafContext.get_PageUserID() in C:\inetpub\YAFIntegration\Trunk\YAF.Classes\YAF.Classes.Utils\Context.cs:522
I checked all the dlls have been moved over. Do you have any idea what that could be?
Thanks,
Ivan
LikeLike
I am getting this error when I try to bring up the forum:
The type or namespace name ‘YafDateTime’ could not be found (are you missing a using directive or an assembly reference?)
LikeLike
The YafDateTime resides in the YAF.Classes.Utils.dll. Make sure this DLL is compiled, and the dll is moved to the /bin/ folder of the website.
LikeLike
Hi Brian,
Following a seemingly successful YAF integration, I have tried to install the optional package. But when I try and use the admin tool from the sitecore start menu, I am seeing the error identified in various other posts:
NullReferenceException: Object reference not set to an instance of an object.]
YAF.Classes.Utils.SitecoreMembershipUser..ctor(MembershipUser innerUser)
I have followed the document(s) closely and ensured that all dll’s are compiled and in the website’s /bin folder, all appears to be correct.
When compiling YAF I did have to change a couple of references to use the .Net 3.5 versions of the following dll’s:
AjaxControlToolkit.dll
CookComputing.XmlRpcV2.dll
System.Web.Extensions.dll
Installing the optional package then tried to overwrite YAF.Sitecore.dll in the website’s /bin folder.
Could this be something to do with the error I am seeing?
Thanks,
Stuart
LikeLike
Just some additional information to the above – during the YAF integration I created a new admin user (which would not be able to log in using the sitecore extranet), I’m guessing this has something to do with it! The full error I am seeing is:
[NullReferenceException: Object reference not set to an instance of an object.] YAF.Classes.Utils.SitecoreMembershipUser..ctor(MembershipUser innerUser) +41 YAF.Classes.Utils.SitecoreMembershipUser.get_ForumAdmin() +337
YAF.Classes.Utils.YafContext.InitUserAndPage() +2733
YAF.Classes.Utils.YafContext.get_Page() +60
YAF.Classes.Utils.YafContext.get_IsSuspended() +46
YAF.Classes.Base.ForumPage.ForumPage_Init(Object sender, EventArgs e) +586
System.Web.UI.Control.OnInit(EventArgs e) +99
System.Web.UI.UserControl.OnInit(EventArgs e) +77
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
System.Web.UI.ControlCollection.Add(Control child) +80
YAF.Forum.Forum_Load(Object sender, EventArgs e) +738
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Any ideas? Thanks,
Stuart
LikeLike
Hi all, first a reply to potentially help people out. We were able to initially integrate http://trac.sitecore.net/YAFIntegration into our Sitecore 6.4.1 website by building it from source and making some small code changes to get it to compile, namely by changing some of the im_ code behind files to pass in SitecoreMembershipUser instead of just MembershipUser.
Secondly, Brian, I’m running into the same kind of issue as Steve, but I’m not using a CRM domain, I’m using a different domain. Steve said: “I’m assuming it’s not recognizing the CRM domain I’m logged in as because it always defaults back to the anonymous user” (comment #511). I see the same. I also noticed Brian that you said: “the code wraps the MembershipUser class to ensure that only users from the current domain (usually extranet) can log into YAF…” . So this may be the reason.
Have you been able to get a non-extranet Sitecore domain user to be recognized by YAF (i.e. logged into YAF), and if so, how? All I get is Anonymous…and even on the admin screen it can see roles from my custom domain but not users.
Thanks,
David
LikeLike
Hi David,
we have integrated YAF as per your docs, but when I maunch the YAF Admin from Sitecore desktop I get an infinite redirect loop.
The url “URL:http://cms.salespulse.slb.com/sitecore/shell/sitecore/content/Applications/YAF.aspx?g=info&i=7” tries to get redirected to itself and goes into an infinite loop.
Please can you suggest why this is? I’ve checked security on the YAF item in the Core database, looks OK. Please can you help us?
Thanks and regards,
Rahul
LikeLike
Hi David,
I get a infinite redirect loop on http://mysite/sitecore/shell/sitecore/content/Applications/YAF.aspx?g=info&i=7” when I click on the “YAF Administration” Start menu button in the sitecore desktop. I’ve checked the sitecore modules/web/admin.aspx and the permissions on YAF/Admin item, no problem there. I even moved your optional module to sitecore modules/shell so that we remain in the ‘sitecore’ domain but no luck.
I’m using the Active Directory module in Sitecore, on an Intranet website. I’ve got users with domain\username (for example “LOL\Waltdisney”) logging into Sitecore content-editor and also the extranet Website at the same time. Is there a problem with having a Active Directory membership provider at the same time? How does YAF work with the LightLDAP.SitecoreADMembershipProvider and the Sitecore.Security.SwitchingMembershipProvider?
Why do you “avoid having users from a different domain logging into YAF”?
Even if YAF runs in an “extranet” domain, the Admin.aspx program runs inside the sitecore domain isn’t it?
Can you help?
Thanks and regards,
Rahul
LikeLike
Rahul,
I wanted to at least respond to your post even though I don’t have the answer immediately. However I wanted you to know we made some further modifications to YAF and it seems to work quite well for us and it passed our light level of testing.
I would be happy to explain the changes we did. Time will be a limiter but I’ll try to do what I can reasonably. Please feel free to ping me at d mead att nav igation artsdotcom – this is phonetic to hopefully avoid spam ; please remove all spaces and change the att to the at-sign, etc.
Thanks,
David
LikeLike
Hi David, Rahul
I installed YAF on a intranet site that’s using Active directory module. I have the same issue as Rahul stated in his post. I created a login page just for testing and when I log in as an extranet user, the user get created in YAF and it displays the user when on forums but when I log in as anotherdomain / user, the yaf just logged me in as Anonymous..
Do you have any idea what could be the problem and is there an issue having both YAF and Active Directory?
Thanks
Abdel
LikeLike
Hello, Brian.
Sitecore Trac (trac.sitecore.net) is no longer available. A new Sitecore Marketplace replace Trac. Is more powerful.
YAF Integration shared source module has been moved to Sitecore Marketplace. The new URL is
http://marketplace.sitecore.net/en/Modules/YAF_integration.aspx
Could you please replace the old URL (http://trac.sitecore.net/YAFIntegration) with a new one?
Best Wishes, Oleg
LikeLike
Hi Brian!
We are using your YAF Sitecore integration as noted from Oleg above, and I’m getting an unrecognized Tag prefix error. I believe I have it set up properly in the web.config but I cannot seem to figure out why Sitecore won’t recognize the tag.
Any suggestions?
Thanks!
Kris
LikeLike
So, I fixed the Tag prefix error by converting to a web application. (Hey, it was a duh moment! Sorry!) and now I’m getting:
Cannot implicitly convert type ‘System.Web.Security.MembershipUser’ to ‘YAF.Classes.Utils.SitecoreMembershipUser’. An explicit conversion exists (are you missing a cast?)
Please help!
Thanks,
Kris
LikeLike
Well, if nothing else, anyone having difficulty setting this up is getting my “play-by-play” *grin*
I finally dropped the code into the Sitecore project and removed the YAF DLL’s.
Now, I’m getting the dreaded Unknown server tag ‘YAF:Forum’.
I’ll let you know when I figure that one out, unless someone can help me!
Thanks for your patience!
Kris
LikeLike
AH HA!
I had to change the web.config assembly from the YAF assembly to “Web.Application”
Hope this helps someone else!
Good luck!
Kris
LikeLike
Has anyone tried this on a recent version of Sitecore (6.5, 6.6 or 7)?
LikeLike