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;
-
- namespace SP2016PnPCoreComponentDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
-
- string siteUrl = "http://c7395723754/";
- string userName = "administrator";
- string password = "Mf165Nz2WV";
- string domain = "AD2012";
- string groupName = "Group created using PnP";
- string roleDefinitionName = "Design";
- bool removeExistingPermLevel = false;
- OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
-
- try
- {
-
- using (var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))
- {
-
- ctx.Web.RemovePermissionLevelFromGroup(groupName, roleDefinitionName, removeExistingPermLevel);
- ctx.Web.RemovePermissionLevelFromGroup(groupName, RoleType.Contributor, removeExistingPermLevel);
- }
- }
-
- catch (Exception ex)
- {
- Console.WriteLine("Error Message: " + ex.Message);
- }
- }
- }
- }