我正在尝试从代码中设置ChangeLogretentionPeriod STSADM属性,通常从SP PowerShell设置。

从代码设置此属性的最佳方法是什么?

背景:我正在利用来自基础实例的SP 2010审计,并尝试为管理员构建UI前端,以便轻松设置审计设置(因为UI不可用基础)。

有帮助吗?

解决方案

Here is the MSDN,

basically

using(var site = new SPSite(SPContext.Current.Site.ID))
{
    var webapp = site.WebApplication;
    webapp.ChangeLogRetentionPeriod = new TimeSpan(1,0,0,0); // meaning 1 day
}

The code must be executed by a Farm Administrator account, so you might need to do som impersonification in the new SPSite statement, like new SPSite(SPContext.Current.Site.ID, farmAdminUserRetrievedBefore.UserToken)

许可以下: CC-BY-SA归因
scroll top