0

I have a code in which I am updating a term of a term set [Event Receiver]

SPSecurity.RunWithElevatedPrivileges(delegate()
{
  //some stuff
   Term termToUpdate = MyMethodToGetTerm() //and its always returning the term
   termToUpdate.Name = "Update_Value"; //this line throws Unauthorized execption
}   

I am administrator of Term Store Group and able to add terms but not able to update it[Event Receiver].

Error message:The current user has insufficient permissions to perform this operation.

1 Answer 1

1

It would be nice to see, how (I mean, from which context) you receive your term in the MyMethodToGetTerm method, and how do you try to add / update it later. You wrote, you can add terms, but not update them, however it is not clear from the code, how you try to achieve that.

You should get and update the Term in an elevated context you receive via code like this one:

SPSecurity.RunWithElevatedPrivileges(
  () =>
    {
      using (var elevatedSite = new SPSite(site.ID, site.Zone))
      {
         ...
         var taxonomySession = new TaxonomySession(elevatedSite);
         ...
      }
    });
1
  • Yes it is. But the above code is written in event receiver and which is throwing this error.
    – nbi
    Jan 14, 2015 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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