SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an SPJobDefinition (WSS) that runs each hour. Based on some values, and if met, it adds an item to the calendar list. This calendar list has an event receiver attached to the ItemAdded event.

When the job does trigger and adds the item, parts of the code executes. What I mean is that it wont' write to the eventlog and it seems to have problems reading from the web.config file.

If I manually add an item to the calendar list, using my credentials, everything works fine. That is, I have events in the eventlog and the items are read from the web.config file.

I can see where System Account is adding the item in the Calendar list. I've tried adding System Account to the groups with full control and I'm still having a problem.

Is there something else I have to look at to get this to work? I've checked the pool user and it's Network Service; I've since added them to the group as well.

I'm not sure where else to look.


Updated (this is the code I use to write to the eventlog)

  System.Security.Principal.WindowsImpersonationContext wic = System.Security.Principal.WindowsIdentity.Impersonate(IntPtr.Zero);
  EventLog.WriteEntry(source, message, type);
catch (Exception)
share|improve this question
Timer jobs are run by the account running OWSTIMER.exe. Did you add that account with appropriate permissions? – Trevor Seward May 14 '12 at 18:19
up vote 1 down vote accepted

Writing to the eventlog could be due to missing windows permissions.

The timer job runs in a windows service which doesn't have a web.config. An event receiver runs in whatever process causing the event. So if you try to read the web.config of the current process it'll fail.

If you try to reach out into the file system to read the web.config, then it might be windows permissions again.

Adding users to SharePoint groups can't help you with access to EventLog or files, these are windows objects not SharePoint objects.

When running from a Timer Job the Impersonate(IntPtr.Zero); isn't changing anything. It impersonates the process account which is already the one running.

share|improve this answer
Hi Per - I updated my original question to show the code I use to write to the EventLog. You think that might still be the problem? – DrZ May 14 '12 at 18:23
Added comments in answer – Per Jakobsen May 14 '12 at 18:45
So it sounds like writing to the EventLog is out of the question for this process. As for the web.config file, it sounds like I have to come up with another solution. Thank you for your help! – DrZ May 14 '12 at 20:16

Your Answer


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.