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) {