Link to home
Start Free TrialLog in
Avatar of arturosm
arturosm

asked on

Copy of text files to AS/400

Hello Experts.

I'm trying to copy some text files from a Windows Server 2008 to a shared folder that resides in AS/400. This is for a client of mine, I don´t know what they are using to share the folder nor know about their AS/400 release.

I can copy the files using the Windows command prompt (MS-DOS like) and using the File Explorer. I also tested with a .bat file to do the copy and it works well.

However if I try to do the copy from a simple Delphi application the file is not copied, even if I call the .bat file, the file is not copied. If I copy the file to a Windows folder (not AS/400), from the same application, the file is copied correctly in the local server or to a shared network folder.

How this AS/400 folder "knows" that I'm copyng the file from an application or what could be the problem?

Regards.

Avatar of SeanDevoy
SeanDevoy
Flag of United States of America image

This is a bit of a stretch, but if your DELPHI "application" is a WEB application, the copy is being attempted by the WEB app user, not your user and it is a file permissions problem.

Is it a web app?  Does the DELPHI app run AS YOU?
Avatar of arturosm
arturosm

ASKER

Hi SeanDevoy:

The delphi is a win32 application and the Windows server is also 32 bits. I run it as administrator, I don´t know how to link the user connected to the AS/400 shared folder with the user running the windows application.

Regards.
ASKER CERTIFIED SOLUTION
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Gary_The_IT_Pro:

All the tests are done from the windos server machine, I have been told the user of windows has nothing to do with the AS/400 user. The windows user is "Administrator" and the AS/400 is "test400\rtest1".  

The commands that works are (examples):

s:\myfile.pdf  
\\myAs400\myshare\myfile.pdf   (using the IP of the machine not he name)

I have tried both and the call to the bat file but neither works.

For the copy I'm using the API function Windows.CopyFile, the program runs form the server also.

Thank you for your help.



What is the error?

- Gary Patterson
Hi Gary_The_IT_Pro:

No error, the CopyFile function just returns false which means the file was not copied. I send the output of the .bat file and the file shows "0 files copied". But no errors or exceptions. The file to be copied does not exists in the AS400.

Regards.
Ok, I used the GetLastError to obtain the code it is: Access is denied.

Will check with the IT guys to set up the users correctly.


Thanks Gary.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No problem.  "Run As Administrator" is meaningless to the AS/400.  All this does is elevate your Windows session to run using local admin rights when running on a machine using User Access Control.  All the AS/400 cares about is if the NAME and PASSWORD of the Windows profile matches the NAME and PASSWORD of an AS/400 profile.

IF it does, and the AS/400 profile has rights to the AS/400 file and folder, then your copy will succeed.  If not, it won't.

Again, it is possible, but not required for the AS/400 administrator to set up a guest NetServer profile, but if that was the case, you wouldn't be getting errors (unless the guest profile wasn't authorized to this particular folder, of course.)

So, if you'll just make sure your program is running under a Windows profile that can perform the copy manually, the copy should succeed.

- Gary Patterson

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It you are using a shared folder in the IFS, the AS400 user that is configured in the PC with the net use command, must also be configured in WRKDIRE
Thank you Experts.

This was about permisions, once I ran the program as the user logged in to the server, not the administrator, it worked well.