add base group Staff
This commit is contained in:
parent
e803135b45
commit
4a7c5dafec
|
@ -94,7 +94,13 @@ async function fetchAllDepartments() {
|
||||||
}
|
}
|
||||||
log.info('Got', deps.department.length, 'departments');
|
log.info('Got', deps.department.length, 'departments');
|
||||||
|
|
||||||
const depsMap = {};
|
const depsMap = {
|
||||||
|
'1': {
|
||||||
|
name: 'Staff',
|
||||||
|
id: 1,
|
||||||
|
parentid: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
deps.department.forEach(d => {
|
deps.department.forEach(d => {
|
||||||
d.name = d.name.replace(/ \/ /g, ' - ').replace(/\//g, '&').trim();
|
d.name = d.name.replace(/ \/ /g, ' - ').replace(/\//g, '&').trim();
|
||||||
depsMap[d.id] = d;
|
depsMap[d.id] = d;
|
||||||
|
@ -110,7 +116,7 @@ async function fetchAllDepartments() {
|
||||||
allDeps.forEach(d => {
|
allDeps.forEach(d => {
|
||||||
let obj = d;
|
let obj = d;
|
||||||
let dn = [ `ou=${obj.name}` ];
|
let dn = [ `ou=${obj.name}` ];
|
||||||
while (obj.parentid !== 1) {
|
while (obj.parentid) {
|
||||||
obj = depsMap[obj.parentid];
|
obj = depsMap[obj.parentid];
|
||||||
dn.push(`ou=${obj.name}`);
|
dn.push(`ou=${obj.name}`);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +222,7 @@ async function reloadFromDingtalkServer() {
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.values(allDepartmentsMap).forEach(dep => {
|
Object.values(allDepartmentsMap).forEach(dep => {
|
||||||
if (dep.parentid != 1) {
|
if (dep.parentid) {
|
||||||
const parentDep = allDepartmentsMap[dep.parentid];
|
const parentDep = allDepartmentsMap[dep.parentid];
|
||||||
addMemberToGroup(allLDAPGroupsMap[dep.id], allLDAPGroupsMap[parentDep.id]);
|
addMemberToGroup(allLDAPGroupsMap[dep.id], allLDAPGroupsMap[parentDep.id]);
|
||||||
}
|
}
|
||||||
|
@ -260,7 +266,7 @@ async function reloadFromDingtalkServer() {
|
||||||
u.department.forEach(depId => {
|
u.department.forEach(depId => {
|
||||||
let parentDep = allDepartmentsMap[depId];
|
let parentDep = allDepartmentsMap[depId];
|
||||||
// allLDAPGroupsMap[parentDep.id].attributes.member.push(personEntry.dn);
|
// allLDAPGroupsMap[parentDep.id].attributes.member.push(personEntry.dn);
|
||||||
while (parentDep && parentDep.id !== 1) {
|
while (parentDep && parentDep.id) {
|
||||||
addMemberToGroup(personEntry, allLDAPGroupsMap[parentDep.id]);
|
addMemberToGroup(personEntry, allLDAPGroupsMap[parentDep.id]);
|
||||||
// console.log('add member', personEntry.attributes.cn, 'to', allLDAPGroupsMap[parentDep.id].attributes.cn);
|
// console.log('add member', personEntry.attributes.cn, 'to', allLDAPGroupsMap[parentDep.id].attributes.cn);
|
||||||
parentDep = allDepartmentsMap[parentDep.parentid];
|
parentDep = allDepartmentsMap[parentDep.parentid];
|
||||||
|
|
Loading…
Reference in New Issue