title: The current user has insufficient permissions to perform this operation. Add Termset in sharepoint
body: <p>I am trying to bind a field to a termset, and if the termset does not exist I want to create it by code. However, even when the code is running with elevated privileges I get the following exception.</p>
  
  <p>The current user has insufficient permissions to perform this operation.</p>
  
  <pre><code>public static void BindTaxonomyField(string taxonomyFieldId, string taxonomyNoteFieldId, string termSetName, string termGroup, SPWeb web)
          {
              try
              {
                  if (web != null)
                  {
                      // get the taxonomyfield from the sitecollection
                      var field = web.Fields[new Guid(taxonomyFieldId)] as TaxonomyField;
                      if (field != null)
                      {
                          // attach the note field
                          field.TextField = new Guid(taxonomyNoteFieldId);
  
                          // set up the field for my termstore
                          var session = new TaxonomySession(web.Site);
  
                          if (session.TermStores.Count &gt; 0)
                          {
                              // get termstore values
                              TermStore ts = session.TermStores[0];
                              Group group = GetGroup(termGroup, ts);
                              if (group == null)
                              {
                                  ts.CreateGroup(termGroup);
                                  //throw new Exception("Group was not found in the termstore");
                              }
  
  // ReSharper disable PossibleNullReferenceException
                              TermSet termSet = group.TermSets.Any(s =&gt; s.Name == termSetName) ? group.TermSets[termSetName] : group.CreateTermSet(termSetName);
  // ReSharper restore PossibleNullReferenceException
  
                              //TermSet termSet = group.TermSets[termSetName];
  
                              // actually setup the field for using the TermStore
                              field.SspId = ts.Id;
                              field.TermSetId = termSet.Id;
                          }
  
                          field.Update();
                      }
                  }
              }
              catch (Exception ex)
              {
  
              }
          }
  
  
   private void BindColumnsToTermStore(string url)
          {
              try
              {
                  SPSecurity.RunWithElevatedPrivileges(delegate
                  {
                      using (var site = new SPSite(url))
                      {
                          using (SPWeb web = site.OpenWeb())
                          {
                              if (!web.AllowUnsafeUpdates)
                                  web.AllowUnsafeUpdates = true;
  
  
  
                              BindTaxonomyField("EF810CD2-F2D2-4BD2-9ABF-C19815F13568",
                                                                             "67E6E777-0D1E-4840-B858-17400CFABD14",
                                                                             "Business Audience", "IctDocumentation",
                                                                             web);
  
  
                              web.AllowUnsafeUpdates = false;
                          }
                      }
                  });
              }
  </code></pre>