We have a scenario on which we are creating site collections from a provider-hosted app. Some of these site collections will be used by external users. Is there a way from CSOM (server-side) to enable external sharing on the site collection? I haven't found any resources stating whether this is or not doable.

I'm trying to replicate the settings you can specify at the site collections page on the tenant admin site:

enter image description here


1 Answer 1


It is very possible look at the code provided by the office pnp team here: https://github.com/OfficeDev/PnP/blob/master/OfficeDevPnP.Core/OfficeDevPnP.Core/AppModelExtensions/TenantExtensions.cs#L414

    public static void SetSiteProperties(this Tenant tenant, string siteFullUrl,
        string title = null,
        bool? allowSelfServiceUpgrade = null,
        SharingCapabilities? sharingCapability = null,
        long? storageMaximumLevel = null,
        long? storageWarningLevel = null,
        double? userCodeMaximumLevel = null,
        double? userCodeWarningLevel = null
        var siteProps = tenant.GetSitePropertiesByUrl(siteFullUrl, true);
        if (siteProps != null)
            if (allowSelfServiceUpgrade != null)
                siteProps.AllowSelfServiceUpgrade = allowSelfServiceUpgrade.Value;
            if (sharingCapability != null)
                siteProps.SharingCapability = sharingCapability.Value;
            if (storageMaximumLevel != null)
                siteProps.StorageMaximumLevel = storageMaximumLevel.Value;
            if (storageWarningLevel != null)
                siteProps.StorageWarningLevel = storageMaximumLevel.Value;
            if (userCodeMaximumLevel != null)
                siteProps.UserCodeMaximumLevel = userCodeMaximumLevel.Value;
            if (userCodeWarningLevel != null)
                siteProps.UserCodeWarningLevel = userCodeWarningLevel.Value;
            if (title != null)
                siteProps.Title = title;

  • Thanks! Worked like a charm. I was looking at the Site object. Commented Apr 17, 2015 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.