Trying to access the Taxonomy in a SP 2013 solution (VS2012, C#), but always get a access denied (unauthorized access) on the TaxonomySession object if I am logged in as a "normal" user. If I am logged in as an termstore administrator everything works fine.
I even tried to clear the httpContext (http://www.communardo.de/home/techblog/2011/10/18/sharepoint-2010-der-termstore-und-der-priviligierte-nutzer/), but no success. The SPSite object for the TaxonomySession is even created as the SystemAccount.
All I need is read access for the solution.... cant't get it, what am I doing wrong?
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite thisSite = new SPSite(guid, SPUserToken.SystemAccount))
{
try
{
TaxonomySession taxonomySession = new TaxonomySession(thisSite, true);
TermStore termStore = taxonomySession.DefaultKeywordsTermStore;
Group navGroup = termStore.Groups[group];
TermSet termSet = navGroup.TermSets[termset];
_termset = termSet;
termCollection = termSet.Terms;
_termCollection = termCollection;
NavigationTermSet navigationTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, thisSite.RootWeb, StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
_navigationTermSet = navigationTermSet;
}
catch (Exception)
{
}//try
}//using
});//SPSecurity