简体   繁体   English

使用Chrome扩展程序调用ServiceNow Rest API

[英]ServiceNow Rest API Call Using Chrome Extension

How is it possible to perform the below query with 'user B' while being logged in as 'user A' and not exiting 'user A' session? 以“用户A”身份登录且不退出“用户A”会话时,如何对“用户B”执行以下查询?

     var settings = {
    "async": true,
    "crossDomain": true,
    "url": "www.url.com",
    "method": "GET",
    "headers": {
    "authorization": "Basic [BASE64]",
    "cache-control": "no-cache",
        }

While being logged with user A, I perform this query and get immediately logged in with user B and my session is overwritten with user B. I'm attempting this while using a Chrome Extension. 使用用户A登录时,我将执行此查询并立即以用户B登录,而我的会话已被用户B覆盖。我正在尝试使用Chrome扩展程序进行此操作。

The 'User B' account is a generic account with permissions to perform API calls which 'User A' does not have. “用户B”帐户是具有执行“用户A”所不具有的API调用权限的通用帐户。

This is only possible if (User A has admin role) or (User A has impersonator role && user B is not an admin) 仅当(用户A具有管理员角色)或(用户A具有模拟者角色&&用户B不是管理员)时才有可能

1) If User A has admin role, then they can directly trigger any REST queries as long the target table is allowed to access. 1)如果用户A具有管理员角色,那么只要允许目标表访问,他们就可以直接触发任何REST查询。

2) If User A has impersonator role, then you can impersonate any users session except the admin users. 2)如果用户A具有模拟角色,那么您可以模拟除admin用户之外的任何用户会话。 The following line of script can be used to impersonate user B within user A's session and then trigger the required API as User B 以下脚本行可用于在用户A的会话中模拟用户B,然后以用户B的身份触发所需的API

 var originalUserID = gs.getUserID(); //Replace SYS_ID_USER_B with the sys_id of user B from the profile gs.getSession().impersonate('SYS_ID_USER_B'); //Trigger REST API as USER B -- START //Trigger REST API as USER B -- END //Impersonate back to the original user gs.getSession().impersonate(originalUserID); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM