Blocking access for custom created portal except mentioned IP Address.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hey folks,
I had created one custom Service Portal in my PDI. Now I want that Service Portal to be accessed only with the mentioned IP Range, let's say only for my office Wi-fi.
I followed the exact same procedure as mentioned in the official ServiceNow knowledge article mentioned here: - How to restrict access some Service Portal Pages/Widgets based on IP address range - Support and Tro....
The script I used below: -
function() {
var clientIP = gs.getSession().getClientIP().toString();
gs.info("User Criteria Check - Client IP: " + clientIP);
var ipFound = false;
var ipGR = new GlideRecord('u_ip_range');
ipGR.query();
while (ipGR.next()) {
var startIP = ipGR.u_start_ip.toString();
var endIP = ipGR.u_end_ip.toString() || startIP; // if end not provided, use start
// Simple equality check for now (can expand to ranges later)
if (clientIP == startIP || clientIP == endIP) {
ipFound = true;
break;
}
}
// If IP found in blocked list, return true (cannot view)
return ipFound;
})();
Please help me to fix this issue as soon as possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @SujanD345956992,
what have been logged in the gs.info?
Let me help to understand the issue in more details
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */