Let’s assume you need to do this from an application page, you need to use the SPSecurity and RunWithElevatedPrivileges as usual.
SPSecurity.RunWithElevatedPrivileges(() => { using (SPSite elevatedSite = new SPSite(site.ID, site.Zone)) { TaxonomySession taxonomySession = new TaxonomySession(elevatedSite); //Do here the update work } });Ok! This code simply doesn’t work: this is due to the fact you have to switch the context to the service account one like this.
SPSecurity.RunWithElevatedPrivileges(() => { using (SPSite elevatedSite = new SPSite(site.ID, site.Zone)) { HttpContext oldContext = HttpContext.Current; try { HttpContext.Current = null; TaxonomySession taxonomySession = new TaxonomySession(elevatedSite); //Do here the update work } finally { HttpContext.Current = oldContext; } } });le jeux sont fait
0 commenti:
Post a Comment
Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).