
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2017 10:42 PM
Hi,
I have a service catalog user which a user who doesn't have admin role can raise a request and once request is raised user will be provided with admin role automatically for certain duration. moreover once the duration expires then admin role will be automatically revoked but i want to end the session for the logged in user once the duration expires. can anyone provide me the sample code so that i can it in my workflow which will help me to revoke admin access as well to end user session.?
Thanks
Regards,
Musab
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2017 04:53 AM
Here is working code.
var sessions = GlideSessions.get().getLoggedInSessionList();
var it = sessions.iterator();
while(it.hasNext()) {
var session = it.next();
gs.log('musab1');
// If session is current users session, invalidate the session
if (session.getUser() == current.opened_by.user_name) {
gs.log('musab2');
var httpSession = session.getHS();
httpSession.setAttribute("locked_out", "true");
}
}
Regards,
Musab

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2017 04:53 AM
Here is working code.
var sessions = GlideSessions.get().getLoggedInSessionList();
var it = sessions.iterator();
while(it.hasNext()) {
var session = it.next();
gs.log('musab1');
// If session is current users session, invalidate the session
if (session.getUser() == current.opened_by.user_name) {
gs.log('musab2');
var httpSession = session.getHS();
httpSession.setAttribute("locked_out", "true");
}
}
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2017 07:56 PM
Thanks. That got me thinking in the right direction for a local logout page that didn't use logout.do.
<g:evaluate var="jvar_status">
var id = gs.getSessionID();
var gr = new GlideRecord('v_user_session');
if (gr.get('session_id',id)) {
gr.locked = true;
gr.update();
}
</g:evaluate>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2019 12:44 PM
This doesn't work across nodes.