Moodle plugins directory: LDAP syncing scripts | Moodle.org
LDAP syncing scripts
General plugins (Local) ::: local_ldap
Maintained by Charles Fulton, Andrew Zito
This plugin synchronizes Moodle cohorts against an LDAP directory using either group memberships or attribute values.
Latest release:
680 sites
481 downloads
31 fans
Current versions available: 10
This plugin synchronizes Moodle cohorts against an LDAP directory using either group memberships or attribute values. This is a continuation of Patrick Pollet's local_ldap plugin, which in turn was inspired by MDL-25011 and MDL-25054.
This plugin requires that you have either CAS or LDAP enabled as an authentication method. It officially supports OpenLDAP and Active Directory. Both have unit test coverage.
The synchronization tasks are managed as scheduled tasks and are disabled by default.
Useful links
Contributors
Charles Fulton (Lead maintainer)
Andrew Zito
Please login to view contributors details and/or to contact them
And if I try to run via /admin/tool/task/schedule_task.php?task=local_ldap\task\group_sync_task the system gives a error page "Sorry, but you do not currently have permissions to do that (Run now)."
Moodle 4.0.3+ (Build: 20220902)
local_ldap v3.7.1 2020110901
Execute scheduled task: Synchronize cohorts from LDAP groups (local_ldap\task\group_sync_task)
... started 10:47:40. Current memory use 14.5 MB.
Debugging increased temporarily due to faildelay of 120
... used 1 dbqueries
... used 0.035255908966064 seconds
Scheduled task failed: Synchronize cohorts from LDAP groups (local_ldap\task\group_sync_task),count(): Argument #1 ($value) must be of type Countable|array, null given
Backtrace:
* line 496 of /local/ldap/locallib.php: call to local_ldap->ldap_get_group_members_ad()
* line 771 of /local/ldap/locallib.php: call to local_ldap->ldap_get_group_members()
* line 55 of /local/ldap/classes/task/group_sync_task.php: call to local_ldap->sync_cohorts_by_group()
* line 259 of /lib/cronlib.php: call to local_ldap\task\group_sync_task->execute()
* line 167 of /admin/cli/scheduled_task.php: call to cron_run_inner_scheduled_task()
On PHP8.0 compulsory types are define on Count.
count((array)$XYZVariable);
stackoverflow.com/questions/66671269/fatal-error-uncaught-typeerror-count-argument-1-var-must-be-of-type-cou
I keep receiving the following message:
PHP Notice: Undefined index: member;range=0-* in /home/agora.cfaiprovence.com/public_html/local/ldap/locallib.php on line 380
PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/agora.cfaiprovence.com/public_html/local/ldap/locallib.php on line 380
So, I added the following two lines of code in the locallib.php file just before line 380:
echo var_dump($group);
error_log(json_encode($group));
Then I got a message that seems to show that the code does not handle cases where LDAP groups do not contain members. The following line seems to show that $group contains one member in the "3205 PERF ...." OU, and this does not generate an error:
{"count":1,"0":{"member;range=0-":{"count":1,"0":"CN=Julien FENELON,OU=3205 PERFECTIONNEMENT PROCEDE MAG 135,OU=nvxinscritsFC,OU=APPRENTI,DC=apprenti,DC=local"},"0":"member;range=0-","count":1,"dn":"CN=3205 PERFECTIONNEMENT PROCEDE MAG 135,OU=3205 PERFECTIONNEMENT PROCEDE MAG 135,OU=nvxinscritsFC,OU=APPRENTI,DC=apprenti,DC=local"}}
However, in the following example, there are no members in the "3142 CQPM ...." OU, and an error appears:
{"count":1,"0":{"count":0,"dn":"CN=3142 CQPM 284,OU=3142 CQPM 284,OU=nvxinscritsFC,OU=APPRENTI,DC=apprenti,DC=local"}}
PHP Notice: Undefined index: member;range=0-* in /home/agora.cfaiprovence.com/public_html/local/ldap/locallib.php on line 383
PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/agora.cfaiprovence.com/public_html/local/ldap/locallib.php on line 383
Do you think the code can be modified to handle empty OUs?