我们可以在脚本中添加以下代码,以确保只有拥有管理员角色的用户才能执行脚本:
var currentUserRole = runtime.getCurrentUser().role; if(currentUserRole != "ADMIN") { throw {name: "Insufficient Permissions Error", message: "You do not have sufficient permissions to access this script."}; }