Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

When i tried to Activate Feature of Timer Job It returns error : Access Denied

Scope of Feature is "Site"..

private static void CreateJob(SPSite site)       
 {          
  try        
    {
     SPSecurity.RunWithElevatedPrivileges(delegate()
     {               
     TenderTimerJob job = new TenderTimerJob(JobName, site.WebApplication);
     job.Properties.Add("SiteCollectionUrl", site.Url);
     SPMinuteSchedule minutes = new SPMinuteSchedule();
     minutes.BeginSecond = 0;
     minutes.Interval = 30;
     minutes.EndSecond = 30;
     job.Schedule = minutes;
     job.Update(); //Error Generates here
     });
    }
    catch (Exception ex){
     string str = ex.Message.ToString();
   }
}
share|improve this question

1 Answer

up vote 2 down vote accepted

When a timer job instance is created, it is persisted to the farm configuration database. Accessing this database for write purposes is a privileged operation; as a rule of thumb, only the farm service account (that is, the account under which OWSTIMER.EXE executes) or accounts that explicitly have the rights. So application pool account wouldn't work, as this this task requires farm level permissions. However, if you're developing in Visual Studio 2010 you can avoid automatic activation of features using Project-> Properties -> In the Active Deployment Configuration section select "No Activation"

share|improve this answer
Thank You Falak, – Torque Oct 17 '12 at 7:58
I also tried without SpSecurity and my account is registered as Farm service account.. But Still not Working..:( – Torque Oct 17 '12 at 8:05
Are you activating features using PowerShell or during development Visual Studio 2010? – Falak Mahmood Oct 17 '12 at 10:54
During Deployment from VS 2010.. right now it is not showing error while i deploy it.. but when i debug it and activate feature manually it is showing error "Access Denied".. – Torque Oct 17 '12 at 11:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.