import * as permission from 'permission';
let mng = permission.newProfileManager();
let profiles = mng.getList();
console.log(profiles);
for (let p of profiles) {
console.log(p.name);
}
try {
let id = mng.create("create_by_script_1", "由脚本创建");
let p = mng.getById(id);
console.log(p);
console.log(p.id);
console.log(p.name);
let pas = mng.getPermissionsById(id);
// console.log(pas);
for (let pa of pas) {
console.log(pa.servicePermission, pa.accessible);
if (!pa.accessible) {
mng.setPermission(id, pa.servicePermission, !pa.accessible);
}
}
pas.filter((v, i) => i % 2 == 0).forEach((v) => mng.setPermission(id, v.servicePermission, false))
pas = mng.getPermissionsById(id);
console.log(pas);
mng.deleteById(id);
} catch (e) {
console.log(e.message);
}
import * as permission from 'permission';
let mng = permission.newProfileManager();
let newName = "SOMNAME";
try {
mng.deleteByName(newName);
}catch (e) {
console.log(e);
}
let anonymous = "Anonymous User Profile";
let ap = mng.getByName(anonymous);
let newId = mng.clone(ap.id, newName);
let aps = mng.getPermissionsById(ap.id);
let bps = mng.getPermissionsById(newId);
for (let i = 0; i < aps.length; i++) {
if (aps[i].accessible != bps[i].accessible || aps[i].servicePermission != bps[i].servicePermission) {
console.log("oops~")
}
}
bps.forEach(v => {
v.accessible = !v.accessible
})
mng.setPermissions(newId, bps)
权限管理
在启用租户级别安全模式下, 需要有 System Admin Profile 权限才能操作