Process : who push the button (real user or scheduler) ?

168 views
Skip to first unread message

Nicolas Micoud

unread,
Sep 14, 2016, 8:33:18 AM9/14/16
to iDempiere
Hi,

I have several process which can be executed from the menu (by real users) or by schedulers.
Is there a way to know who executed the process ?

My first idea was to look ad #AD_User_ID or AD_PInstance.CreatedBy.

As I can execute those process in SuperUser, it's not reliable.

Is there a way to identify a real session (opposite of a scheduler session) ?

Thanks,

Nicolas

Carlos Antonio Ruiz Gomez

unread,
Sep 14, 2016, 10:55:52 AM9/14/16
to idem...@googlegroups.com
Maybe the IP address of the session? or the web ID?



El 14/09/16 a las 14:33, Nicolas Micoud escribió:

Nicolas Micoud

unread,
Sep 14, 2016, 11:14:12 AM9/14/16
to iDempiere
There is no session (you mean session in AD_Session ?)
in Scheduler.doWork(), maybe we could add a new kind of session ? AFAIR, there is a context variable which says if we are logged in Swing or WebUI (but i can't find it). That could be extented.
WDYT ?

Carlos Antonio Ruiz Gomez

unread,
Sep 14, 2016, 3:47:33 PM9/14/16
to idem...@googlegroups.com
AD_ChangeLog requires a session to work, so I think there must be a session.


El 14/09/16 a las 17:14, Nicolas Micoud escribió:

norber...@multimageweb.com

unread,
Sep 15, 2016, 2:33:45 AM9/15/16
to iDempiere
hi,

we are using user specific user e.g. @watchdog => special user running all processes, alerts etc.
norbert

Nicolas Micoud

unread,
Sep 15, 2016, 3:25:26 AM9/15/16
to iDempiere
@Carlos : correct me if i'm wrong, but if there is a session, i could find it on AD_Session table ? I can only see "real" sessions there.
In Scheduler.java, i don't see any reference to MSession. Seems everything is put in the context.

@Norbert : yes, that would work, but sounds too easy :D
But we should hardcode all userIDs (I'm in SaaS mode and there could be users in System and in each tenant)

Nicolas

Carlos Antonio Ruiz Gomez

unread,
Sep 15, 2016, 4:36:34 AM9/15/16
to idem...@googlegroups.com
Nicolas, my idea is to check the change log generated by the process (activate it for one table if it's disabled), and there you can find the AD_Session_ID associated to the change log.

Regards,

Carlos Ruiz


El 15/09/16 a las 09:25, Nicolas Micoud escribió:

Nicolas Micoud

unread,
Sep 15, 2016, 11:19:53 AM9/15/16
to iDempiere
I can't find records in AD_ChangeLog.

Moreover, doing a
Env.getContextAsInt(Env.getCtx(), "#AD_Session_ID")
returns nothing

So, I think there is no session in that case or i'm missing something ?

Thanks,

Nicolas

Carlos Antonio Ruiz Gomez

unread,
Sep 15, 2016, 12:24:28 PM9/15/16
to idem...@googlegroups.com
Nicolas, added a breakpoint in PO, line 2911, and effectively the session is null, so I think there is no change log for any record that is created/updated using a scheduled process, which is very bad in my opinion.


El 15/09/16 a las 17:19, Nicolas Micoud escribió:

Nicolas Micoud

unread,
Sep 16, 2016, 2:41:01 AM9/16/16
to iDempiere
So, we should change the way Scheduler connects to iDempiere.
Perhaps it is the time to add a new Reference list on AD_Session to identify the origin (WebUI, Swing, Scheduler, MobileUI, ...) ?

WDYT ?

Carlos Antonio Ruiz Gomez

unread,
Sep 16, 2016, 5:38:05 AM9/16/16
to idem...@googlegroups.com
> So, we should change the way Scheduler connects to iDempiere.

I think so, the lack of change log can be a big audit problem.


> Perhaps it is the time to add a new Reference list on AD_Session to identify the origin (WebUI, Swing, Scheduler, MobileUI, ...) ?

I don't think is necessary, usually you can figure it out with the data on the ad_session table (user, role, IP, description, websession)

We can add the #UIClient context variable to the description if that's helpful.

Regards,

Carlos Ruiz


El 16/09/16 a las 08:41, Nicolas Micoud escribió:

Deepak Pansheriya (Logilite.com)

unread,
Apr 4, 2018, 1:28:50 AM4/4/18
to iDempiere
Created ticket https://idempiere.atlassian.net/browse/IDEMPIERE-3675 and we are fixing to create AD_Session from scheduler
Reply all
Reply to author
Forward
0 new messages