在 365 群组上设置群组设置

Setting group settings on a 365 group

Microsoft 在其网站 (https://docs.microsoft.com/en-us/graph/api/groupsetting-update?view=graph-rest-1.0&tabs=csharp) 上有以下示例:

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var groupSetting = new GroupSetting
{
    DisplayName = "GroupSettings",
    TemplateId = "08d542b9-071f-4e16-94b0-74abb372e3d9",
    Values = new List<SettingValue>()
    {
        new SettingValue
        {
            Name = "AllowToAddGuests",
            Value = false
        }
    }
};

await graphClient.Groups["{id}"].Settings["{id}"]
    .Request()
    .UpdateAsync(groupSetting);

我们正在尝试禁用特定 365 群组的外部访问。我尝试了各种组合。但是Settings["{id}"]中的id应该是什么?

根据这个link说明,请求中的第一个{id}是组的标识(group id),第二个{id}是groupSetting对象的标识。

得到groupSetting, you need to create object with the groupSettingsTemplate and the group settings template id should be with the display name 'Group.Unified.Guest'. You cannot create,delete or update these templates but you can get the template id by using the below http call. https://graph.microsoft.com/v1.0/groupSettingTemplates

在创建 groupSettings 对象时,我们需要为您的条件指定以下值。

{

"name": "AllowGuestsToAccessGroups",

"value": "false"

}

您可以查看 Marc Lafleur 提到的此设置 here

Please check this Image

我使用的以下调用要求两个 id,第一个 id 是组 id,第二个 id 是 groupSettings 对象 id。

https://graph.microsoft.com/v1.0/groups/df951149-7379-44b9-9add-c114e2137d09/settings/87785da2-114b-428a-8983-e65efd24015f