SharePoint 2010 Timer Job. 激活发生错误 The EXECUTE permission was denied on the object 'proc_putObject'
2012-07-23 01:19
489 查看
激活SharePoint 2010 Timer Job 的Feature时,发生了错误:
The EXECUTE permission was denied on the object 'proc_putObject', database 'WSS_Config', schema 'dbo'
错误发生在激活过程中Timer Job 实例提交的时候
因为:autoMailJob.Update();
有人说在执行这个代码的时候加上权限提升的语句
加了,但是还是一样的错误。
最终的解决方案是将feature部署的范围改成场或应用程序,利用场管理员激活。
参考文章:
http://rnowik.com/SharePoint-EXECUTE-permission-was-denied-on-the-object-proc_putObject.aspx
SharePoint 的Timer job是这么写
新增一个类,集成Timer Job的基类:
新增一个feature用于控制Timer Job的启动和关闭
而且注意,在feature的代码中:
properties.Feature.Parent会因feature所激活的位置而改变
如果feature是web级的,那么SPWeb web = properties.Feature.Parent as SPWeb;
如果feature是site级的,那么SPSite site = properties.Feature.Parent as SPSite;
类推:
应用程序级的:SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
场级的:SPFarm farm = properties.Feature.Parent as SPFarm;
2013/8/10 补充:
部署的时候,使用的PS命令按如下步骤执行:
using 'SharePoint 2010 Management Shell' Tool
1.add solution
PS> add-spsolution -LiteralPath c:\test.wsp
2.deploy solution
PS> install-spsolution test.wsp -webappliction http://targetapp.net -force
3.restart sp timer service
PS> net stop sptimerv4
PS> net start sptimerv4
4.restart feature in the webpplication features list
调试程序的时候注意两个问题:
1、重新部署后,需要重新启动sptimerv4服务(定时器服务)
2、调试的进程是:OWSTIMER.exe(定时器的进程)
3、重新激活feature
The EXECUTE permission was denied on the object 'proc_putObject', database 'WSS_Config', schema 'dbo'
错误发生在激活过程中Timer Job 实例提交的时候
AutoMailJob autoMailJob = new AutoMailJob("SHFMOS_ReportMail_Job", webApp); SPDailySchedule dailySchedule = new SPDailySchedule(); dailySchedule.BeginHour = 19; dailySchedule.EndHour = 19; dailySchedule.EndMinute = 5; autoMailJob.Schedule = dailySchedule; autoMailJob.Update();
因为:autoMailJob.Update();
有人说在执行这个代码的时候加上权限提升的语句
SPSecurity.RunWithElevatedPrivileges(delegate() { //Your Code });
加了,但是还是一样的错误。
最终的解决方案是将feature部署的范围改成场或应用程序,利用场管理员激活。
参考文章:
http://rnowik.com/SharePoint-EXECUTE-permission-was-denied-on-the-object-proc_putObject.aspx
SharePoint 的Timer job是这么写
新增一个类,集成Timer Job的基类:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint.Administration; using Microsoft.SharePoint; using Cbw.SHFMOS.AutoMailReport.Handlers; namespace Cbw.SHFMOS.AutoMailReport { class AutoMailJob: SPJobDefinition { public AutoMailJob() : base() { } public AutoMailJob(string jobName, SPWebApplication webApp) : base(jobName, webApp, null, SPJobLockType.None) { this.Title = jobName; Log.Log2File("New AutoMailJob", this.Title); } protected override bool HasAdditionalUpdateAccess() { Log.Log2File("HasAdditionalUpdateAccess", this.Title); return true; } public override void Execute(Guid contentDbId) { try { // Put your job's code here. using (SPSite site = new SPSite("http://solution-ap.mycom.net/web")) using (SPWeb web = site.OpenWeb()) { //执行我的处理的逻辑,这里是发送邮件 FMOSReportHandler hdl = new FMOSReportHandler(); hdl.SendReportByZeRenZhuGuan(web); hdl.SendReportByCuoShiFzr(web); } } catch (Exception ex) { Log.Log2File("Exception Of Execute", ex.Message); } finally { } } } }
新增一个feature用于控制Timer Job的启动和关闭
using System;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Administration;
namespace Cbw.SHFMOS.AutoMailReport.Features.Feature1
{
/// <summary>
/// 此类用于处理在激活、停用、安装、卸载和升级功能的过程中引发的事件。
/// </summary>
/// <remarks>
/// 附加到此类的 GUID 可能会在打包期间使用,不应进行修改。
/// </remarks>
[Guid("5c439d15-5aad-4b8d-9a72-ca2e8c118c76")]
public class Feature1EventReceiver : SPFeatureReceiver
{
// 取消对以下方法的注释,以便处理激活某个功能后引发的事件。
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
//SPSecurity.RunWithElevatedPrivileges(delegate()
//{
Log.Log2File("webApp", webApp.Name);
foreach (SPJobDefinition job in webApp.JobDefinitions)
{
if (job.Name == "SHFMOS_ReportMail_Job")
{
job.Delete();
}
}
try
{AutoMailJob autoMailJob = new AutoMailJob("SHFMOS_ReportMail_Job", webApp); SPDailySchedule dailySchedule = new SPDailySchedule(); dailySchedule.BeginHour = 19; dailySchedule.EndHour = 19; dailySchedule.EndMinute = 5; autoMailJob.Schedule = dailySchedule; autoMailJob.Update();
}
catch (Exception err)
{
Log.Log2File("Update Exception", err.Message);
}
//});
}
// 取消对以下方法的注释,以便处理在停用某个功能前引发的事件。
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
//SPWeb web = properties.Feature.Parent as SPWeb;
// delete the job
//SPSecurity.RunWithElevatedPrivileges(delegate()
//{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
foreach (SPJobDefinition job in webApp.JobDefinitions)
{
if (job.Name == "SHFMOS_ReportMail_Job")
job.Delete();
}
//});
}
}
}
而且注意,在feature的代码中:
properties.Feature.Parent会因feature所激活的位置而改变
如果feature是web级的,那么SPWeb web = properties.Feature.Parent as SPWeb;
如果feature是site级的,那么SPSite site = properties.Feature.Parent as SPSite;
类推:
应用程序级的:SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
场级的:SPFarm farm = properties.Feature.Parent as SPFarm;
2013/8/10 补充:
部署的时候,使用的PS命令按如下步骤执行:
using 'SharePoint 2010 Management Shell' Tool
1.add solution
PS> add-spsolution -LiteralPath c:\test.wsp
2.deploy solution
PS> install-spsolution test.wsp -webappliction http://targetapp.net -force
3.restart sp timer service
PS> net stop sptimerv4
PS> net start sptimerv4
4.restart feature in the webpplication features list
调试程序的时候注意两个问题:
1、重新部署后,需要重新启动sptimerv4服务(定时器服务)
2、调试的进程是:OWSTIMER.exe(定时器的进程)
3、重新激活feature
相关文章推荐
- The EXECUTE permission was denied on the object 'xp_sqlagent_enum_jobs', database 'mssqlsystemresour
- php 执行mssql 里的语句,报错 The EXECUTE permission was denied on the object
- Visual studio 2005中调试遇到 EXECUTE permission denied on object 'sp_sdidebug', database 'master', owner 'dbo'
- The EXECUTE permission was denied on the object 'uf_date', database 'AA', schema 'dbo'.
- 同步复制错误:The process could not execute 'sp_replcmds' on 'servername'
- sql 问题 select permission denied on object 'pb_userinfo',database 'Maching',owner'ado' 解决方法
- 错误:A field or property with the name 'XXX' was not found on the selected data source 解决
- Java常见错误-The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- Myeclipse错误:Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project
- Opencv中调用FileStorage出现错误“Stack around the variable '*' was corrupted.”
- 包执行中提示错误:The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
- JSP的jar类错误;The superclass "javax.servlet.http.HttpServlet" was not found on......报错
- Linked Server: EXECUTE permission denied on object 'xp_prop_oledb_provider', database 'master', owner 'dbo'
- 错误:The superclass "javax.servlet.xxx" was not found on the Java Build Path
- VIEW SERVER STATE permission was denied on object 'server', database 'master'
- web API 错误处理The 'ObjectContent`1' type failed to serialize
- 解决The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path配置路径还是有错误标志的解决
- 继承QTreeWidgetItem发生error: 'staticMetaObject' is not a member of 'QTreeWidgetItem' 错误
- eclipse错误之Errors occurred during the build. Errors running builder 'JavaScript Validator' on project
- SharePoint 爬网错误:Access is denied. Check that the Default Content Access Account has access to this content && 本机无法访问moss 站点