Skip to content

Instantly share code, notes, and snippets.

@vman
Last active July 18, 2018 13:43
Show Gist options
  • Select an option

  • Save vman/129190113ea4e8405554b81280482161 to your computer and use it in GitHub Desktop.

Select an option

Save vman/129190113ea4e8405554b81280482161 to your computer and use it in GitHub Desktop.
SharePoint Online: Add TermStore Managers and Contributors using CSOM
ClientContext clientContext = GetClientContext();
var taxonomySession = TaxonomySession.GetTaxonomySession(clientContext);
var termStore = taxonomySession.GetDefaultSiteCollectionTermStore();
var myTermGroup = termStore.Groups.GetByName("My Custom Terms Group");
//Add Group Managers
myTermGroup.AddGroupManager("i:0#.f|membership|[email protected]");
//Add Group Contributors
myTermGroup.AddContributor("i:0#.f|membership|[email protected]");
myTermGroup.AddContributor("i:0#.f|membership|[email protected]");
clientContext.Load(myTermGroup, group => group.GroupManagerPrincipalNames, group => group.ContributorPrincipalNames);
clientContext.ExecuteQuery();
Console.WriteLine("Group Managers: ");
foreach (var manager in myTermGroup.GroupManagerPrincipalNames)
{
Console.WriteLine(manager);
}
Console.WriteLine("Group Contributors: ");
foreach (var contributors in myTermGroup.ContributorPrincipalNames)
{
Console.WriteLine(contributors);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment