命名空间:microsoft.graph
更新 SharePoint 和 OneDrive 的一个或多个租户级 设置 。
此 API 可用于以下国家级云部署。
| 全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
| ✅ |
✅ |
✅ |
❌ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 权限类型 |
最低特权权限 |
更高特权权限 |
| 委派(工作或学校帐户) |
SharePointTenantSettings.ReadWrite.All |
不可用。 |
| 委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
| 应用程序 |
SharePointTenantSettings.ReadWrite.All |
不可用。 |
代表用户调用时,该用户需要属于 SharePoint 管理员角色。 若要详细了解管理员角色,请参阅关于Microsoft 365 管理中心中的管理员角色。
HTTP 请求
PATCH /admin/sharepoint/settings
| 名称 |
说明 |
| Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
| Content-Type |
application/json. 必需。 |
请求正文
在请求正文中, 仅 提供要更新的属性的值。 请求正文中未包含的现有属性会保留其以前的值,或者根据对其他属性值的更改重新计算。
下表指定可更新的属性。
| 属性 |
类型 |
说明 |
| allowedDomainGuidsForSyncApp |
GUID 集合 |
OneDrive 同步应用的受信任域 GUID 集合。 |
| deletedUserPersonalSiteRetentionPeriodInDays |
Int32 |
用于保留已删除用户的 OneDrive 的天数。 |
| excludedFileExtensionsForSyncApp |
字符串集合 |
OneDrive 同步应用未上传的文件扩展名的集合。 |
| idleSessionSignOut |
microsoft.graph.idleSessionSignOut |
指定租户的空闲会话注销策略。 |
| imageTaggingOption |
imageTaggingChoice |
指定租户的映像标记选项。 可能的值包括 disabled、basic、enhanced。 |
| isCommentingOnSitePagesEnabled |
布尔值 |
指示是否允许对 SharePoint 中的新式网站页面进行注释。 |
| isFileActivityNotificationEnabled |
布尔值 |
指示是否为 OneDrive 事件启用推送通知。 |
| isLegacyAuthProtocolsEnabled |
布尔值 |
指示是否为租户启用旧式身份验证协议。 |
| isLoopEnabled |
布尔值 |
指示是否允许在 SharePoint 网站上使用 Fluid Framework。 |
| isMacSyncAppEnabled |
布尔值 |
指示是否可以使用适用于 Mac 的 OneDrive 同步 应用同步文件。 |
| isRequireAcceptingUserToMatchInvitedUserEnabled |
布尔值 |
指示来宾是否必须使用向其发送共享邀请的同一帐户登录。 |
| isResharingByExternalUsersEnabled |
布尔值 |
指示是否允许来宾重新共享他们不拥有的文件、文件夹和网站。 |
| isSharePointMobileNotificationEnabled |
布尔值 |
指示是否为 SharePoint 启用移动推送通知。 |
| isSharePointNewsfeedEnabled |
布尔值 |
指示是否允许在 SharePoint 中的新式网站页面上使用新闻源。 |
| isSiteCreationEnabled |
布尔值 |
指示是否允许用户创建网站。 |
| isSiteCreationUIEnabled |
布尔值 |
指示是否显示用于创建网站的 UI 命令。 |
| isSitePagesCreationEnabled |
布尔值 |
指示是否允许在 SharePoint 网站上创建新的新式页面。 |
| isSitesStorageLimitAutomatic |
布尔值 |
指示是自动管理站点存储空间,还是为每个站点设置了特定的存储限制。 |
| isSyncButtonHiddenOnPersonalSite |
布尔值 |
指示 OneDrive 中的同步按钮是否隐藏。 |
| isUnmanagedSyncAppForTenantRestricted |
布尔值 |
指示是否仅允许用户在加入特定域的电脑上同步文件。 |
| personalSiteDefaultStorageLimitInMB |
Int64 |
分配有合格许可证的所有新用户和现有用户的默认 OneDrive 存储限制。 以 MB) (MB 为单位。 |
| sharingAllowedDomainList |
字符串集合 |
允许在组织外部共享的电子邮件域的集合。 |
| sharingBlockedDomainList |
字符串集合 |
被阻止在组织外部共享的电子邮件域的集合。 |
| sharingCapability |
sharingCapabilities |
租户的共享功能。 可能的值包括 disabled、externalUserSharingOnly、externalUserAndGuestSharing、existingExternalUserSharingOnly。 |
| sharingDomainRestrictionMode |
sharingDomainRestrictionMode |
指定域的外部共享模式。 可能的值包括 none、allowList、blockList。 |
| siteCreationDefaultManagedPath |
String |
团队网站托管路径的值。 这是创建新团队网站的路径。 |
| siteCreationDefaultStorageLimitInMB |
Int32 |
创建新站点时的默认存储配额。 以 MB) (MB 为单位。 |
| tenantDefaultTimezone |
String |
新创建站点的租户的默认时区。 有关可能值的列表,请参阅 SPRegionalSettings.TimeZones 属性。 |
响应
如果成功,此方法在响应正文中返回响应 200 OK 代码和更新 的设置 对象。
示例
请求
以下示例显示了一个请求。
PATCH https://graph.microsoft.com/v1.0/admin/sharepoint/settings
Content-Type: application/json
Content-length: 1323
{
"deletedUserPersonalSiteRetentionPeriodInDays": 365,
"excludedFileExtensionsForSyncApp": [".mp3"],
"imageTaggingOption": "enhanced",
"isLegacyAuthProtocolsEnabled": true,
"isSitesStorageLimitAutomatic": false,
"isSyncButtonHiddenOnPersonalSite": false,
"isUnmanagedSyncAppForTenantRestricted": false,
"personalSiteDefaultStorageLimitInMB": 120000
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new SharepointSettings
{
DeletedUserPersonalSiteRetentionPeriodInDays = 365,
ExcludedFileExtensionsForSyncApp = new List<string>
{
".mp3",
},
ImageTaggingOption = ImageTaggingChoice.Enhanced,
IsLegacyAuthProtocolsEnabled = true,
IsSitesStorageLimitAutomatic = false,
IsSyncButtonHiddenOnPersonalSite = false,
IsUnmanagedSyncAppForTenantRestricted = false,
PersonalSiteDefaultStorageLimitInMB = 120000L,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Admin.Sharepoint.Settings.PatchAsync(requestBody);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewSharepointSettings()
deletedUserPersonalSiteRetentionPeriodInDays := int32(365)
requestBody.SetDeletedUserPersonalSiteRetentionPeriodInDays(&deletedUserPersonalSiteRetentionPeriodInDays)
excludedFileExtensionsForSyncApp := []string {
".mp3",
}
requestBody.SetExcludedFileExtensionsForSyncApp(excludedFileExtensionsForSyncApp)
imageTaggingOption := graphmodels.ENHANCED_IMAGETAGGINGCHOICE
requestBody.SetImageTaggingOption(&imageTaggingOption)
isLegacyAuthProtocolsEnabled := true
requestBody.SetIsLegacyAuthProtocolsEnabled(&isLegacyAuthProtocolsEnabled)
isSitesStorageLimitAutomatic := false
requestBody.SetIsSitesStorageLimitAutomatic(&isSitesStorageLimitAutomatic)
isSyncButtonHiddenOnPersonalSite := false
requestBody.SetIsSyncButtonHiddenOnPersonalSite(&isSyncButtonHiddenOnPersonalSite)
isUnmanagedSyncAppForTenantRestricted := false
requestBody.SetIsUnmanagedSyncAppForTenantRestricted(&isUnmanagedSyncAppForTenantRestricted)
personalSiteDefaultStorageLimitInMB := int64(120000)
requestBody.SetPersonalSiteDefaultStorageLimitInMB(&personalSiteDefaultStorageLimitInMB)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
settings, err := graphClient.Admin().Sharepoint().Settings().Patch(context.Background(), requestBody, nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SharepointSettings sharepointSettings = new SharepointSettings();
sharepointSettings.setDeletedUserPersonalSiteRetentionPeriodInDays(365);
LinkedList<String> excludedFileExtensionsForSyncApp = new LinkedList<String>();
excludedFileExtensionsForSyncApp.add(".mp3");
sharepointSettings.setExcludedFileExtensionsForSyncApp(excludedFileExtensionsForSyncApp);
sharepointSettings.setImageTaggingOption(ImageTaggingChoice.Enhanced);
sharepointSettings.setIsLegacyAuthProtocolsEnabled(true);
sharepointSettings.setIsSitesStorageLimitAutomatic(false);
sharepointSettings.setIsSyncButtonHiddenOnPersonalSite(false);
sharepointSettings.setIsUnmanagedSyncAppForTenantRestricted(false);
sharepointSettings.setPersonalSiteDefaultStorageLimitInMB(120000L);
SharepointSettings result = graphClient.admin().sharepoint().settings().patch(sharepointSettings);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const sharepointSettings = {
deletedUserPersonalSiteRetentionPeriodInDays: 365,
excludedFileExtensionsForSyncApp: ['.mp3'],
imageTaggingOption: 'enhanced',
isLegacyAuthProtocolsEnabled: true,
isSitesStorageLimitAutomatic: false,
isSyncButtonHiddenOnPersonalSite: false,
isUnmanagedSyncAppForTenantRestricted: false,
personalSiteDefaultStorageLimitInMB: 120000
};
await client.api('/admin/sharepoint/settings')
.update(sharepointSettings);
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\SharepointSettings;
use Microsoft\Graph\Generated\Models\ImageTaggingChoice;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new SharepointSettings();
$requestBody->setDeletedUserPersonalSiteRetentionPeriodInDays(365);
$requestBody->setExcludedFileExtensionsForSyncApp(['.mp3', ]);
$requestBody->setImageTaggingOption(new ImageTaggingChoice('enhanced'));
$requestBody->setIsLegacyAuthProtocolsEnabled(true);
$requestBody->setIsSitesStorageLimitAutomatic(false);
$requestBody->setIsSyncButtonHiddenOnPersonalSite(false);
$requestBody->setIsUnmanagedSyncAppForTenantRestricted(false);
$requestBody->setPersonalSiteDefaultStorageLimitInMB(120000);
$result = $graphServiceClient->admin()->sharepoint()->settings()->patch($requestBody)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Sites
$params = @{
deletedUserPersonalSiteRetentionPeriodInDays = 365
excludedFileExtensionsForSyncApp = @(
".mp3"
)
imageTaggingOption = "enhanced"
isLegacyAuthProtocolsEnabled = $true
isSitesStorageLimitAutomatic = $false
isSyncButtonHiddenOnPersonalSite = $false
isUnmanagedSyncAppForTenantRestricted = $false
personalSiteDefaultStorageLimitInMB = 120000
}
Update-MgAdminSharepointSetting -BodyParameter $params
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.sharepoint_settings import SharepointSettings
from msgraph.generated.models.image_tagging_choice import ImageTaggingChoice
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = SharepointSettings(
deleted_user_personal_site_retention_period_in_days = 365,
excluded_file_extensions_for_sync_app = [
".mp3",
],
image_tagging_option = ImageTaggingChoice.Enhanced,
is_legacy_auth_protocols_enabled = True,
is_sites_storage_limit_automatic = False,
is_sync_button_hidden_on_personal_site = False,
is_unmanaged_sync_app_for_tenant_restricted = False,
personal_site_default_storage_limit_in_m_b = 120000,
)
result = await graph_client.admin.sharepoint.settings.patch(request_body)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.sharepointSettings",
"allowedDomainGuidsForSyncApp": [
"bdd1ab9b-3fd0-4def-a761-ec8d7471732c",
"ad31vb6b-5zd0-7tyg-m231-kj8d6578432c"
],
"availableManagedPathsForSiteCreation": [
"/sites/",
"/teams/"
],
"deletedUserPersonalSiteRetentionPeriodInDays": 365,
"excludedFileExtensionsForSyncApp": [
".mp3"
],
"idleSessionSignOut": {
"isEnabled": true,
"warnAfterInSeconds": 120,
"signOutAfterInSeconds": 300
},
"imageTaggingOption": "basic",
"isCommentingOnSitePagesEnabled": true,
"isFileActivityNotificationEnabled": true,
"isLegacyAuthProtocolsEnabled": true,
"isLoopEnabled": true,
"isMacSyncAppEnabled": false,
"isRequireAcceptingUserToMatchInvitedUserEnabled": true,
"isResharingByExternalUsersEnabled": true,
"isSharePointMobileNotificationEnabled": true,
"isSharePointNewsfeedEnabled": true,
"isSiteCreationEnabled": true,
"isSiteCreationUIEnabled": true,
"isSitePagesCreationEnabled": true,
"isSitesStorageLimitAutomatic": false,
"isSyncButtonHiddenOnPersonalSite": false,
"isUnmanagedSyncAppForTenantRestricted": false,
"personalSiteDefaultStorageLimitInMB": 120000,
"sharingAllowedDomainList" : [
"contoso.com",
"fabrikam.com"
],
"sharingBlockedDomainList" : [
"contoso.com",
"fabrikam.com"
],
"sharingCapability": "externalUserAndGuestSharing",
"sharingDomainRestrictionMode": "allowList",
"siteCreationDefaultManagedPath": "/sites/",
"siteCreationDefaultStorageLimitInMB": 808034,
"tenantDefaultTimezone": "(UTC-05:00) Eastern Time (US and Canada)"
}