Add the following code in you code behind file where you need this.
WindowsIdentity currentUserIdentity = (WindowsIdentity)User.Identity;
WindowsImpersonationContext impersonationContext = currentUserIdentity.Impersonate();
try{
// do Something that requires saving, creating, or deleting files in the server.
}
catch(Exception ex){
if (impersonationContext != null)
{
impersonationContext.Undo();
}
}
No comments:
Post a Comment