getting http header information
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 08:02 AM
Is there any way of extracting the http header information in servicenow.
we got an on premise customer wants to establish if the access to the instance is from trusted source, specially if the users have admin roles.
in the installation exits we can determine their IP address using gs.getSession().getClientIP().toString();
But is there any way we can get the http header information like X-Forwarded-For?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 08:08 AM
Hi,
Have you tried request.getHeader(' X-Forwarded-For');
I believe this should work on installation exits. You can check the OOB exit for DigestSingleSignOn, it uses a similar call.
Thanks
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 09:29 AM
I have disabled the login exist and tried gs.log to capture the above header but to no avail.
and yes you are right i can see the DigestSingleSignOn script uses the getHeader property.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 09:24 AM
Try request.getHeader('x-forwarded-for')
or
(below will give you all the headers)
var header = request.headers;
var json = new JSON();
var headerStr = json.encode(header);
gs.log('headers'+headerStr);
Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-08-2017 09:31 AM
hi Deepa, i have disabled the OOTB login script and created by overridden with my own script where gs.log fails to capture the header string as you suggested.
but this works
var IP = gs.getSession().getClientIP().toString();
gs.log('IP Address ' + IP);