- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2015 06:41 AM
I want to make sure that all the user which are currently logged in should be locked out before starting my maintenance work.
Is it possible by anyway using script or anything ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2015 07:23 AM
Ravish,
It does not kick current users out but prevents them from logging back in. Used in combo with Alex's suggestion that should do what you need.
var gr = new GlideRecord('v_user_session');
gr.addEncodedQuery('user!=YOURIDHERE');
gr.query();
while(gr.next()){
gr.locked = true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2015 07:23 AM
Ravish,
It does not kick current users out but prevents them from logging back in. Used in combo with Alex's suggestion that should do what you need.
var gr = new GlideRecord('v_user_session');
gr.addEncodedQuery('user!=YOURIDHERE');
gr.query();
while(gr.next()){
gr.locked = true;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2018 03:39 PM
Setting gr.locked = true on v_user_session table only locks out users in a specific node (Node in which the script runs).
An Instance may have more than 2 nodes, in that case we are not killing all the sessions for all the users.
To forcefully terminate all the active user session on all nodes for all the user, use the below function in server side scripts by looping with all the user_names who's session needs to be killed.
GlideSessions.lockOutSessionsInAllNodes(<user_name>);
This would kill the sessions and logout users who are currently logged in when they perform their next action.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 12:25 AM
Hi
I have a similar requirement but I need to logout all users.
'v_user_session' table holds user session who are in same node as yours.
Managing User Sessions - ServiceNow Wiki
How do i get list of all logged in users

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2017 12:38 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2018 07:50 PM
Hi Ashik,
We also had a similar requirement to forcefully terminate all the active user session on all nodes for a user
and it was achieved by using the below function in server side scripts.
GlideSessions.lockOutSessionsInAllNodes(<user_name>);