Force Logout Users in all Nodes

D_8
Tera Contributor

I have a business rule that is trying to force Logout users using the below script 

var gr = new GlideRecord('v_user_session');
gr.addEncodedQuery('user=YOURIDHERE');
gr.query();
while(gr.next()){
  gr.locked = true;
}

But the problem is in production we have around 12 nodes, and the above script works logs out users from a specific node that is assigned at the time but all nodes. If my user is in Node A, and when the business rule runs under another user who is in Node B, then the script wont logout the user. Node assignment seems to be random.

Any Idea how to solve this ?

1 ACCEPTED SOLUTION

ARG645
Tera Guru

Dustin,

Try using the below method (this wont work in Scoped apps I believe). Pass the User name as the parameter. 

GlideSessions.lockOutSessionsInAllNodes('user_name');

Thank you,

Aman Gurram

Please mark the answer as correct/helpful if applicable.

View solution in original post

6 REPLIES 6

ARG645
Tera Guru

Dustin,

Try using the below method (this wont work in Scoped apps I believe). Pass the User name as the parameter. 

GlideSessions.lockOutSessionsInAllNodes('user_name');

Thank you,

Aman Gurram

Please mark the answer as correct/helpful if applicable.

D_8
Tera Contributor

aaah I tried this method. I was passing in the sys_id of the user as the parameter. 

I tested it just now by passing in the User ID and it works.

Thank you Gurram

Can we send a message to the user logged out? We want him know the reason.

Thanks.

Yes, you can. Depends on how you want to inform them. You can send them a notification, or display an error message before locking them out.