Accessing Filesystem via Asp.net application through Impersonation
|
|
|
Question / Problem
|
How do we get an ASP.net application to write to the server's file system?
|
Solution
|
|
When we create an asp.net application it manages to write to the filesystem if its on a development server. How ever after hosting on the IIS it might cause problems For this we use windows impersonation try {
WindowsImpersonationContext wic = null;//initialize IPrincipal p = this.User;//principal for the authentication WindowsIdentity wi = (WindowsIdentity)p.Identity;//casting is neccesary wic = wi.Impersonate(); } catch(Exception ie) { Response.Write("Can Not Impersonate : "+ie.Message); }
|
Applies to |
|
Asp.Net 2.0
|
Rank It |
|