4

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

Thanks!

3

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);
        tenant.Context.Load(siteProps);
        tenant.Context.ExecuteQueryRetry();
        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;

            siteProps.Update();
            tenant.Context.ExecuteQueryRetry();
        }
    }
  • Thanks! Worked like a charm. I was looking at the Site object. – Rodrigo Molinas Apr 17 '15 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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