You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更新365组设置禁用外部访问时,Settings["{id}"]的取值疑问

How to Find the Settings["{id}"] Value for Disabling Microsoft 365 Group External Access

Got it, let's clear up that confusion right away. The {id} in Settings["{id}"] isn't the ID of your Microsoft 365 group—it's the ID of the specific group setting object that controls guest access for that group. Here's exactly how to get it and use it:

Step 1: Retrieve the Group's Existing Guest Access Setting

First, you need to fetch all settings applied to your target group, then filter for the one that manages guest access (it uses the template ID you already have: 08d542b9-071f-4e16-94b0-74abb372e3d9, which maps to the "Unified Group Guest Access" template).

Use this C# code to get the setting ID:

GraphServiceClient graphClient = new GraphServiceClient(authProvider);

// Replace {group-id} with your actual Microsoft 365 group ID
var groupSettings = await graphClient.Groups["{group-id}"].Settings
    .Request()
    .GetAsync();

// Find the setting that controls guest access
var guestAccessSetting = groupSettings.FirstOrDefault(s => s.TemplateId == "08d542b9-071f-4e16-94b0-74abb372e3d9");

if (guestAccessSetting != null)
{
    string settingId = guestAccessSetting.Id;
    // You'll use this settingId in your update call next
}

Step 2: Update the Setting to Disable Guest Access

Now plug that retrieved settingId into your original update code, replacing the {id} placeholder in Settings["{id}"]:

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

// Replace {group-id} with your group ID, and {setting-id} with the ID from Step 1
await graphClient.Groups["{group-id}"].Settings["{setting-id}"]
    .Request()
    .UpdateAsync(groupSetting);

Important Note: If No Guest Access Setting Exists

If your group doesn't already have this guest access setting object (it might not be created by default for some groups), you'll need to create it first before updating. Use this code to create the setting:

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

// Replace {group-id} with your group ID
var createdSetting = await graphClient.Groups["{group-id}"].Settings
    .Request()
    .AddAsync(newGuestSetting);

// Use createdSetting.Id if you need to update it later

内容的提问来源于stack exchange,提问作者Thomas Segato

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 08:02:29