LDAP sync hotfix
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2020-11-30 18:45:50 +01:00
parent 2a2104936c
commit 61bb2f14ba
1 changed files with 10 additions and 5 deletions

View File

@ -146,17 +146,22 @@ module.exports = Self => {
if (!info.hasAccount) return; if (!info.hasAccount) return;
reqs = [];
for (let role of info.user.roles()) { for (let role of info.user.roles()) {
let roleName = role.inherits().name;
let dn = `cn=${roleName},${this.groupDn}`;
let change = new ldap.Change({ let change = new ldap.Change({
operation: 'add', operation: 'add',
modification: {memberUid: userName} modification: {memberUid: userName}
}); });
let roleName = role.inherits().name;
let dn = `cn=${roleName},${this.groupDn}`; try {
reqs.push(client.modify(dn, change)); await client.modify(dn, change);
} catch (err) {
if (err.name !== 'NoSuchObjectError')
throw err;
}
} }
await Promise.all(reqs);
}, },
async getUsers(usersToSync) { async getUsers(usersToSync) {