Code Snippet
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.SharePoint.Client;
- using OfficeDevPnP.Core;
- using OfficeDevPnP.Core.Extensions;
- using Microsoft.SharePoint.Client.Taxonomy;
-
- namespace SP2016PnPCoreComponentDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
-
- string siteUrl = "http://c7395723754/";
- string userName = "administrator";
- string password = "xxxxxxxx";
- string domain = "AD2012";
- Guid featureID = new Guid("961d6a9c-4388-4cf2-9733-38ee8c89afd4");
-
- OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
-
- try
- {
-
- using (var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))
- {
-
- if (ctx.Web.IsFeatureActive(featureID))
- {
-
- ctx.Web.DeactivateFeature(featureID);
- }
- else
- {
-
- ctx.Web.ActivateFeature(featureID);
- }
- }
- }
-
- catch (Exception ex)
- {
- Console.WriteLine("Error Message: " + ex.Message);
- }
- }
- }
- }