Microapps

配置用户提供者

配置用户提供程序无需复制和同步在记录系统(SoR)标识提供程序配置设置中创建和维护的用户组,从而提高管理效率。

Microapps管理员可以配置用户提供者来从您的SoR收集用户和用户组数据,并使用这些数据来管理所有集成中的microapp订阅。要配置用户提供程序,应用程序SoR必须提供公开用户/用户组的api,例如ServiceNow、Salesforce、Jira等。

创建用户提供者

您可以手动创建新的用户提供程序,也可以导入已配置的用户提供程序。

遵循以下步骤:

  1. Microapp集成页面,选择用户服务提供商选项卡在顶部栏中。

    用户提供选项卡

  2. 选择用户提供程序类型。选择从HTTP Web服务创建新的用户提供程序手动配置此用户提供程序。你也可以导入以前配置的用户提供程序.有关导入的更多信息,请参见进口
  3. 输入一个用户提供程序名称的连接。
  4. 输入用户提供者基URL
  5. 选择一个图标为图标库中的用户提供程序设置,或将其保留为默认图标。
  6. 选择服务认证方法,并根据使用的身份验证方法完成所有必需的详细信息。有关身份验证方法的更多信息,请参见设置服务认证
  7. (可选)启用启用请求速率限制如果需要,切换并输入的请求数量和一个时间间隔
  8. (可选)输入请求超时如果需要的话。
  9. 选择添加以完成用户提供程序的创建。

    用户提供程序配置屏幕

    现在您需要导入一个脚本来完成。

导入脚本

使用用户提供脚本功能,你需要上传一个脚本来完成用户提供商的设置。下面我们提供了脚本需求和JavaScript模型。看到准备你的脚本.有关脚本的一般信息,请参见HTTP集成脚本

在添加用户提供程序(在前面的过程中)之后,页面将打开,其中显示用户提供程序的视图。按照以下步骤添加脚本。

  1. 选择添加脚本状态
  2. 选择导入脚本
  3. 将脚本拖到导入弹出框中,或浏览该文件。该脚本必须是一个不大于1mb的.js文件。

    解析并验证脚本。

  4. 选择进口完成。

    您可以在下面查看脚本的详细信息脚本处理程序用户提供脚本用户提供者视图。要查看脚本发出的请求,请选择用户提供程序条目旁边的菜单并选择同步日志

在分配订阅者时,您的新用户提供程序现在可用。有关更多信息,请参见管理用户

订阅中的用户提供者

准备你的脚本

在准备你的脚本时,考虑以下要求:

  • 导入脚本必须从加载内置库微应用程序-用户组开始。这个库定义了必须存储在数据库中的对象:const {User, Group, UserGroupMapping} = library.load("microapp-user-groups");
  • 对象具有以下结构/属性:

    • 用户(accountName, displayName, email, domain, userPrincipalName, userId)电子邮件地址必须在用户提供商内是唯一的
    • 组(accountName, displayName, domain, userPrincipalName, groupId, parentGroupId)组层次结构也是使用parentGroupId定义的
    • usergroupmapping(UserID,GroupID)将用户映射到组
  • 所有属性都是数据类型字符串
  • 用户。email必须与登录到Citrix Workspace的用户的email相匹配。

模型脚本

使用下面的JavaScript代码作为模型。

请注意

以下模型是专门为ServiceNow SoR编写的。此脚本与其他服务不兼容。

const {User, Group, UserGroupMapping} = library.load("microapp-user-groups");function fullsync(params){fullsyncusers(params);fullsyncgroups(params);fullsyncusergroupmapping(params);}函数全同步仪({client,datastore}){let offset = 0;do {const response = client.fetchsync(`/ api / now / table / sys_user?sysparm_fields = sys_domain_path%2cname%2c%20sys_id%2cuser_name%2cemail&sysparm_query = emailisnotempty ^ Active%3Dtrue&sysparm_limit = 100&sysparm_offset = $ {offset}`);if(!responsok.ok){console.log(“错误状态:”,response.status,response.statustext);console.log(“错误正文:”,response.textsync());抛出新的错误(“网络响应不正常”);console.log(“完成”); const users = response.jsonSync().result; console.log("users"); users.map((user) => console.log( user.user_name, user.name, user.email, user.sys_domain_path, user.name, user.sys_id ) ); dataStore.save( User.tableModel, users.map( (user) => new User( user.user_name, user.name, user.email, user.sys_domain_path, user.user_name, user.sys_id ) ) ); offset = offset + 100; console.log(`offset: ${offset}`); } while (offset < 300); } function fullSyncGroups({ client, dataStore }) { let offset = 0; do { const response = client.fetchSync( `/api/now/table/sys_user_group?sysparm_query=active%3Dtrue&sysparm_limit=100&sysparm_offset=${offset}` ); if (!response.ok) { console.log("Error status:", response.status, response.statusText); console.log("Error body:", response.textSync()); throw new Error("Network response was not ok"); } const groups = response.jsonSync().result; groups.map((group) => console.log( group.name, group.name, "/", group.name, group.sys_id, group.parent.value ) ); dataStore.save( Group.tableModel, groups.map( (group) => new Group( group.name, group.name, "/", group.name, group.sys_id, group.parent.value ) ) ); offset = offset + 100; console.log(`offset: ${offset}`); } while (offset < 400); } function fullSyncUserGroupMapping({ client, dataStore }) { let offset = 0; do { const response = client.fetchSync( `/api/now/table/sys_user_grmember?&sysparm_limit=100&sysparm_offset=${offset}` ); if (!response.ok) { console.log("Error status:", response.status, response.statusText); console.log("Error body:", response.textSync()); throw new Error("Network response was not ok"); } const mappings = response.jsonSync().result; mappings.map((mapping) => console.log(mapping.user.value, mapping.group.value) ); dataStore.save( UserGroupMapping.tableModel, mappings.map( (mapping) => new UserGroupMapping(mapping.user.value, mapping.group.value) ) ); offset = offset + 100; console.log(`offset: ${offset}`); } while (offset < 400); } integration.define({ synchronizations: [ { name: "snowUserGroups", // Logical name fullSyncFunction: fullSync, }, ], model: { tables: [User.tableModel, Group.tableModel, UserGroupMapping.tableModel], }, }); 
配置用户提供者