How to end the user session

Rahul Singh7
Tera Guru

There are two instances A and B. When a user submits the request in instance A, they get admin access in instance B(through REST webservice). Admin access is auto revoked(through REST webservice) after 2 hours. However admin access still remains since the user session is active in instance B.

Is there any way to kill the user session ?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you want to kill user instance in instance B via some API call?

you can create scripted rest api in instance B of type POST and invoke it from instance A and send the user name via API in JSON request body

in scripted rest api you can use this script to kill user session

GlideSessions.lockOutSessionsInAllNodes('userName');

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you want to kill user instance in instance B via some API call?

you can create scripted rest api in instance B of type POST and invoke it from instance A and send the user name via API in JSON request body

in scripted rest api you can use this script to kill user session

GlideSessions.lockOutSessionsInAllNodes('userName');

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader