- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2014 09:19 AM
I'm looking for a way to invalidate a user session on our ServiceNow instance to force them to relogin without locking their account.
I have not been able to determine a way to do this either in script or via the user or logged in users form.
Does anyone know if this is possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2014 05:27 PM
When you lock out a user, it triggers a business rule called "Lock Out User" that terminates the user's session. You can use the script from that business rule to do the same without locking out the user's account.
// Get all sessions
var sessions = GlideSessions.get().getLoggedInSessionList();
var it = sessions.iterator();
while(it.hasNext()) {
var session = it.next();
// If session is current users session, invalidate the session
if (session.getUser() == current.user_name) {
var httpSession = session.getHS();
httpSession.setAttribute("locked_out", "true");
}
}
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2014 05:27 PM
When you lock out a user, it triggers a business rule called "Lock Out User" that terminates the user's session. You can use the script from that business rule to do the same without locking out the user's account.
// Get all sessions
var sessions = GlideSessions.get().getLoggedInSessionList();
var it = sessions.iterator();
while(it.hasNext()) {
var session = it.next();
// If session is current users session, invalidate the session
if (session.getUser() == current.user_name) {
var httpSession = session.getHS();
httpSession.setAttribute("locked_out", "true");
}
}
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2014 06:55 AM
Thanks Slava,
I'll give that a try.
Bryan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2017 11:32 PM
Hey Bryan,
Were you able to achieve this ??
I have a similar requirement and i dont see a possibility of getting all the sessions of all the nodes.
Thanks,
Sanjay

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2014 08:57 AM
I would check out this Wiki page.
Modifying Session Timeout - ServiceNow Wiki
You didn't state when you wanted to trigger this action, which happens by default after 30 minutes. If you want to simply adjust the timing of this you can set the system property described in this article, but this is not an on demand solution.
Thanks,
-Robert