SIGN UP MEMBER LOGIN:    
ARTICLE

Publishing Exception in SPS Web Parts

Posted by Kiran Khambete Articles | SharePoint April 11, 2005
This article tells the safe way of publishing exceptions using Microsoft Exception Management Application Blocks from WebPart.
Reader Level:

Assume that you have configured the SPS Site to be working under following conditions.

  • "NT AUTHORITY\Authenticated Users" users as Reader on the portal, 

  • Web.Config for the particular Portal is marked as <identity impersonate="true" />

And now a user who is part of the Network where the SPS Web is running logs in to the portal, and now this user is not part of the users from the machine where SPS Web Site is running, and an exception is generated in any of the WebParts, and you are using Microsoft's Exception Management Application Block to publish the Exception in the Event Viewer - then the exceptions which would be generated for this particular user can not be logged in to Event Viewer, basically the Exception block throws an Exception. The reason behind this scenario is that since we are doing impersonation with the current user, and to write in to Event Log the user should be having "Admin Access" on the machine. To avoid this issue following lines of code should be added in the Catch block.

try
{
}
catch(Exception e)
{
System.Security.Principal.WindowsImpersonationContext wic =
// make impersonation = false in the code.
System.Security.Principal.WindowsIdentity.Impersonate
(IntPtr.Zero);
// again roll back the Impersonation = true
ExceptionManager.Publish(e);
wic.Undo();
}

Basically what you are doing is doing is <identity impersonate="false"/> in the code for publishing exception, so the exception is published by the Exception Manager with the user under which the AppPool of the SPS WebSite is running. (Provided that the AppPool Identity is having "Admin Access" on the machine to Publish Exception in Event Viewer.)

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Become a Sponsor