SP2013 Set-SPSite标记站点,无访问权限 [英] SP2013 Set-SPSite Marking Site with NO ACCESS
问题描述
大家好,
SP2013内部部署具有Set-SPSite Powershell命令来设置以下属性:
SP2013 on-prem has Set-SPSite Powershell command to set properties like:
- 未锁定. .
- Not locked .
-
Adding content prevented
是否可以通过租户API(CSOM)或通过任何Admin REST API调用而不是Powershell Commandlet来实现或设置站点属性?我们正在尝试将网站自动标记为只读"或不访问",作为网站生命周期的一部分.
Is there a way to achieve or set the site properties thru Tenant API (CSOM) or thru any Admin REST API call instead of Powershell commandlet? We are trying to mark the site as either READ ONLY or NO ACCESS as part of the Site Lifecycle automatically.
Ana
推荐答案
请尝试使用以下代码并检查您的要求:
Please try to use the below code and check for your requirement:
using (var clientContext = new ClientContext(tenantUrl)) {
clientContext.Credentials = spoCredentials;
var tenant = new Tenant(clientContext);
var siteProperties = tenant.GetSitePropertiesByUrl(siteUrl, true);
clientContext.Load(siteProperties);
clientContext.ExecuteQuery();
Console.WriteLine("LockState: {0}", siteProperties.LockState);
siteProperties.LockState = "NoAccess";
siteProperties.Update();
clientContext.ExecuteQuery();
}
注意: 这不会使它只读.基本上,它将阻止所有访问.
Note: This will not make it READ ONLY. Basically, it will block all access.
谢谢
Siva
这篇关于SP2013 Set-SPSite标记站点,无访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!