moodle_print_object("current members : " . count($currentmembers) . ' ', $currentmembers); } // it is unlikely that there is mre than one LDAP per institution foreach ($auths as $auth) { $instance = new GAAuthLdap($auth->id); $instance->set_config('group_synching_ldap_attribute_attribute', $attributename); // override defaut contexts values for the auth plugin if ($onlycontexts) { $instance->set_config('contexts', $onlycontexts); } // OVERRRIDING searchsub contexts for this auth plugin if ($searchsub !== false) { $instance->set_config('search_sub', $searchsub ? 'yes' : 'no'); } if ($CFG->debug_ldap_groupes) { moodle_print_object("config. LDAP : ", $instance->get_config()); } // get the distinct values of the used attribute by a LDAP search // that may be restricted by flags -c or -o $groups = $instance->get_attribute_distinct_values(); if ($CFG->debug_ldap_groupes) { moodle_print_object("distinct values found for {$attributename} ", $groups); } $nbadded = 0; foreach ($groups as $group) { // skip if in excludelist or not in the includelist if (!ldap_sync_filter_name($group, $includelist, $excludelist)) { continue; } if ($CFG->debug_ldap_groupes) { moodle_print_object("processing group : ", $group);
if (count($auths) == 0) { $cli->cli_exit(get_string('cli_mahara_nomatchingauths', 'local.ldap')); } execute_sql('CREATE TEMPORARY TABLE extusers (extusername VARCHAR(64), PRIMARY KEY (extusername))', false); // it is unlikely that there is mre than one LDAP per institution foreach ($auths as $auth) { $instance = new GAAuthLdap($auth->id); // override defaut contexts values for the auth plugin if ($onlycontexts) { $instance->set_config('contexts', $onlycontexts); } // OVERRRIDING searchsub contexts for this auth plugin if ($searchsub !== false) { $instance->set_config('search_sub', $searchsub ? 'yes' : 'no'); } $instanceconfig = $instance->get_config(); if ($CFG->debug_ldap_groupes) { moodle_print_object("config. LDAP : ", $instanceconfig); } // fetch ldap users having the filter attribute on (caution maybe mutlivalued // do it on a scalable version by keeping the LDAP users names in a temporary table $nbldapusers = $instance->ldap_get_users_scalable('extusers', 'extusername', $extrafilterattribute); $cli->cli_print('LDAP users found : ' . $nbldapusers); if ($nbldapusers < 99) { //sécurité avec cipcauth $USER->logout(); $cli->cli_exit(get_string('cli_mahara_noldapusersfound', 'local.ldap')); } try { $nbupdated = $nbcreated = $nbsuspended = $nbdeleted = $nbignored = $nbpresents = $nbunsuspended = $nberrors = 0; // Define ldap attributes in user update