× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Scott,

THANKS A LOT.

Added this code to my CLP and it WORKS GREAT!!!

BTW and FYI -
However, I did discover one caveat - that is, that the USER ID being passed - HAS TO BE in all CAPS.
I initially passed it in lower case for the common user id and received message CPF 2204.
So, I decided to use one of my other sign-on id's - and this too failed. So, after some checking of the job log and looking at the value of the passed parm - I decided to try all caps - and, lo and behold it now works.

Again, Thanks a lot for your help,

Charles Pascoe
Programming Supervisor
cpascoe@xxxxxxxxxxxxxxxxx


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: May 30, 2013 11:07 PM
To: Midrange Systems Technical Discussion
Subject: Re: Swapping User Profiles within CLP via RPGLE using CALLP.


Hi Charles,

On 5/29/2013 10:48 PM, Charles Pascoe wrote:

The ultimate goal of this process (for us) is to imbed a call to the
program to swap users to a common user that exists on the Windows Network
and create an .XLS or .XLSX file from a spool file and write it out to a
Network Folder.


I haven't heard any further info from you on what you're trying to do (swap with password, or swap without?)

But here's a very simple example of using these APIs to swap without passwords. This is intended for a situation where the calling user has (at least) *USE authority to the "common" user profile, and so can swap to it without needing a password.

PGM

DCL VAR(&ORIGUSER) TYPE(*CHAR) LEN(12)
DCL VAR(&SFTPUSER) TYPE(*CHAR) LEN(12)

MONMSG (CPF0000 MCH0000) EXEC(GOTO DONE)

CALL PGM(QSYGETPH) PARM(*CURRENT *NOPWD &ORIGUSER)
CALL PGM(QSYGETPH) PARM(the-common-user *NOPWD &SFTPUSER)

CALL PGM(QWTSETP) PARM(&SFTPUSER)


/* ... RUN THE EXCEL STUFF HERE ... */


DONE: CALL PGM(QWTSETP) PARM(&ORIGUSER)

CALL PGM(QSYRLSPH) PARM(&ORIGUSER)
CALL PGM(QSYRLSPH) PARM(&SFTPUSER)

ENDPGM


As you can see... it's pretty simple, I didn't need another special program to implement this, I just called the APIs directly from the CL.

I start by calling QSYGETPH with *CURRENT to get a handle for the current userid -- that way, I don't have to worry about whether the common user has authority, because I have the handle before I swap. The current user always has authority to his own user profile :-)

Then, I get the profile handle for the common user with QSYGETPH.
(You'll need to replace 'the-common-user' with the proper user profile
name.) Assuming that you have at least *USE authority to that profile, you should be able to get the profile handle without needing a password.

Then, it calls QWTSETP to do the actual swap -- and we're set, we can do the special stuff that requires the common user profile.

After doing that, it calls QWTSETP to switch back to the original user profile, and releases both profile handles with QSYRLSPH, to prevent the possible memory leak.

It's important to note that there's a global MONMSG here so that if something should go wrong, it'll still swap back to the original profile
and release the profile handles. But, the error message will be sent
to the job log, too, so you'll be able to view the job log to see what went wrong.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.