Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Publishing Exception in SPS Web Parts
WhatsApp
Kiran Khambete
18y
14.9k
0
0
100
Article
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.)
.NET
c#
enterprise development
Exception in SPS
Publishing Exception
SPS Web Parts
Web Parts
Up Next
Ebook Download
View all
Getting Started with SharePoint Framework Development using TypeScript, PnP JS, and React JS
Read by 4.9k people
Download Now!
Learn
View all
Membership not found