Newsletters Subscriptions Forums Media Kit About Us Contact Search Home

mgo
OS/400 Edition
Volume 3, Number 78 -- November 19, 2003

Exchange Data the Easy Way with Windows File Shares


by Michael Sansoterra

There's nothing worse than doing something and later discovering there's a much simpler way. To my amazement and dismay, I recently learned that NetServer provides an elegant way for the iSeries to read and write files on a Windows file share.

If you're like me, you knew NetServer allowed IFS folders to be published as shares for use on a Windows network. But did you know NetServer also works in the opposite fashion, allowing the iSeries to access data on a Windows share from a Windows PC or server?

Users of Integrated xSeries Server will find this tip a yawner, because they already know about this capability. But for those you who don't, here's how it works. Windows share data is made available to iSeries commands and programs via a special file system on the IFS called QNTC. QNTC is located under the IFS root (/). When configured properly, Windows share data is accessed using the following format:

/QNTC/ComputerName/ShareName/Path

ComputerName is the name of a Windows PC or a server hosting a share, ShareName is the name of the share being accessed, and Path is a file or folder name located on the share.

Here are the steps required to configure NetServer for Windows file share access:

  1. On a Windows PC (including your own PC) or on a Windows server, collect your computer name, domain or workgroup, and share name information. If you don't have a file share defined, create one.

  2. Open iSeries Navigator (Client Access for V5R1 or earlier versions).

  3. Expand your iSeries name, expand Network, expand Server, and click TCP/IP.

  4. In the right-hand pane, right-click NetServer and choose Properties.

  5. If the Domain Name box doesn't match your domain or workgroup name, click the Next Start button. Change the domain name to match your workgroup or domain name, and click OK. Click OK to exit the NetServer configuration.

  6. If you had to make a change to the domain name, restart NetServer by right-clicking it in the right-hand pane and choosing Stop. Press F5 to refresh, and verify that it's stopped. Then right-click NetServer and choose Start.

  7. Make sure you have at least one consistent user name and password defined between your iSeries and network (or PC). Sign on to the iSeries with this user name.

  8. At a command line type WRKLNK /QNTC/ComputerName/ShareName/*.

You should see the entries from your share appear on the screen. If you add a file to your share on the PC side, press F5 on the iSeries WRKLNK screen and the new file should appear. The WRKLNK screen should look similar to the following:

                             Work with Object Links

 Directory  . . . . :   /qntc/silver01/manuals

 Type options, press Enter.
  2=Edit  3=Copy  4=Remove  5=Display  7=Rename  8=Display attributes
  11=Change current directory ...

 Opt   Object link            Type     Attribute    Text
       V4R5_SQLRef.pdf        DSTMF
       V4R5_VARPG_Parts_R >   DSTMF
       V4R5_VARPG_Program >   DSTMF
       V4R5_VARPG_Ref.pdf     DSTMF
       V5R1 Tips and Tool >   DSTMF
       V5R1_CLProgramming >   DSTMF
       V5R1_DB2TextExtend >   DSTMF
       V5R1_ILERPG_Ref.pd >   DSTMF
       V5R1_SQLHostLangPr >   DSTMF
                                                           More...
 Parameters or command
 ===>
 F3=Exit  F4=Prompt  F5=Refresh  F9=Retrieve  F12=Cancel  
 F17=Position to  F22=Display entire field  F23=More options

The implications of accessing Windows file share data via the IFS are many: QSHell scripts and redirected output, Java programs and all CODE/400 source, etc., can be stored on a Windows share and simultaneously accessed by the iSeries. Windows shares can be backed up using iSeries hardware. Report processing output can be mapped directly to a user's home drive. An RPG program can directly read a text file on a Windows share using the OPEN and READ APIs.

Here's a command I use to copy a source member directly to a file share on my laptop (computer name is SILVER_01 and share name is source):

CPYTOSTMF FROMMBR('/qsys.lib/mike.lib/qrpglesrc.file/program.mbr')
          TOSTMF('/qntc/silver_01/source/program.rpgle.txt')
          STMFOPT(*REPLACE) 
          STMFCODPAG(437)

Make sure to replace your computer name and share name information. Of course, you'll have to possess write authority to your share in order for this command to create a text file on the share. If you don't have write authority, you'll receive a CPFA09C "not authorized to object" error. Also note, in the above example, that code page 437 (often used by English Windows versions) is specified for the translation from EBCDIC to ASCII (STMFCODPAG parameter). The *PCASCII special value can be used but often does not translate special characters correctly.

The User Log-In Caveat

One drawback to this scenario is that the iSeries user name and password has to match a Windows user name and password. This is a problem for many shops because there is no consistency between iSeries and Windows credentials. Further, adopted authority does not affect data access on the IFS.

Fortunately, Shannon O'Donnell's excellent SWAPUSRPRF program (see "Swapping AS/400 User Profiles") does the trick by temporarily swapping the current user's profile with a different profile: one that's capable of accessing the file shares on the network.

After downloading and compiling this utility, create a common profile/password combination on both the iSeries and your Windows PC or server. This profile should have limited authority on the iSeries and have authority to one or more shares on the Windows network. Next, simply modify the sample CL program Shannon supplied:

PGM  PARM(&USERID &PASSWORD)                                           

             DCL        VAR(&ORGUSER) TYPE(*CHAR) LEN(10)
             DCL        VAR(&USERID) TYPE(*CHAR) LEN(10)
             DCL        VAR(&PASSWORD) TYPE(*CHAR) LEN(10)

/* GET THE CURRENT USER PROFILE */
             RTVJOBA    USER(&ORGUSER)

/* SWAP JOB'S CURRENT USER PROFILE TO SUPPLIED PROFILE */
             CALL  PGM(SWAPUSRPRF) PARM(&USERID &PASSWORD)

/* PERFORM TASK ON PROTECTED QNTC PORTION OF THE IFS */
             WRKLNK '/qntc/silver_01/source/*'

/* SWAP BACK TO THE ORIGINAL USER PROFILE */
             CALL  PGM(SWAPUSRPRF) PARM(&ORGUSER '*NOPWDCHK')
ENDPGM

When you call this CL, pass the name and password of the Windows share profile you created. This will allow the share to be temporarily accessed by the profile. When the program completes, the job continues to run under the original profile, at which time the Windows shares will be unavailable to users who don't have a user name and password that matches their Windows system.

Windows XP Sharing

Also, the NetServer documentation indicates that Windows XP sharing is supported in V5R2. I'm assuming this means that the new Windows XP "simple file sharing" may not be recognized by an older version of NetServer.

Learn to Share

The benefit of using the QNTC file system is that it offers real-time file-sharing capabilities with Windows-based systems. This makes it unnecessary to use file transfer mechanisms like FTP because the file transfer work can be done transparently by NetServer!

For more information on configuring NetServer, go to the iSeries NetServer Web site.


Michael Sansoterra is a programmer/analyst for SilverLake Resources, an IT services firm based in Grand Rapids, Michigan. E-mail: msansoterra@silver-lake.com


Sponsored By
PROFOUND LOGIC SOFTWARE

Have you done the RPG-Alive thing yet?

Thousands of programmers have adopted RPG-Alive, and are now able to read and understand RPG code 2 to 3 times faster.

To try RPG-Alive on your system, visit http://www.RPGAlive.com/now.

"I am very happy with RPG-Alive! It's a terrific productivity booster!" says Brian Johnson of Help/Systems.

See other user testimonials at http://www.rpgalive.com/testimonials.html.



Editors: Howard Arner, Joe Hertvik, Ted Holt, David Morris,
Managing Editor: Shannon Pastore
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
Profound Logic Software


BACK ISSUES

TABLE OF
CONTENTS

Querying the System Catalog Like DSPFD

Exchange Data the Easy Way with Windows File Shares

Reader Feedback and Insights: Don't Do Things On-the-Fly



Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.