BSSV Get and Change Current User

alfredorz

alfredorz

Well Known Member
Hi guys,


I have a public bssv, i need get current user logged (I could to call BSFN Get Audit Info, but is there other way to do it? with context or connection ? )


And I need change the user for transactions. I could manually assign the user in transactions or when call bsfn (if there are userId as input, because other bsfn get user internally) but it is very costs if there are a lot of transactions and bsfn. From same batch or application to do it i use a bsfn (BD3NSETU) that internaly copy userid input to SysPref with
jdeStrncpyTerminate(lpBhvrCom->SysPref.szUserName, lpDS->szUserId, DIM(lpBhvrCom->SysPref.szUserName));
It call to start and change the user for all transactions.
But in BSSV doesn't work.


Regards!
 
I know you can use API JDB_InitEnvOvr in C to start up a thread under a new user, but you need their password etc. I'm not quite sure what you mean about the logging a user? Automatically logging all they do? If you launch a UBE using the API you can specify logging Y/N

But you are talking about going this in java right?


This is my example in C from a year or two ago just in case C would work.



/* Spawn new user session using API JDB_InitEnvOvr
JDB_InitEnvOvr() initializes a JDB environment, usually on the servers.
This API passes the environment name, user name, and password for signing on to the environment.
In addition, without an initialized environment, no JDB API will work.
The environment handle initialized here is needed for the call to JDB_InitUser.
*/



if (JDB_InitEnvOvr( &hEnv, lpDS->szEnvironment, lpDS->szScheduledUserID, lpDS->szScheduledPassword) != JDEDB_PASSED)
{
JDB_FreeBhvr(hUser);
return (ER_ERROR);
}

if (JDB_InitUser(hEnv, &hUser2, lpDS->szScheduledUserID, JDEDB_COMMIT_AUTO) != JDEDB_PASSED)
{
JDB_FreeBhvr(hUser);
return (ER_ERROR);
}
jdeCreateBusinessFunctionParms(hUser2, &lpBhvrCom2, &lpVoid2);

Then a few other things to setup the UBe call then this



/* Call Launch UBE API */
idJDBReturn = jdeLaunchUBEEx((HUSER)hUser2,
(PUBEVAR)&dsUbeStructure,
(LPVOID)&dsReportInterconnect,
(LPBHVRCOM) lpBhvrCom);

/* When UBE Managed to Launch and Return, Get Error Code back */
if(idJDBReturn != JDEDB_PASSED)
{
lpDS->cErrorCode = _J('1');
lpDS->cUBEErrorCode = _J('1');
idReturnCode = ER_ERROR;
}
else
{
lpDS->cUBEErrorCode = dsReportInterconnect.cErrorCode;
}

jdeFreeBusinessFunctionParms(lpBhvrCom2, lpVoid2);
JDB_FreeUser(hUser2);
JDB_FreeEnv(hEnv);
jdeFree(pUBEVar);

}
 
Last edited:
Back
Top