0

I have an event receiver attached to a list in SharePoint 2010. It is a solution built in C# in Visual Studio 2012. By adding items to the list from the browser, the user can add new Managed Metadata Terms, and by setting the label field, add labels to that term. Everything works fine on my dev machine. But, on our staging server, I can add a new term, but adding a label throws the error "the current user has insufficient permissions to perform this operation."

I should note that this is a local term set, and not a farm level one. I am a Contributor for the group. Also, if I go to the Term Store Management page, I can MANUALLY add a term set and a label, I just can't do it programmatically.

  • Mind to test with powershell under with end user creds? – Aziz Kabyshev Feb 29 '16 at 19:57
0

I discovered the cause of the problem. In my code behind, I was wrapping my code within a delegate (shown below), to run as the System account. This is normally required when editing a list, as the current user might not have the proper permissions. Once I removed the delegate wrapper and just updated the Term Set as the current user, my code works perfectly.

SPSecurity.RunWithElevatedPrivileges(delegate()
  {
    using (SPSite objElevatedSite = new SPSite(mobjWeb.Site.ID))
      {
      using (SPWeb objElevatedWeb = objElevatedSite.OpenWeb(mobjWeb.ID))
        {
          * SNIP *
        }
      }
    }
  });

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.