1

I have a MVC application where I need to wrote to a folder location with shared writes to a specific user, ho can I authenticate this so that the specific user has access to that folder. Please see my code below:

public ActionResult Upload(HttpPostedFileBase file, int? ciscoIdentifier)
    {
        foreach (string upload in Request.Files)
        {
            //if (!Request.Files[upload].HasFile()) continue;


            string mimeType = Request.Files[upload].ContentType;
            Stream fileStream = Request.Files[upload].InputStream;
            string fileName = Path.GetFileName(Request.Files[upload].FileName);
            int fileLength = Request.Files[upload].ContentLength;
            byte[] fileData = new byte[fileLength];
            fileStream.Read(fileData, 0, fileLength);

            string path = @"\\servername\foldername";
            //AppDomain.CurrentDomain.BaseDirectory + "uploads/";
            string filename = Path.GetFileName(Request.Files[upload].FileName);
            Request.Files[upload].SaveAs(Path.Combine(path, filename));

I am trying to pass a username and a password for the above specified folder. I need this so I can deploy this to IIS. I want to remain using the Application Pool Identity in IIS and pass username and password to save to file in the application itself. Your help will be appreciated.

Pikoh
  • 7,582
  • 28
  • 53
Papi
  • 555
  • 13
  • 40

0 Answers0