How can I read files on an iSeries IFS from Visual Basic .NET 2010?

Posted on 2011-10-26
Last Modified: 2012-05-12
I have a folder in the IFS on an iSeries that contains files I want to process from within a Windows Service. The service has the LocalSystem authority (for now) to work with network resources, but when working with iSeries network resources (via a UNC) it needs to authenticate with an iSeries user profile/password pair.

I am using the Directory.GetFiles(...) method to work through all the files in the IFS folder, so how do I authenticate as the iSeries user from within Visual Basic .NET 2010?

I have tried the LogonUser/Impersonate route that you can find all over the internet, but it appears that it only works if the credentials you give the LogonUser are a valid login for the local PC, which the iSeries credentials will not be. I have also tried to use System.Diagnostics.Process.Start(processInfo) to run a NET USE command (which works well on the command line) but I get "Access to the path '\\bhsfiseries\letters\tstextrs\' is denied. (Err# 5)" when the service is trying to view the files.
Question by:Paul-Bailey
    LVL 83

    Expert Comment


    Author Comment

    Both of those examples are not applicable. The first is never resolved, where one guy says over and over to use the GetFiles() method, but never discusses how, or (I suspect) has ever tried it himself. It will not work as the cwbx.dll library is for connecting to the iSeries, not for reading the IFS.

    The second also uses cwbx.dll, but it uses it to call programs written and running on the iSeries.

    I just need a way of passing iSeries credentials to the Directory.GetFiles() method so that I can list/work with the files. I just can't understand why it isn't working... it should be really easy.
    LVL 83

    Expert Comment

    As you have discovered that getfiles does not take credentials and impersonation wont work in this scenario, you have to look at alternatives. The first link shows an example of using credentials to download a file from iSeries.

    Accepted Solution

    The first example allows downloading from the IFS. That is clear and works. However, I can not find out what files exist in that location to download. (If I don't know the filename, how can I download it?)

    I should have mentioned this in the OP: Using mapped drives (or Process.Start with the "net use" command) I can use the GetFiles() method with no problems when running as a normal VB program, but if I convert that program to a "LocalSystem" windows service (start a timer in OnStart(...) that calls the rest of the program) or a scheduled job I get the error I mention in the OP.

    The program is running as a scheduled job under windows 2000 with no problems. The same program will not run under Windows 2008 as a scheduled job because of the error in the OP.

    Can anyone help?

    Author Closing Comment

    After a brief response the question was not followed through. Very disappointing. Closing now due to warnings from EE automails.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now