In publishing sharepoint 2013 site, I am using managed navigation. I need to read value of custom property defined in term store and I also need to read value of description field. Is it possible to do it with read access to site?

I can obtain TaxonomyNavigationContext.Current.NavigationTerm and read basic info. But to read custom property and description, I need to get taxonomy term and I cannot use read-only cached navigation term.

TaxonomySession session = new TaxonomySession(site);
NavigationTerm navTerm = TaxonomyNavigationContext.Current.NavigationTerm;
Term term = navTerm.GetTaxonomyTerm(session); // I cannot do it due to permission level - user is read only user!
string val = term.CustomProperties["..."]; // this is what I need - read value of custom property - but without need to access Term class.

Is there a way how to read custom property from read-only navigation term with user assigned with read permissions?


You'll have to use an account which has the rights to access those terms. I would go for RunWithElevatedPrivileges - however, you'll first need to make sure no "remnants" from the current account are avaiable before accessing the ServiceApplication (TaxonomySession).

So I'd use:

var site = ....;
var navTerm = TaxonomyNavigationContext.Current.NavigationTerm;
string prop = null;
using (new CleanHttpContext())
SPSecurity.RunWithElevatedPrivileges(() =>
    using (var elevatedSite = new SPSite(site.ID))
        var session = new TaxonomySession(elevatedSite);
            var term = navTerm.GetAsEditable(session).GetTaxonomyTerm(session);
            if (!term.CustomProperties.TryGetValue("...", out prop))
                // no custom property.
                prop = string.Empty;
        catch (InvalidOperationException e)
            throw new ApplicationException("Unable to get the TaxonomyTerm from the NavigationTerm. Are you sure the IIS appPoolUser is also TermStoreAdminstrator?", e);

in combination with:

public class CleanHttpContext : IDisposable
    HttpContext oldContext;
    bool isDisposed;

    public CleanHttpContext()
        this.oldContext = HttpContext.Current;
        isDisposed = false;
        HttpContext.Current = null;

    public void Dispose()

    protected virtual void Dispose(bool disposing)
        if (disposing && !isDisposed)
            HttpContext.Current = oldContext;
            isDisposed = true;

And make sure your IIS AppPool-User is set as TermStoreAdministrator..


surround your code with elevated permissions:


                 //Code goes here


This works for all authentication types including anonymous users.

  • 1
    This will never work, SPSecurity.RunWithElevatedPrivileges does nothing for your TaxonomySession!
    – Nils
    Jun 24 '16 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.