Copy user profile in Java - IBM AS400

This is a discussion on Copy user profile in Java - IBM AS400 ; All, I am in the midst of a 'conversion' on our 9406-550, and a new piece of software we are using only allows a user ID to be 8 bytes(sigh). I have 400+ users with 8+ bytes, so I have ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: Copy user profile in Java

  1. Copy user profile in Java

    All,

    I am in the midst of a 'conversion' on our 9406-550, and a new piece
    of software we are using only allows a user ID to be 8 bytes(sigh). I
    have 400+ users with 8+ bytes, so I have devised a naming scheme and
    have the old and new names in a table. My intent was to write a small
    java application to update usernames in a variety of tables, and then
    rename or copy the as/400 user profile and remove the old user
    profile.

    Does anyone know a way to do this via java? I can make a connection to
    my box, and I am familiar with the java cmd.run. What I don't know is
    what command will copy a given user profile into a different user
    profile with a new name.

    Failing that, is there any way to go beyond an as/400 interactive
    command and rename a user profile? I am willing to deal with the
    orphaned objects if that will be a side effect.

    Any ideas? We are running V5R4.

    Thanks,

    Chris

  2. Re: Copy user profile in Java

    Hal wrote:
    >
    > I am in the midst of a 'conversion' on our 9406-550, and a new piece
    > of software we are using only allows a user ID to be 8 bytes(sigh). I
    > have 400+ users with 8+ bytes, so I have devised a naming scheme and
    > have the old and new names in a table. My intent was to write a small
    > java application to update usernames in a variety of tables, and then
    > rename or copy the as/400 user profile and remove the old user
    > profile.
    >
    > Does anyone know a way to do this via java? I can make a connection to
    > my box, and I am familiar with the java cmd.run. What I don't know is
    > what command will copy a given user profile into a different user
    > profile with a new name.
    >
    > Failing that, is there any way to go beyond an as/400 interactive
    > command and rename a user profile? I am willing to deal with the
    > orphaned objects if that will be a side effect.
    >
    > Any ideas? We are running V5R4.


    The command string for a CRTUSRPRF request can be generated from the
    details manifest by the Retrieve User Information QSYRUSRI API
    http://publib.boulder.ibm.com/infoce...s/qsyrusri.htm

    After the new user profile is created, then the following request to
    change the ownership and authorities over to the new name:
    DLTUSRPRF USRPRF(&oldusrname) OWNOBJOPT(*CHGOWN &newusrname)
    PGPOPT( per_the_crt ) EIMASSOC( as_desired )
    http://publib.boulder.ibm.com/infoce.../dltusrprf.htm

    The password can be retrieved and set for the same user name, but I
    pretty sure that it can not be set for another user name as in this
    scenario. The links to the APIs are included anyhow:
    http://publib.boulder.ibm.com/infoce...s/qsyrupwd.htm
    http://publib.boulder.ibm.com/infoce...s/qsysupwd.htm

    I had written [and I believe published on a forum\NG, but I can not
    find it] a CLP which modified the results of a request to CALL QCMDCHK
    with the string ?CHGUSRPRF USRPRF(NAMED) by changing the result of the
    request to a CRTUSRPRF. That method requires running interactively, and
    the unicode default directory is not made available. Somebody responded
    that there was the Retrieve Prompt Override QPTRTVPO API to retrieve the
    results from the prompt override from an API. That can enable the same
    type of command string generation as the ?CHGUSRPRF NAMEDUSER.
    http://archive.midrange.com/midrange.../msg00626.html
    http://publib.boulder.ibm.com/infoce...s/qptrtvpo.htm

    Regards, Chuck

  3. Re: Copy user profile in Java


    > The command string for a CRTUSRPRF request can be generated from the
    > details manifest by the Retrieve User Information QSYRUSRI APIhttp://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/qsyr...
    >
    > After the new user profile is created, then the following request to
    > change the ownership and authorities over to the new name:
    > DLTUSRPRF USRPRF(&oldusrname) OWNOBJOPT(*CHGOWN &newusrname)
    > PGPOPT( per_the_crt ) EIMASSOC( as_desired )http://publib.boulder.ibm.com/infoce...opic/cl/dltusr...
    >


    Chuck/All,

    I had a hunch that the option to "Copy" a profile from the wrkusrprf
    interactive command really was a facade for doing a "dspusrprf" on the
    profile to be copied, grabbing a few pieces of information from that
    action, and then issuing a "crtusrprf" with much of that information
    being put inserted into the prompt string so that one need only type
    the user ID/password and hit enter.

    I read the documents on the link to the API, and forgive me if this is
    a stupid question, but how I use that API in Java? Here's my code
    snippet from similar themed thing I wrote a while back to
    automagically remove users once HR marks an employee as resigned:

    try {
    AS400 myAS = new AS400("DISTRICT", --insert user here--,--insert
    password here--);
    CommandCall cmd = new CommandCall(myAS);
    cmd.run("DLTUSRPRF USRPRF(" + usrid + ") ownobjopt(*DLT)");
    myAS.disconnectService(AS400.COMMAND);

    } catch(IOException e) {System.err.println("Error on exec() method " +
    e);}

    Any help would be appreciated...

    Chris

  4. Re: Copy user profile

    There is a slick way to copy user profiles. IBM has provided an API that
    will allow a user program to invoke
    a command's prompt override program to obtain the string the the command
    prompter uses when to fill in the current
    values when a CHGxxx command is invoked. I have used this facility to
    create a CPYUSRPRF command.

    The API is QPTRTVPO, if you need sample code let me know

    "CRPence" wrote in message
    news:KoC1k.432$vm1.276@newsfe07.lga...
    > Hal wrote:
    >>
    >> I am in the midst of a 'conversion' on our 9406-550, and a new piece
    >> of software we are using only allows a user ID to be 8 bytes(sigh). I
    >> have 400+ users with 8+ bytes, so I have devised a naming scheme and
    >> have the old and new names in a table. My intent was to write a small
    >> java application to update usernames in a variety of tables, and then
    >> rename or copy the as/400 user profile and remove the old user
    >> profile.
    >>
    >> Does anyone know a way to do this via java? I can make a connection
    >> to
    >> my box, and I am familiar with the java cmd.run. What I don't know is
    >> what command will copy a given user profile into a different user
    >> profile with a new name.
    >>
    >> Failing that, is there any way to go beyond an as/400 interactive
    >> command and rename a user profile? I am willing to deal with the
    >> orphaned objects if that will be a side effect.
    >>
    >> Any ideas? We are running V5R4.

    >
    > The command string for a CRTUSRPRF request can be generated from the
    > details manifest by the Retrieve User Information QSYRUSRI API
    > http://publib.boulder.ibm.com/infoce...s/qsyrusri.htm
    >
    > After the new user profile is created, then the following request to
    > change the ownership and authorities over to the new name:
    > DLTUSRPRF USRPRF(&oldusrname) OWNOBJOPT(*CHGOWN &newusrname)
    > PGPOPT( per_the_crt ) EIMASSOC( as_desired )
    > http://publib.boulder.ibm.com/infoce.../dltusrprf.htm
    >
    > The password can be retrieved and set for the same user name, but I
    > pretty sure that it can not be set for another user name as in this
    > scenario. The links to the APIs are included anyhow:
    > http://publib.boulder.ibm.com/infoce...s/qsyrupwd.htm
    > http://publib.boulder.ibm.com/infoce...s/qsysupwd.htm
    >
    > I had written [and I believe published on a forum\NG, but I can not
    > find it] a CLP which modified the results of a request to CALL QCMDCHK
    > with the string ?CHGUSRPRF USRPRF(NAMED) by changing the result of the
    > request to a CRTUSRPRF. That method requires running interactively,
    > and the unicode default directory is not made available. Somebody
    > responded that there was the Retrieve Prompt Override QPTRTVPO API to
    > retrieve the results from the prompt override from an API. That can
    > enable the same type of command string generation as the ?CHGUSRPRF
    > NAMEDUSER.
    > http://archive.midrange.com/midrange.../msg00626.html
    > http://publib.boulder.ibm.com/infoce...s/qptrtvpo.htm
    >
    > Regards, Chuck




  5. Re: Copy user profile in Java

    > I read the documents on the link to the API, and forgive me if this is
    > a stupid question, but how I use that API in Java? Here's my code
    > snippet from similar themed thing I wrote a while back to
    > automagically remove users once HR marks an employee as resigned:
    >


    If you're using Java, why not use the Toolbox functionality to
    retrieve the User details? (I think you will still need to issue the
    DLTUSRPRF as a command.)

  6. Re: Copy user profile in Java

    Why would you want to use Java for this. Write a command and invoke that
    from Java
    "walker.l2" wrote in message
    news:de1588fe-7708-4eda-b907-a7c72573bf4d@x35g2000hsb.googlegroups.com...
    >> I read the documents on the link to the API, and forgive me if this
    >> is
    >> a stupid question, but how I use that API in Java? Here's my code
    >> snippet from similar themed thing I wrote a while back to
    >> automagically remove users once HR marks an employee as resigned:
    >>

    >
    > If you're using Java, why not use the Toolbox functionality to
    > retrieve the User details? (I think you will still need to issue the
    > DLTUSRPRF as a command.)




  7. Re: Copy user profile in Java

    On Jun 5, 3:08 pm, "Tim M" wrote:
    > Why would you want to use Java for this. Write a command and invoke that
    > from Java"walker.l2" wrote in message
    >


    The problem is getting the data back from the iSeries. Cmd.run is a
    fine piece of goods but I haven't mastered two-way communication with
    it yet.

    I did find a complete java implementation that calls the QSYRUSRI API
    and returns a few fields of information to the console. Now that I
    have a working code snippet I can probably get it to work for what I
    need it to do. What came as a shock to me is the fact that there are
    as/400 specific data types and converters to dump said data between
    java data formats and as/400 data formats. The learning curve for
    writing as/400 java code is pretty steep at the beginning because of
    this, at least for me.

    Chris

  8. Re: Copy user profile in Java

    If you're already using the Toolbox (to generate the Java
    CommandCall), why wouldn't you just use the Toolbox User classes to
    retrieve the data? In my view that would be much simpler than trying
    to correctly use an API and dealing with data conversion issues. (The
    API is probably used under the covers by the Java classes)

  9. Re: Copy user profile in Java

    When you want to exchange data with an AS/400, the Toolbox is much
    simpler than dropping down to command level - generally it deals with
    data conversion issues for you, and it insulates you from command
    changes in different OS versions.

  10. Re: Copy user profile

    Hello Chuck,

    I would be very interested in your cpyusrprf command.
    Is there any way you can share it?

    Regards,
    Richard


    There is a slick way to copy user profiles. IBM has provided an API that
    will allow a user program to invoke
    a command's prompt override program to obtain the string the the command
    prompter uses when to fill in the current
    values when a CHGxxx command is invoked. I have used this facility to
    create a CPYUSRPRF command.

    The API is QPTRTVPO, if you need sample code let me know

+ Reply to Thread