1

I've written an asp.net webapp that writes a file to a location on our iSeries FileShare. The path looks like this: \IBMServerAddress\Filepath

This code executes perfectly on my local machine, but fails when it's deployed to my (windows) WebServer.

I understand that i may need to do some sort of impersonation to authenticate access to the IFS, but i'm unsure of how to proceed.

Here's the code i'm working with:

string filepath = "\\\\IBMServerAddress\\uploads\\";

    public int SaveToDisk(string data, string plant)
    {
       //code for saving to disk
       StreamWriter stream = null;

       stream = File.CreateText(filepath + plant + ".txt"); // creating file
       stream.Write(data + "\r\n"); //Write data to file

       stream.Close();

       return 0;
   }

Again, this code executes perfectly on my local machine but does not work when deployed to my Windows WebServer - access to filepath is denied.

Thanks for your help.

EDIT: I've tried adding a network account with the same credentials as the IFS user, created a UNC path (iseries)on IIS7 to map the network drive (using the same credentials) - but receive this error:

Access to the path 'iseries\' is denied.

1 Answers1

2

My understanding of Windows in general is that normally services don't have access to standard network shares like a program being run by a user does.

So the first thing would be to see if you can successfully write to a windows file share from the web server.

Assuming that works, you'll need one of two things in order to write to the IBM i share..
1) An IBM i user ID and password that matches the user ID and password the process is being run under
2) A "guest account" configured on IBM i Netserver
http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_71/rzahl/rzahlsetnetguestprof.htm

You might have better luck with using Linux/UNIX based Network File System (NFS) which is supported in both Windows and the IBM i.

Charles
  • 21,637
  • 1
  • 20
  • 44
  • Charles, thanks for the response. I can remote into my WebServer and access the iserver file share (used my uid and pw). Unfortunately our company chose Windows and IBM, I will try your suggestions and report back. Thanks again. – Wîlliam Çhristopher Älexander Oct 10 '14 at 14:33
  • That guest account idea is probably the simplest solution. If you're using a specific user id and password, then I suggest running a NET USE command at server startup to map a drive letter. The NET USE command can accept a user id and password. NET USE Y: \\IBMServerAddress\uploads password_goes_here /USER:IBMServerAddres\userid_goes_here. I suggest not using the /PERSISTENT flag because I've seen odd behavior with that flag and Windows-to-AS400 mappings. – Tracy Probst Oct 10 '14 at 14:35
  • Hey Tracy, i was sucessful in mapping via Net Use command on my WebServer, next, i tried running the webapp on server but got this error message instead: Could not find a part of the path 'Y:\' (it exists!) – Wîlliam Çhristopher Älexander Oct 10 '14 at 15:30
  • @WîlliamÇhristopherÄlexander `Unfortunately our company chose Windows and IBM,...` Both Windows and IBM i can support UNIX-style NFS. IBM i supports it as standard. Windows might need the support to be installed. – user2338816 Oct 20 '14 at 19:17
  • Hey @Charles, Thanks for the write-up. I just needed to create a user id that matched my Application Pool which i found using IIS Manager> Application Pool. – Wîlliam Çhristopher Älexander Oct 28 '14 at 18:47