0

I have created child term inside selected term from code behind. Now when I try to delete or create term with same user then I got "The current user has insufficient permissions to perform this operation." error.

Previously it was work but currently it is not working. I have given "Term Store Administrators" permission to my current user. I have written same code as I have written for at the time of creating new page.

My code block (I'm getting exception in term creation line):

        try
        {
    SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                TaxonomySession session = new TaxonomySession(sitecollection);
                TermStore termStore = session.TermStores["Managed Metadata Service"];
                Group group = termStore.Groups["GroupName"];
                TermSet sTermSet = group.TermSets["S"];

        if (!string.IsNullOrEmpty(hdnAllSelectedTermGuiIds.Value))
                    {
                        string[] newTerms = hdnAllSelectedTermGuiIds.Value.TrimEnd(',').Split(',');

                        for (int i = 0; i < newTerms.Length; i++)
                        {
                                try
                                {
                                    Guid termId = new Guid(newTerms[i]);
                                    Term termObj = structureTermSet.GetTerm(termId);
                                    Term newTerm = termObj.CreateTerm(hdnPageName.Value, langCode);
                                }
                                catch (Exception ex2)
                                {

                                }
                        }
                        sTermSet.TermStore.CommitAll();
                    }
            });
        }
        catch (Exception ex)
        {

        }

Is there any solution for this?

  • Are you executing the code with elevated privileges? – jpollar Jun 15 '15 at 16:26
  • I have tried with both run with elevated privileges and without privileges but not working. – Trimantra Software Solution Jun 16 '15 at 4:53
  • please post your code and the full exception being thrown. do you know which line is throwing the error? – jpollar Jun 16 '15 at 13:49
  • I have attached code....I'm getting error when try to create term. same code is for delete term also. – Trimantra Software Solution Jun 17 '15 at 5:17
  • I think this issue is of page layout. Because when I have tried with application page, it works. but it is not working in page layout. – Trimantra Software Solution Jun 17 '15 at 6:27
1

Make sure user had right permission, check at two places.

  1. Central admin -> Manage service application -> Managed meta data
    service - and the are on the page is call Term store Administrators
  2. The next place to check is to highlight your Manage metadata service which is located Central admin -> Manage service application and click on permissions on the ribbon and make sure the users your running the code with has the correct access

https://stackoverflow.com/questions/18956405/the-current-user-has-insufficient-permissions-to-perform-this-operation-add-ter

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.