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.
Thanks
Updated (this is the code I use to write to the eventlog)
try
{
System.Security.Principal.WindowsImpersonationContext wic = System.Security.Principal.WindowsIdentity.Impersonate(IntPtr.Zero);
EventLog.WriteEntry(source, message, type);
wic.Undo();
}
catch (Exception)
{
}