General plugins (Local): LDAP syncing scripts

Maintained by Picture of Charles FultonCharles Fulton, Picture of Andrew ZitoAndrew Zito
This plugin synchronizes Moodle cohorts against an LDAP directory using either group memberships or attribute values.
503 sites
18 fans
Current versions available: 6

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.


Screenshot #0


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

Comments RSS

Show comments
  • Picture of Michel Rancourt
    Thu, Sep 6, 2018, 11:30 PM
    I've updated the plugin and a lot of cohorts are add / updated! thanks a lot.
  • Picture of Visvanath Ratnaweera
    Fri, Nov 23, 2018, 3:52 AM
    Hi Charles, I have tested v3.4.1 (2018090700) just today against an AD. It does attribute-based sync but no group-based sync. See the details here: The test system is still open, I can do more tests, if you could guide me.
  • Picture of Patrick Lemaire
    Wed, Nov 28, 2018, 4:03 AM
    Hi Charles,
    I succeed in synchronize group-based AD with v3.4.1 (2018090700) but I had to change line 391 in locallib.php :
    - $filter = '(&('.$this->config->user_attribute.'=*)'.$this->config->objectclass.')';
    + $filter = '(&('.$this->config->user_attribute.'=*))';
    Otherwise I had an error for bad syntax in ldap search query.

    Moreover some lines of codes intrigates me. For example, why are there thoses 2 lines 366 & 367?! Only line 367 is useful, isn't it?!

    Despite this half-success I want to synchronize a cohort with a group that is member of an OU. I didn't succeed so far... I activated 'Nested Group' option but nothing happens.

  • Picture of Marini Marini
    Sun, Apr 7, 2019, 5:44 PM
    Hi, I have a question, if someone can help me, I would be very grateful.

    When groups of the active directory are synchronized as cohorts, are the users associated with each group also associated with each cohort?

    thank you!!
  • uk
    Sat, Sep 7, 2019, 1:50 PM
    Hi Charles, the plugin works as it should lächelnd THX I would like to add a comma separated list in the field local_ldap | passed cohort_synching_ldap_attribute_attribute to include not only in the class group but also in the school group. Under no circumstances should all existing groups in the AD be synchronized. Therefore the way over the attribute. I could put a test environment . Regards
  • Stefano Guglielmetti
    Wed, Sep 11, 2019, 7:30 PM
    Hi Charles and Andrew,
    In our site the authentication is managed with the LDAP server plugin (Sync Plus) and is synchronized with Acrive Directory.
    We would like to use your plugin, but having many groups in AD, we would like to import only the Organizational Units that interest us. It's possible to do it?
    Thank you
  • Picture of Charles Fulton
    Sat, Sep 14, 2019, 2:41 AM
    Hi Stefano, there's an active proposal or OU filtering: We're working on it but don't have a code solution yet.
  • Picture of Charles Fulton
    Sat, Sep 14, 2019, 2:51 AM
    Hi Uwe, we don't have plans to support multiple attributes, and it might require some major restructuring of the code to achieve that outcome (like what to do if two attributes have similar values). Please consider filing an issue at for review.
  • Picture of Fabian Messing
    Wed, Feb 5, 2020, 6:47 PM
    Hey guys, i dont know if i am right here but in case not, just delete the post.

    Does the plugin consider configurated filters in the ldap authentification and if not how is the best practices then to enroll only a few seperated groups in the moodle?

    Thanks in advnace

    Kindly Regards

  • Picture of Andrew O'Brien
    Wed, Jul 1, 2020, 6:14 PM
    We're running Moodle 3.9 (Build 20200618) with LDAP script 3.6.0 installed. I've just realised that the cohorts aren't syncing. When I go to Scheduled tasks, they're set to disabled and I can't enable them and when I go to view plugins I can't change the settings.

    Any help greatly appreciated! This continues to be an awesome plugin for our school.
  • Picture of Andrew Zito
    Tue, Jul 7, 2020, 2:49 AM
    Hi Andrew,

    Sorry to hear you're having difficulty. Unfortunately I am not able to reproduce the behavior you are describing -- I'm not even sure what circumstances would cause a plugin settings page to be disabled like that. Could you provide some screenshots for us to look at? Maybe we can figure out what's going wrong.
  • Picture of Axel Rezo
    Tue, Jul 21, 2020, 4:49 AM
    Want to tell how i use script and get good result. In AD i use powershell script to add group name to department field in user attribute. in moodle i set 'Attribute name to search' to department and got all group created and user added. Other metod didnt give me good result, and some error.
    And this script didnt work at all using ldap_plus auth plugin(at least may be needed some code editing).
    Tue, Aug 4, 2020, 7:34 PM
    I have installed Moodle 3.9 in the Windows 2019 Server and enabled Active Directory login and it's working fine without any issues. Now I downloaded ldap sync plugin and copied ldap folder to moodle/local and added cli/syc_cohorts.php and sync_cohorts_attribute.php in the Task Scheduler. After run the task scheduler, only 20 cohorts created out of 150 groups and very few of them only added in the cohorts not all the members.
    Group attribute - cn
    Group class - group
    Process nested groups - yes
    Auto create missing cohorts - yes

    Attribute name to search - department

    Axel, could you please help me, I have made the changes as you suggested, but still it is not populating cohorts.
  • Picture of Tobias Marx
    Tue, Sep 29, 2020, 3:51 PM
    Hi! I would like to add all my LDAP users to one cohort. LDAP is working, but I can't get local_ldap to sync anything. It just does nothing when I run the task. A way to debug would greatly appreciated!
  • Picture of Répondant Informatique
    Mon, Oct 5, 2020, 3:16 AM
    We have the same issue than Tobias Marx.
    We suppose that the problem comes after an upgrade to Moodle 3.8. We try to upgrade to Moodle 3.9, we uninstall and reinstall the plugin but nothing is done when the task is running.

    Execute scheduled task: Synchronisation des cohortes sur les groupes du LDAP (local_ldap\task\group_sync_task)
    ... started 21:13:38. Current memory use 13.8Mo.
    ... used 0 dbqueries
    ... used 0.064833164215088 seconds
    Scheduled task complete: Synchronisation des cohortes sur les groupes du LDAP (local_ldap\task\group_sync_task)

    Our configuration is :
    Group attribute - cn
    Group class - group
    Process nested groups - yes
    Auto create missing cohorts - yes

    The LDAP (Active Directory) authentification works well.

    Thanks for your help.
1 2 3 4 5
Please login to post comments