Adambean / gitlab-ce-ldap-sync

Synchronise users and groups (including group members) from an LDAP instance with Gitlab CE (and EE in free tier) self-hosted instance(s).
Apache License 2.0
59 stars 23 forks source link

Not creating Groups with only 1 member #5

Closed jsiegers closed 5 years ago

jsiegers commented 5 years ago

Again love your script. Found another little bug. Sometimes it does this. I've placed a user in a group but the group isn't made in GitLab.

In the beginning of the script it says:

[info] Found directory group "hedge".
[warning] Group #1 / member #1: User not found "gitlab01".
[info] Found directory group "hedge" member "jsiegers".
[notice] 1 directory group "hedge" member(s) recognised.

While later on when it needs to create the directory it says:

[notice] Creating directory groups of which don't exist in Gitlab...
[warning] Not creating Gitlab group "hedge" [hedge]: No members in directory group, or config gitlab->options->createEmptyGroups is disabled.
[notice] 0 Gitlab group(s) created.

But as soon as I put another user inside of the group it will create it. It looks like there need to be at least 2 users before it creates it. I expect that a group of 1 should also be possible.

Adambean commented 5 years ago

My fault. I was trying to be smart with Yoda condition formatting but got it wrong: 1 >= count($ldapGroupMembers) That would exclude groups with 1 member. It should be: 1 > count($ldapGroupMembers)

jsiegers commented 5 years ago

Cheers! Tested and works now!