Forum Discussion

davidrosmon's avatar
davidrosmon
Copper Contributor
Mar 13, 2019

Issue Setting Domains AllowList for Sharing in CSOM API

Hi all   We found an issue trying to set allowed domains for sharing through CSOM. When setting the site property's SharingDomainRestrictionMode to AllowList and setting the SharingAllowedDomainLis...
  • davidrosmon's avatar
    May 09, 2019

    If you want to switch between block and allow mode, you need to set the mode to None, then execute and the set it to whatever your looking to do.

    var siteProperties = tenant.GetSitePropertiesByUrl(siteCollectionUrl, false);
    ctx.Load(siteProperties, s => s.SharingDomainRestrictionMode, s => s.SharingAllowedDomainList);
    ctx.ExecuteQueryRetry();

    siteProperties.SharingDomainRestrictionMode = SharingDomainRestrictionModes.None;
    siteProperties.Update();
    ctx.ExecuteQueryRetry();

    siteProperties.SharingDomainRestrictionMode = SharingDomainRestrictionModes.AllowList;
    siteProperties.SharingAllowedDomainList = domainString;
    siteProperties.Update();
    ctx.ExecuteQueryRetry();

Resources