Отвечено Error when registering Timer Job SPJobDefinition.Update - URGENT

  • Friday, February 15, 2008 7:42 PM
     
     

    I am trying to register my custom timer definition through object model code. i created a layout application and it has an aspx page to register the timer job. i am able to access my sharepoint object model objects but when method of Update is called i get the following exception

     

    System.Security.SecurityException: Access denied. at Microsoft.SharePoint.Administration.SPPersistedObject.Update() at Microsoft.SharePoint.Administration.SPJobDefinition.Update() at CustomTimerDefinition.MainCallToRegisterTimerJob() The Zone of the assembly that failed was: MyComputer

     

     

    my code is

     

    Dim oTimerJob As New CustomTimerDefinition("MyCustomTimer", oSite.WebApplication)

    'Every 5 minute

    Dim oSchedule As New SPMinuteSchedule()

    oSchedule.BeginSecond = 0

    oSchedule.EndSecond = 59

    oSchedule.Interval = 7 'minutes

    oTimerJob.Schedule = oSchedule

    oTimerJob.Update()    

     

    my CustomTimerDefinition is a class inheriting from SPJOBDefinition class and it is a GAC component. i know a way to register timer through Feature but i want to do it through object model where i also want to keep it in Layout application.

     

    any help on it?

     

     

All Replies

  • Sunday, February 17, 2008 11:27 PM
     
     

    Personally I have only ever registered timer jobs through features, but......

     

    the above sounds like it could be to do with the privelages required to register a timer job.

     

    Have you tried impersonating an admin user or elevating privelages.

  • Monday, February 18, 2008 11:17 PM
     
     Answered
    This problem is vaguely similar to an issue I had with BDC that I wrote about here:
    http://feeds.feedburner.com/~r/PaulGalvinsSharepointSpace/~3/230017467/cns!1CC1EDB3DAA9B8AA!687.entry

     

    It's not apples to apples, but might give you a lead.

     

    --Paul Galvin, Conchango
      RSS @ http://feeds.feedburner.com/PaulGalvinsSharepointSpace
      Web site @ http://paulgalvin.spaces.live.com

     

  • Tuesday, April 01, 2008 4:17 AM
     
     Answered

    Recently i switched back to this task and found that if you login on your sharepoint server desktop using Server FARM Admin account and activate the feature to register timer job through Command line stsadm command. it get register right away without any issue. Above error occur if you are not logged in on sharepoint server desktop with farm admin. I tried with farm admin account from a different machine but it keep failing but when i used stsadm on sharepoint server with farm admin account login, it works perfectly.