Wednesday, January 6, 2021

Access denied in office 365 / SharePoint Online

  •  Login your Office 365 account.
  • Go to the SharePoint admin center.
  • Select Settings.
  • Under Custom Script choose:


  • Prevent users from running custom script on personal sites or Allow users to run custom script on personal sites.
  • Prevent users from running custom script on user created sites or Allow users to run custom script on self-service created sites.


var tenant = new Tenant(ctx);
    var SiteProp = tenant.GetSitePropertiesByUrl(http://devprasad007-admin.sharepoint.com, true);
    ctx.Load(SiteProp);
ctx.ExecuteQuery(); SiteProp.DenyAddAndCustomizePages = DenyAddAndCustomizePagesStatus.Disabled;
var result = SiteProp.Update();
ctx.Load(result); ctx.ExecuteQuery(); while (!result.IsComplete) { Thread.Sleep(result.PollingInterval); ctx.Load(result); ctx.ExecuteQuery(); 

    } 

No comments:

Post a Comment