,
Share with your friends 

Accessing Filesystem via Asp.net application through Impersonation

0 ratings Views 217 
Author: abhijit_9989f6cc (abhijit pande)  View Profile |  View other solutions by this author

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

Login to rank it

Report


Advertisement