• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Retrieve the User ID at Run Time In a .NET Environment

    November 12, 2008 Hey Mike

    I am coding a .NET reporting application. The new .NET reports need to look like the old iSeries reports with the user name at the top. I am using the DB2 managed provider to connect to the data files.

    My code for connecting is:

    Public cni5 As iDB2Connection
    cni5 = New iDB2Connection("DataSource=" + My.Settings.PTCValue)
    cni5.Open()
    

    When connecting, the .NET Windows application displays the Client Access sign-on screen just like the iSeries Access for Windows program does. I can see the connection on the iSeries side under the QUSRWRK Subsystem. It is called QZDASOINIT, user is QUSER, type is PJ (prestart job).

    I have two questions:

    1. How can I get the Work with Active Jobs screen to show the real user that signed on like I normally see when we use iSeries Access for Windows?

    2. How can I get the user ID to use in my .NET application?

    –Duane

    Duane,

    Are you on V5R4 yet? As of V5R4 the WRKACTJOB command shows the current user (i.e., the logged in user) instead of the job user as the default. Also, when QZDASOINIT jobs show QUSER as the current user it means they are not currently servicing any requests from a client (i.e., they’re asleep waiting for a request.) If your iSeries connection is only open for a short time, it may be difficult to see the signed-on user on this screen.

    If you’re not on V5R4 yet, you can look for the QZDASOINIT jobs by user profile by issuing a WRKOBJLCK userid *USRPRF command. The only drawback is that you need to know the user name you’re looking for and the user must have an open connection in order for a QZDASOINIT job to show in the list of jobs. Other than this, your remaining options are to find a utility that lists active jobs with current user or write a program that uses the QUSRJOBI API to retrieve the list of jobs along with each job’s current user.

    Now on to your second question. As for retrieving the user name in a client/server application, generically speaking, you can always retrieve the value of the CURRENT_USER register using SQL:

    SELECT CURRENT_USER FROM SYSIBM/SYSDUMMY1
    

    Specifically from a .NET application using the IBM managed provider, once the user has signed in and the connection has been opened, you can read the UserID property at run time from your iDB2Connection object as shown here:

    cni5.Open()
    MessageBox.Show(cni5.UserID)
    

    –Mike

    Michael Sansoterra is a programmer/analyst for i3 Business Solutions, an IT services firm based in Grand Rapids, Michigan. Send your questions or comments for Michael to Ted Holt via the IT Jungle Contact page.



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    DRV Tech

    Get More Out of Your IBM i

    With soaring costs, operational data is more critical than ever. IBM shops need faster, easier ways to distribute IBM applications-based data to users more efficiently, no matter where they are.

    The Problem:

    For Users, IBM Data Can Be Difficult to Get To

    IBM Applications generate reports as spooled files, originally designed to be printed. Often those reports are packed together with so much data it makes them difficult to read. Add to that hardcopy is a pain to distribute. User-friendly formats like Excel and PDF are better, offering sorting, searching, and easy portability but getting IBM reports into these formats can be tricky without the right tools.

    The Solution:

    IBM i Reports can easily be converted to easy to read and share formats like Excel and PDF and Delivered by Email

    Converting IBM i, iSeries, and AS400 reports into Excel and PDF is now a lot easier with SpoolFlex software by DRV Tech.  If you or your users are still doing this manually, think how much time is wasted dragging and reformatting to make a report readable. How much time would be saved if they were automatically formatted correctly and delivered to one or multiple recipients.

    SpoolFlex converts spooled files to Excel and PDF, automatically emailing them, and saving copies to network shared folders. SpoolFlex converts complex reports to Excel, removing unwanted headers, splitting large reports out for individual recipients, and delivering to users whether they are at the office or working from home.

    Watch our 2-minute video and see DRV’s powerful SpoolFlex software can solve your file conversion challenges.

    Watch Video

    DRV Tech

    www.drvtech.com

    866.378.3366

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    BCD:  Attend a Presto How To technical webinar, November 19
    COMMON:  Join us at the 2009 annual meeting and expo, April 26-30, Reno, Nevada
    Vision Solutions:  A $20 gas card for completing a short i5/OS DR survey

    IT Jungle Store Top Book Picks

    Easy Steps to Internet Programming for AS/400, iSeries, and System i: List Price, $49.95
    Getting Started with PHP for i5/OS: List Price, $59.95
    The System i RPG & RPG IV Tutorial and Lab Exercises: List Price, $59.95
    The System i Pocket RPG & RPG IV Guide: List Price, $69.95
    The iSeries Pocket Database Guide: List Price, $59.00
    The iSeries Pocket Developers' Guide: List Price, $59.00
    The iSeries Pocket SQL Guide: List Price, $59.00
    The iSeries Pocket Query Guide: List Price, $49.00
    The iSeries Pocket WebFacing Primer: List Price, $39.00
    Migrating to WebSphere Express for iSeries: List Price, $49.00
    iSeries Express Web Implementer's Guide: List Price, $59.00
    Getting Started with WebSphere Development Studio for iSeries: List Price, $79.95
    Getting Started With WebSphere Development Studio Client for iSeries: List Price, $89.00
    Getting Started with WebSphere Express for iSeries: List Price, $49.00
    WebFacing Application Design and Development Guide: List Price, $55.00
    Can the AS/400 Survive IBM?: List Price, $49.00
    The All-Everything Machine: List Price, $29.95
    Chip Wars: List Price, $29.95

    RFID Spending to Grow 15 Percent Per Year, ABI Research Says Jinfonet Boosts Performance of Reporting Tool

    Leave a Reply Cancel reply

Volume 8, Number 39 -- November 12, 2008
THIS ISSUE SPONSORED BY:

LANSA
ProData Computer Services
Vision Solutions

Table of Contents

  • What Is AJAX?
  • Retrieve the User ID at Run Time In a .NET Environment
  • Admin Alert: Readers Pimp Joe’s Font, Win No-Prize

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • The Power11 Transistor Count Discrepancies Explained – Sort Of
  • Is Your IBM i HA/DR Actually Tested – Or Just Installed?
  • Big Blue Delivers IBM i Customer Requests In ACS Update
  • New DbToo SDK Hooks RPG And Db2 For i To External Services
  • IBM i PTF Guide, Volume 27, Number 33
  • Tool Aims To Streamline Git Integration For Old School IBM i Devs
  • IBM To Add Full System Replication And FlashCopy To PowerHA
  • Guru: Decoding Base64 ASCII
  • The Price Tweaking Continues For Power Systems
  • IBM i PTF Guide, Volume 27, Numbers 31 And 32

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle