From b2a3adc96ff4eacfe85ad84b7ac1734a7300bc43 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 30 Nov 2020 18:50:04 +0100 Subject: [PATCH] LDAP sync hotfix --- modules/account/back/models/ldap-config.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/account/back/models/ldap-config.js b/modules/account/back/models/ldap-config.js index 9f0e84c66..6b9d9f4dc 100644 --- a/modules/account/back/models/ldap-config.js +++ b/modules/account/back/models/ldap-config.js @@ -146,17 +146,22 @@ module.exports = Self => { if (!info.hasAccount) return; - reqs = []; for (let role of info.user.roles()) { + let roleName = role.inherits().name; + + let dn = `cn=${roleName},${this.groupDn}`; let change = new ldap.Change({ operation: 'add', modification: {memberUid: userName} }); - let roleName = role.inherits().name; - let dn = `cn=${roleName},${this.groupDn}`; - reqs.push(client.modify(dn, change)); + + try { + await client.modify(dn, change); + } catch (err) { + if (err.name !== 'NoSuchObjectError') + throw err; + } } - await Promise.all(reqs); }, async getUsers(usersToSync) {