Monday, February 4, 2008

Message: Cannot open log for source 'ExceptionManagerInternalException'. You may not have write access.

Message: Cannot open log for source 'ExceptionManagerInternalException'. You may not have write access.

Came across this message when trying to write to the event log using Microsoft.ApplicationBlocks.ExceptionManagement.dll in the Infopath (IFS) form codebehind. However, if you are an administrator of the box (web server where this is running on), you won't have a problem writing to the event log. Since we cannot grant all users administrator rights, that option is out.

Solution: by default, a sharepoint site uses impersonation. Use the SPSecurity class:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
ExceptionManager.Publish(ex);

});

As a side note, do not mess with the existing settings in web.config of the sharepoint site. Taking out impersonate="true" messed up our BDC and other things....

1 comment:

Ben Ross said...

Yanling,

I would like to speak with you about a Sr Sharepoint Developer role. Please call me at my direct dial 212-204-1025.

Cheers,

Ben