Do not record empty memberUid within mixedgroups
Description
I'm using fusiondirectory 1.3 through Debian package (locally recompiled for buster). I'm using the mixedgroups plugin.
When I create a mixedgroup with one user and several (sub-)groups, I got an error about duplicate (empty) memberUid. Indeed, this is due to the fact that the plugin gets a 'uid' attribute for all its entries, even for (sub-)groups that do not have 'uid' attribute.
I fixed this locally with this patch: In ogroups/mixedgroups/class_mixedGroup.inc, in prepare_save(), I replace:
foreach ($members as $dn) {
$ldap->cat($dn, array('uid'));
$attrs = $ldap->fetch();
$memberUid[] = $attrs['uid'][0];
}
by
foreach ($members as $dn) {
$ldap->cat($dn, array('uid'));
$attrs = $ldap->fetch();
/* Some members (other groups) do not have uid
* Adding a empty uid is not a problem, but adding two or more is */
if ($attrs['uid'][0] != '') {
$memberUid[] = $attrs['uid'][0];
}
}
Note: it solve my problem but you might want to do other things, for example:
-
allows empty uid but skip entries with no uid attribute (my patch does the same thing for both cases)
-
check that there are no duplicate uid (empty or not). If there are:
- return an error
- cleanup the list to keep only unique values
- or ...
Regards Vincent
PS: the code in gitlab seems to be the same in the 1.4 branch, so this bug does not seem already fixed.