18 thoughts on “How to Completely Disable External Sharing for a Single Office 365 Group”

  • Hi Laura,

    First of all thank you for the wonderfull article you are posting on your blog.
    We have created a WebPart that we have published to Teams that would give owners the possibility to modify the external sharing setting (“AllowToAddGuests”) from a tab in their Teams.
    We are experiencing a problem when we try to do the set of AllowToAddGuests using an owner account. With global admin works without any issue.
    The Teams app has :
    {
    “resource”: “Microsoft Graph”,
    “scope”: “Directory.ReadWrite.All”
    }
    As per MS Graph docs https://docs.microsoft.com/en-us/graph/api/directorysetting-update?view=graph-rest-beta&tabs=http should work fine with delegated.
    If I execute the graph call in the graph explorer using the owner user it gives the same access error.
    All permissions are granted at admin level.
    If a global admin is used, then all works fine.
    The error I am receiving is the following:
    {
    “error”: {
    “code”: “Authorization_RequestDenied”,
    “message”: “Insufficient privileges to complete the operation.”,
    “innerError”: {
    “date”: “2020-07-02T15:18:56”,
    “request-id”: “84fe9be9-a4b0-4023-93e6-68dd780ce2ea”
    }
    }
    }

    Has the owner the possibility to change the flag AllowToAddGuests or should I do this via an App reg?
    Thank you in advance for your answer.

    Regards,
    Anisia Pop

    • Hi Anisia,

      I’d try including also the “Directory.AccessAsUser.All” permission. If that doesn’t do the trick, then it definitely sounds like you need to be an O365 group admin to change that setting for groups when using delegated permissions. Instead of granting admin privileges, I’d call an Azure function from your SPFx web part, and in the Azure function change that setting for the group using app permissions.

      Laura

  • Hi Laura,

    Thanks for the article! Do you know if you can disable external sharing on a private channel, which has its own site collection, but not a separate group (from what I can tell).

    I’m using Graph to provision Teams and there are private channels as part of the provisioning that I’d like to limit external sharing. It doesn’t seem Graph has an endpoint for this. Will the CSOM example in your post also work for the private channel site? I’d love to use Graph if it’s possible, but I’m open to using the CSOM.

    Thanks,
    Doug

  • Hi Laura,
    What is the reason for adding an Azure AD property “AllowToAddGuests”? I’m not sure I understand the reasoning for that part.

    From what I’ve done, disabling the external sharing on the SharePoint site appears to give me all I need, or am I not testing the Groups invitation of an external party properly, to understand this Azure AD property fully.

    Thanks,
    Jason.

    • Hi Jason,

      The external sharing setting on the modern SharePoint Online team site is different than the AllowToAddGuests setting of the underlying Office 365 group. If you only disable external sharing on the SharePoint site, people can still invite guests to be members of the Office 365 group which means they can get access to Teams conversations, Planner plans, etc.. You can test adding a guest user to the group via Outlook.

      Laura

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.