{
windowsimpersonationcontext context = null;
context = currentidentity.impersonate();
context.undo();
}
catch (exception ex)
{
// display diagnostic error information if exception occurs
writer.write("<div>");
writer.write("<b>exception type</b>: " + ex.gettype().tostring() +
"<br>");
writer.write("<b>exception message</b>: " + ex.message + "<br>");
writer.write("<b>stack trace</b>:<br>" + ex.stacktrace.replace("\n",
"<br>"));
writer.write("</div>");
}