You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hallo,
I have a special problem, I want to use your module to sync only some specific moodle cohorts but not all cohorts found in ldap.
So I added a patch to optionally create a list of groups, which is then used as a filter for ldap_get_grouplist. If you find this option useful, please add it to the code, maybe others could use this filter, too.
Hallo,
I have a special problem, I want to use your module to sync only some specific moodle cohorts but not all cohorts found in ldap.
So I added a patch to optionally create a list of groups, which is then used as a filter for ldap_get_grouplist. If you find this option useful, please add it to the code, maybe others could use this filter, too.
I attach the patch to this post.
..diff -up moodle/local/ldap/locallib.php.orig moodle/local/ldap/locallib.php
..--- moodle/local/ldap/locallib.php.orig 2020-07-20 09:53:01.373282357 +0200
..+++ moodle/local/ldap/locallib.php 2020-07-20 10:15:22.966568914 +0200
..@@ -66,6 +66,7 @@ class local_ldap extends auth_plugin_lda
..
.. // Get my specific settings.
.. $extra = get_config('local_ldap');
..+ $this->merge_config($extra, 'group_list','');
.. $this->merge_config($extra, 'group_attribute', 'cn');
.. $this->merge_config($extra, 'group_class', 'groupOfNames');
.. $this->merge_config($extra, 'process_nested_groups', 0);
..@@ -675,7 +676,14 @@ class local_ldap extends auth_plugin_lda
.. public function sync_cohorts_by_group() {
.. global $DB;
..
..- $ldapgroups = $this->ldap_get_grouplist();
..+ $grouplist = $this->config->group_list;
..+ if (! empty($grouplist) && $grouplist != "") {
..+ $filter = "&(" . $this->config->group_attribute . "=)(objectclass=" . $this->config->group_class . ")";
..+ $groupfilter = $filter . "(|(cn=".implode(")(cn=",explode(",",$grouplist))."))";
..+ $ldapgroups = $this->ldap_get_grouplist("(".$groupfilter.")");
..+ } else {
..+ $ldapgroups = $this->ldap_get_grouplist();
..+ }
.. foreach ($ldapgroups as $groupname) {
.. if (!$cohort = $DB->get_record('cohort', array('idnumber' => $groupname), '')) {
.. if (empty($this->config->cohort_synching_ldap_groups_autocreate_cohorts)) {
..diff -up moodle/local/ldap/settings.php.orig moodle/local/ldap/settings.php
..--- moodle/local/ldap/settings.php.orig 2020-06-15 17:07:02.000000000 +0200
..+++ moodle/local/ldap/settings.php 2020-07-20 10:01:48.490646460 +0200
..@@ -27,6 +27,12 @@ defined('MOODLE_INTERNAL') || die;
.. if ($hassiteconfig) {
.. $settings = new admin_settingpage('local_ldap', get_string('pluginname', 'local_ldap'));
..
..+ $name = 'group_list';
..+ $title = 'Group list';
..+ $description = 'Comma separated list of groups to synchronize';
..+ $setting = new admin_setting_configtext('local_ldap/'.$name, $title, $description, '');
..+ $settings->add($setting);
..+
.. $settings->add(new admin_setting_heading('synccohortgroup',
.. get_string('synccohortgroup', 'local_ldap'),
.. get_string('synccohortgroup_info', 'local_ldap')));
..
The text was updated successfully, but these errors were encountered: