Hi,
i have a little Change, that will also leave User when NOT in ldap group:
groupJoin: (ldapGroup, ldapId, uid, callback) => {
winston.verbose("[LDAP] groupJoin " + ldapGroup.cn + " for user " + ldapId + " uid " + uid)
nodebb_ldap.createGroup(ldapGroup,
(err, groupId) => {
if (err) {
return callback(err);
}
let members = ldapGroup.uniqueMember;
if (!Array.isArray(members)) {
members = [members];
}
winston.verbose("[LDAP] groupJoin members " + members && typeof members)
let found = false
if (members) {
members.forEach(member => {
if (member && member.indexOf(ldapId) != -1) {
found = true
}
});
}
if (found) {
const groupsToJoin = [groupId];
if ((master_config.admin_groups || '').split(',').includes(ldapGroup.cn)) {
winston.verbose("[LDAP] joins admin group")
groupsToJoin.push('administrators');
}
if ((master_config.moderator_groups || '').split(',').includes(ldapGroup.cn)) {
groupsToJoin.push('Global Moderators');
}
return groups.join(groupsToJoin, uid, callback);
} else {
const groupsToUnJoin = [groupId];
winston.verbose("[LDAP] unjoins group" + ldapGroup.cn + " uid " + uid);
return groups.leave(groupsToUnJoin, uid, callback);
//callback();
}
}
);
},
thats realy cool for use maybe someone else will help it