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.

Screenshots

Screenshot #0

Contributors

Charles Fulton (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Zigor Astarbe
    Mon, 12 Sept 2022, 6:21 PM
    Missing link "Run now" here too. That's a problem for us.
  • Charles Fulton
    Wed, 14 Sept 2022, 9:11 PM
    To be clear, do you see "run now" for other scheduled tasks, just not for this one?
  • Zigor Astarbe
    Thu, 15 Sept 2022, 3:27 AM
    Exact.
    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
  • Reinhard Sacher
    Tue, 10 Jan 2023, 6:06 PM
    moodle 4.1 php 8.1 MS-AD
    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()
  • Charles Fulton
    Tue, 10 Jan 2023, 9:07 PM
    Hello Reinhard, thank you for the report. I notice that you're running Moodle on PHP 8.1. That's not officially supported by Moodle HQ yet (see https://tracker.moodle.org/browse/MDL-73016) and I haven't tested this plugin against PHP 8.1. I attempted to run tests against PHP 8.1 with Moodle 4.1 and wasn't even able to set up the Moodle test suite: https://app.travis-ci.com/github/LafColITS/moodle-local_ldap/jobs/592934549. You should consider downgrading PHP to 8.0.
  • Reinhard Sacher
    Wed, 11 Jan 2023, 7:16 PM
    Thank you Charles… I assumed differences to php 8.0 would not break things, as everything else seems to work…I will try 8.0 to check, if this solves the problem.
  • Reinhard Sacher
    Thu, 12 Jan 2023, 3:35 AM
    8.0 did not solve the problem but on stackoverflow I found the change from php7 to 8: (notice the "(array)" )

    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
  • Charles Fulton
    Wed, 18 Jan 2023, 5:54 AM
    Reinhard, thank you, that's helpful. I'm now tracking this at https://github.com/LafColITS/moodle-local_ldap/issues/34 and may have a fix. I'll need your help to test.
  • Philippe VIEN
    Wed, 1 Mar 2023, 4:37 PM
    Hello,

    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?
  • Andrew O'Brien
    Thu, 2 Mar 2023, 9:30 PM
    I was receiving the same error as Phillippe Vien and applied the new update v3.11.0, but it emptied all the cohorts. Fortunately I had a checkpoint I could roll back to. Moodle version is Moodle 4.0.6+ (Build: 20230217).
  • Charles Fulton
    Thu, 2 Mar 2023, 9:57 PM
    Andrew, that's obviously unexpected and I'm glad to hear you had backups. Do you have any additional debugging information?
  • Charles Fulton
    Thu, 2 Mar 2023, 10:46 PM
    I've pulled v3.11.0 from active release until there's a better understanding of what's going on here.
  • Vince DiScipio
    Wed, 15 Mar 2023, 8:39 PM
    Is there a location to set a search base for the LDAP structure. We would not want the entire LDAP structure read each time, but would like to take a branch off the tree and down.
  • Charles Fulton
    Thu, 6 Apr 2023, 10:26 PM
    The new v3.11.1 release addresses the AD pagination issues introduced in v3.11.0 and also has a fix for empty groups.
  • Ylber Ukzmajli
    Wed, 9 Aug 2023, 8:59 PM
    Hi, We are a Professional school with approx 8'000 students and we are using this plugin to sync our AD groups into Moodle cohorts. We are currently in Moodle 4.1 and we just found that the sync is not working. I don't have error message and it sais "sync successful" but the new cohorts are not created and the members not updated. It worked well before and we did'nt make any change in the moodle configuration... If anyone can help it would be precious.
Please login to post comments