How can I temporarily impersonate a user to open a file?
问题 I would like to temporarily impersonate a domain user account to read in a file on a network drive from an ASP.NET site. I would rather not set up impersonation for the entire site or set up a mapped drive on the server. 回答1: I ended up using code from Michiel van Otegem: WindowsImpersonationContext made easy and added an implementation of IDisposable. I found this in another question about impersonation in ASP.NET. Usage: using (WindowsImpersonationContextFacade impersonationContext = new