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.

IBM System iProgrammingDelphi

Avatar of undefined
Last Comment
arturosm

8/22/2022 - Mon
SeanDevoy

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?
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
Gary Patterson, CISSP

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
arturosm

ASKER
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.



Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Gary Patterson, CISSP

What is the error?

- Gary Patterson
arturosm

ASKER
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.
arturosm

ASKER
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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Gary Patterson, CISSP

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
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
KarenLe

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
arturosm

ASKER
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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23